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