diff options
Diffstat (limited to 'classes/image_types_ostree.bbclass')
-rw-r--r-- | classes/image_types_ostree.bbclass | 94 |
1 files changed, 30 insertions, 64 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 5286efc..4095de0 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -1,42 +1,30 @@ | |||
1 | # OSTree deployment | 1 | # OSTree deployment |
2 | 2 | inherit distro_features_check | |
3 | do_image_ostree[depends] += "ostree-native:do_populate_sysroot \ | ||
4 | openssl-native:do_populate_sysroot \ | ||
5 | coreutils-native:do_populate_sysroot \ | ||
6 | unzip-native:do_populate_sysroot \ | ||
7 | virtual/kernel:do_deploy \ | ||
8 | ${INITRAMFS_IMAGE}:do_image_complete \ | ||
9 | " | ||
10 | do_image_ostree[lockfiles] += "${OSTREE_REPO}/ostree.lock" | ||
11 | |||
12 | export OSTREE_REPO | ||
13 | export OSTREE_BRANCHNAME | ||
14 | export GARAGE_TARGET_NAME | ||
15 | 3 | ||
16 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" | 4 | OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" |
17 | 5 | OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs" | |
18 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" | 6 | OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" |
19 | OSTREE_COMMIT_BODY ??= "" | 7 | OSTREE_COMMIT_BODY ??= "" |
20 | OSTREE_UPDATE_SUMMARY ??= "0" | 8 | OSTREE_UPDATE_SUMMARY ??= "0" |
21 | 9 | ||
22 | export SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" | 10 | BUILD_OSTREE_TARBALL ??= "1" |
23 | 11 | ||
24 | IMAGE_CMD_ostree () { | 12 | SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" |
25 | if [ -z "$OSTREE_REPO" ]; then | ||
26 | bbfatal "OSTREE_REPO should be set in your local.conf" | ||
27 | fi | ||
28 | 13 | ||
29 | if [ -z "$OSTREE_BRANCHNAME" ]; then | 14 | IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*" |
30 | bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" | 15 | CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}; ${IMAGE_CMD_TAR} --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.tar -C ${OTA_IMAGE_ROOTFS} . || [ $? -eq 1 ]" |
31 | fi | 16 | CONVERSIONTYPES_append = " tar" |
32 | 17 | ||
33 | OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` | 18 | REQUIRED_DISTRO_FEATURES = "usrmerge" |
34 | cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} | 19 | OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" |
20 | do_image_ostree[dirs] = "${OSTREE_ROOTFS}" | ||
21 | do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" | ||
22 | do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" | ||
23 | IMAGE_CMD_ostree () { | ||
24 | cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS} | ||
35 | chmod a+rx ${OSTREE_ROOTFS} | 25 | chmod a+rx ${OSTREE_ROOTFS} |
36 | sync | 26 | sync |
37 | 27 | ||
38 | cd ${OSTREE_ROOTFS} | ||
39 | |||
40 | for d in var/*; do | 28 | for d in var/*; do |
41 | if [ "${d}" != "var/local" ]; then | 29 | if [ "${d}" != "var/local" ]; then |
42 | rm -rf ${d} | 30 | rm -rf ${d} |
@@ -53,18 +41,8 @@ IMAGE_CMD_ostree () { | |||
53 | mkdir -p usr/rootdirs | 41 | mkdir -p usr/rootdirs |
54 | 42 | ||
55 | mv etc usr/ | 43 | mv etc usr/ |
56 | # Implement UsrMove | ||
57 | dirs="bin sbin lib" | ||
58 | |||
59 | for dir in ${dirs} ; do | ||
60 | if [ -d ${dir} ] && [ ! -L ${dir} ] ; then | ||
61 | mv ${dir} usr/rootdirs/ | ||
62 | rm -rf ${dir} | ||
63 | ln -sf usr/rootdirs/${dir} ${dir} | ||
64 | fi | ||
65 | done | ||
66 | 44 | ||
67 | if [ -n "$SYSTEMD_USED" ]; then | 45 | if [ -n "${SYSTEMD_USED}" ]; then |
68 | mkdir -p usr/etc/tmpfiles.d | 46 | mkdir -p usr/etc/tmpfiles.d |
69 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf | 47 | tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf |
70 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} | 48 | echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} |
@@ -100,7 +78,7 @@ IMAGE_CMD_ostree () { | |||
100 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" | 78 | bbwarn "Data in /$dir directory is not preserved by OSTree. Consider moving it under /usr" |
101 | fi | 79 | fi |
102 | 80 | ||
103 | if [ -n "$SYSTEMD_USED" ]; then | 81 | if [ -n "${SYSTEMD_USED}" ]; then |
104 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} | 82 | echo "d /var/rootdirs/${dir} 0755 root root -" >>${tmpfiles_conf} |
105 | else | 83 | else |
106 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} | 84 | echo "mkdir -p /var/rootdirs/${dir}; chown 755 /var/rootdirs/${dir}" >>${tmpfiles_conf} |
@@ -112,11 +90,10 @@ IMAGE_CMD_ostree () { | |||
112 | 90 | ||
113 | if [ -d root ] && [ ! -L root ]; then | 91 | if [ -d root ] && [ ! -L root ]; then |
114 | if [ "$(ls -A root)" ]; then | 92 | if [ "$(ls -A root)" ]; then |
115 | bberror "Data in /root directory is not preserved by OSTree." | 93 | bbfatal "Data in /root directory is not preserved by OSTree." |
116 | exit 1 | ||
117 | fi | 94 | fi |
118 | 95 | ||
119 | if [ -n "$SYSTEMD_USED" ]; then | 96 | if [ -n "${SYSTEMD_USED}" ]; then |
120 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} | 97 | echo "d /var/roothome 0755 root root -" >>${tmpfiles_conf} |
121 | else | 98 | else |
122 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} | 99 | echo "mkdir -p /var/roothome; chown 755 /var/roothome" >>${tmpfiles_conf} |
@@ -140,17 +117,12 @@ IMAGE_CMD_ostree () { | |||
140 | 117 | ||
141 | # Copy image manifest | 118 | # Copy image manifest |
142 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest | 119 | cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest |
120 | } | ||
143 | 121 | ||
144 | cd ${WORKDIR} | 122 | IMAGE_TYPEDEP_ostreecommit = "ostree" |
145 | 123 | do_image_ostreecommit[depends] += "ostree-native:do_populate_sysroot" | |
146 | # Create a tarball that can be then commited to OSTree repo | 124 | do_image_ostreecommit[lockfiles] += "${OSTREE_REPO}/ostree.lock" |
147 | OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 | 125 | IMAGE_CMD_ostreecommit () { |
148 | tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} . | ||
149 | sync | ||
150 | |||
151 | rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
152 | ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2 | ||
153 | |||
154 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then | 126 | if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then |
155 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 | 127 | ostree --repo=${OSTREE_REPO} init --mode=archive-z2 |
156 | fi | 128 | fi |
@@ -166,11 +138,9 @@ IMAGE_CMD_ostree () { | |||
166 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 138 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then |
167 | ostree --repo=${OSTREE_REPO} summary -u | 139 | ostree --repo=${OSTREE_REPO} summary -u |
168 | fi | 140 | fi |
169 | |||
170 | rm -rf ${OSTREE_ROOTFS} | ||
171 | } | 141 | } |
172 | 142 | ||
173 | IMAGE_TYPEDEP_ostreepush = "ostree" | 143 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" |
174 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" | 144 | do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" |
175 | IMAGE_CMD_ostreepush () { | 145 | IMAGE_CMD_ostreepush () { |
176 | # Print warnings if credetials are not set or if the file has not been found. | 146 | # Print warnings if credetials are not set or if the file has not been found. |
@@ -189,7 +159,7 @@ IMAGE_CMD_ostreepush () { | |||
189 | } | 159 | } |
190 | 160 | ||
191 | IMAGE_TYPEDEP_garagesign = "ostreepush" | 161 | IMAGE_TYPEDEP_garagesign = "ostreepush" |
192 | do_image_garagesign[depends] += "aktualizr-native:do_populate_sysroot" | 162 | do_image_garagesign[depends] += "unzip-native:do_populate_sysroot" |
193 | IMAGE_CMD_garagesign () { | 163 | IMAGE_CMD_garagesign () { |
194 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 164 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
195 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 165 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
@@ -197,11 +167,9 @@ IMAGE_CMD_garagesign () { | |||
197 | 167 | ||
198 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) | 168 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) |
199 | if [ "${java_version}" = "" ]; then | 169 | if [ "${java_version}" = "" ]; then |
200 | bberror "Java is required for synchronization with update backend, but is not installed on the host machine" | 170 | bbfatal "Java is required for synchronization with update backend, but is not installed on the host machine" |
201 | exit 1 | ||
202 | elif [ "${java_version}" \< "1.8" ]; then | 171 | elif [ "${java_version}" \< "1.8" ]; then |
203 | bberror "Java version >= 8 is required for synchronization with update backend" | 172 | bbfatal "Java version >= 8 is required for synchronization with update backend" |
204 | exit 1 | ||
205 | fi | 173 | fi |
206 | 174 | ||
207 | rm -rf ${GARAGE_SIGN_REPO} | 175 | rm -rf ${GARAGE_SIGN_REPO} |
@@ -235,7 +203,7 @@ IMAGE_CMD_garagesign () { | |||
235 | --length 0 \ | 203 | --length 0 \ |
236 | --url "${GARAGE_TARGET_URL}" \ | 204 | --url "${GARAGE_TARGET_URL}" \ |
237 | --sha256 ${ostree_target_hash} \ | 205 | --sha256 ${ostree_target_hash} \ |
238 | --hardwareids ${MACHINE} | 206 | --hardwareids ${SOTA_HARDWARE_ID} |
239 | garage-sign targets sign --repo tufrepo \ | 207 | garage-sign targets sign --repo tufrepo \ |
240 | --home-dir ${GARAGE_SIGN_REPO} \ | 208 | --home-dir ${GARAGE_SIGN_REPO} \ |
241 | --key-name=targets | 209 | --key-name=targets |
@@ -252,14 +220,12 @@ IMAGE_CMD_garagesign () { | |||
252 | rm -rf ${GARAGE_SIGN_REPO} | 220 | rm -rf ${GARAGE_SIGN_REPO} |
253 | 221 | ||
254 | if [ "$push_success" -ne "1" ]; then | 222 | if [ "$push_success" -ne "1" ]; then |
255 | bberror "Couldn't push to garage repository" | 223 | bbfatal "Couldn't push to garage repository" |
256 | exit 1 | ||
257 | fi | 224 | fi |
258 | fi | 225 | fi |
259 | } | 226 | } |
260 | 227 | ||
261 | IMAGE_TYPEDEP_garagecheck = "ostreepush garagesign" | 228 | IMAGE_TYPEDEP_garagecheck = "garagesign" |
262 | do_image_garagecheck[depends] += "aktualizr-native:do_populate_sysroot" | ||
263 | IMAGE_CMD_garagecheck () { | 229 | IMAGE_CMD_garagecheck () { |
264 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 230 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
265 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 231 | # if credentials are issued by a server that doesn't support offline signing, exit silently |