diff options
Diffstat (limited to 'classes/image_types_ostree.bbclass')
-rw-r--r-- | classes/image_types_ostree.bbclass | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 533d338..3b86b35 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -19,14 +19,24 @@ CONVERSIONTYPES_append = " tar" | |||
19 | 19 | ||
20 | REQUIRED_DISTRO_FEATURES = "usrmerge" | 20 | REQUIRED_DISTRO_FEATURES = "usrmerge" |
21 | TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" | 21 | TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" |
22 | |||
23 | python prepare_ostree_rootfs() { | ||
24 | import oe.path | ||
25 | import shutil | ||
26 | |||
27 | ostree_rootfs = d.getVar("OSTREE_ROOTFS") | ||
28 | if os.path.lexists(ostree_rootfs): | ||
29 | bb.utils.remove(ostree_rootfs, True) | ||
30 | |||
31 | # Copy required as we change permissions on some files. | ||
32 | image_rootfs = d.getVar("IMAGE_ROOTFS") | ||
33 | oe.path.copyhardlinktree(image_rootfs, ostree_rootfs) | ||
34 | } | ||
35 | |||
22 | do_image_ostree[dirs] = "${OSTREE_ROOTFS}" | 36 | do_image_ostree[dirs] = "${OSTREE_ROOTFS}" |
23 | do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" | 37 | do_image_ostree[prefuncs] += "prepare_ostree_rootfs" |
24 | do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" | 38 | do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" |
25 | IMAGE_CMD_ostree () { | 39 | IMAGE_CMD_ostree () { |
26 | cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS} | ||
27 | chmod a+rx ${OSTREE_ROOTFS} | ||
28 | sync | ||
29 | |||
30 | for d in var/*; do | 40 | for d in var/*; do |
31 | if [ "${d}" != "var/local" ]; then | 41 | if [ "${d}" != "var/local" ]; then |
32 | rm -rf ${d} | 42 | rm -rf ${d} |
@@ -37,9 +47,6 @@ IMAGE_CMD_ostree () { | |||
37 | mkdir sysroot | 47 | mkdir sysroot |
38 | ln -sf sysroot/ostree ostree | 48 | ln -sf sysroot/ostree ostree |
39 | 49 | ||
40 | rm -rf tmp/* | ||
41 | ln -sf sysroot/tmp tmp | ||
42 | |||
43 | mkdir -p usr/rootdirs | 50 | mkdir -p usr/rootdirs |
44 | 51 | ||
45 | mv etc usr/ | 52 | mv etc usr/ |
@@ -63,13 +70,11 @@ IMAGE_CMD_ostree () { | |||
63 | mkdir -p usr/share/sota/ | 70 | mkdir -p usr/share/sota/ |
64 | echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname | 71 | echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname |
65 | 72 | ||
66 | # Preserve data in /home to be later copied to /sysroot/home by sysroot | 73 | # home directories get copied from the OE root later to the final sysroot |
67 | # generating procedure | 74 | # Create a symlink to var/rootdirs/home to make sure the OSTree deployment |
68 | mkdir -p usr/homedirs | 75 | # redirects /home to /var/rootdirs/home. |
69 | if [ -d "home" ] && [ ! -L "home" ]; then | 76 | rm -rf home/ |
70 | mv home usr/homedirs/home | 77 | ln -sf var/rootdirs/home home |
71 | ln -sf var/rootdirs/home home | ||
72 | fi | ||
73 | 78 | ||
74 | # Move persistent directories to /var | 79 | # Move persistent directories to /var |
75 | dirs="opt mnt media srv" | 80 | dirs="opt mnt media srv" |
@@ -137,7 +142,7 @@ IMAGE_CMD_ostree () { | |||
137 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") | 142 | checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") |
138 | touch boot/initramfs-${checksum} | 143 | touch boot/initramfs-${checksum} |
139 | else | 144 | else |
140 | if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then | 145 | if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${KERNEL_DEVICETREE}" ]; then |
141 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") | 146 | checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") |
142 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | 147 | for DTS_FILE in ${KERNEL_DEVICETREE}; do |
143 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) | 148 | DTS_FILE_BASENAME=$(basename ${DTS_FILE}) |
@@ -164,25 +169,20 @@ IMAGE_CMD_ostreecommit () { | |||
164 | fi | 169 | fi |
165 | 170 | ||
166 | # Commit the result | 171 | # Commit the result |
167 | ostree --repo=${OSTREE_REPO} commit \ | 172 | ostree_target_hash=$(ostree --repo=${OSTREE_REPO} commit \ |
168 | --tree=dir=${OSTREE_ROOTFS} \ | 173 | --tree=dir=${OSTREE_ROOTFS} \ |
169 | --skip-if-unchanged \ | 174 | --skip-if-unchanged \ |
170 | --branch=${OSTREE_BRANCHNAME} \ | 175 | --branch=${OSTREE_BRANCHNAME} \ |
171 | --subject="${OSTREE_COMMIT_SUBJECT}" \ | 176 | --subject="${OSTREE_COMMIT_SUBJECT}" \ |
172 | --body="${OSTREE_COMMIT_BODY}" \ | 177 | --body="${OSTREE_COMMIT_BODY}" \ |
173 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ | 178 | --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ |
174 | --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" | 179 | ${EXTRA_OSTREE_COMMIT}) |
175 | 180 | ||
176 | if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then | 181 | echo $ostree_target_hash > ${WORKDIR}/ostree_manifest |
182 | |||
183 | if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then | ||
177 | ostree --repo=${OSTREE_REPO} summary -u | 184 | ostree --repo=${OSTREE_REPO} summary -u |
178 | fi | 185 | fi |
179 | |||
180 | # To enable simultaneous bitbaking of two images with the same branch name, | ||
181 | # create a new ref in the repo using the basename of the image. (This first | ||
182 | # requires deleting it if it already exists.) Fixes OTA-2211. | ||
183 | ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} | ||
184 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) | ||
185 | ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash} | ||
186 | } | 186 | } |
187 | 187 | ||
188 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" | 188 | IMAGE_TYPEDEP_ostreepush = "ostreecommit" |
@@ -197,7 +197,7 @@ IMAGE_CMD_ostreepush () { | |||
197 | 197 | ||
198 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 198 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
199 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then | 199 | if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then |
200 | garage-push -vv --repo=${OSTREE_REPO} \ | 200 | garage-push --loglevel 0 --repo=${OSTREE_REPO} \ |
201 | --ref=${OSTREE_BRANCHNAME} \ | 201 | --ref=${OSTREE_BRANCHNAME} \ |
202 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | 202 | --credentials=${SOTA_PACKED_CREDENTIALS} \ |
203 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \ | 203 | --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \ |
@@ -232,7 +232,7 @@ IMAGE_CMD_garagesign () { | |||
232 | --home-dir ${GARAGE_SIGN_REPO} \ | 232 | --home-dir ${GARAGE_SIGN_REPO} \ |
233 | --credentials ${SOTA_PACKED_CREDENTIALS} | 233 | --credentials ${SOTA_PACKED_CREDENTIALS} |
234 | 234 | ||
235 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 235 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
236 | 236 | ||
237 | # Use OSTree target hash as version if none was provided by the user | 237 | # Use OSTree target hash as version if none was provided by the user |
238 | target_version=${ostree_target_hash} | 238 | target_version=${ostree_target_hash} |
@@ -308,7 +308,7 @@ IMAGE_CMD_garagecheck () { | |||
308 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 308 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
309 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 | 309 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 |
310 | 310 | ||
311 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) | 311 | ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) |
312 | 312 | ||
313 | garage-check --ref=${ostree_target_hash} \ | 313 | garage-check --ref=${ostree_target_hash} \ |
314 | --credentials=${SOTA_PACKED_CREDENTIALS} \ | 314 | --credentials=${SOTA_PACKED_CREDENTIALS} \ |