summaryrefslogtreecommitdiffstats
path: root/classes/image_types_ostree.bbclass
diff options
context:
space:
mode:
authorMing Liu <liu.ming50@gmail.com>2018-11-20 09:03:25 +0100
committerMing Liu <liu.ming50@gmail.com>2018-11-24 14:24:26 +0100
commite97975d6113ca1ffa6cbe9b005bd518bd146fd9c (patch)
tree0c1df1f626bfd3d1819661dda5fb6ff7c4877210 /classes/image_types_ostree.bbclass
parentf4cf0698a88631af150782dce9b3dafcb0dbc5d5 (diff)
downloadmeta-updater-e97975d6113ca1ffa6cbe9b005bd518bd146fd9c.tar.gz
image_types_ostree/ota.bbclass: refactor ostree task
There are several flaws with ostree tasks, as follows: - ${IMAGE_NAME}.rootfs.ostree.tar.bz2 is generated, but it's not being used during ostree commit, so it should be removed if it's just a intermittent artifact. Or if we intend to deploy this tar.bz2 file, it should be tracked by sstate cache, that is to day, it should be generated in ${IMGDEPLOYDIR} rather than in ${DEPLOY_DIR_IMAGE}. - There are quite a few redundant code like mktemp/cd/rm a directory, which can be replaced by setting 'dirs', 'cleandirs' varflags. - There are some redundant variable check logic in image_types_ostree and image_types_ota bbclass. To fix the above, we make the following changes: - Introduce a new conversion image type 'tar', it could convert ostree and ota to ostree.tar, ota.tar, hence we can drop the code generating ostree.tar.bz2 in image_types_ostree.bbclass, and also drop the do_image_ota-tar task. To let this conversion type take effect, the otasetup task needs to be changed to ota. - Introduce BUILD_OSTREE_TARBALL variable, when being set to 1, a ostree.tar.bz2 tarball would be built, BUILD_OSTREE_TARBALL defaults to be 1, to be consistent with original behavior. - Replace 'ota-tar ota-tar.xz' with ota.tar.xz in IMAGE_FSTYPES. - Add a sanity check bbclass sota_sanity.bbclass, to ensure ostree or ota is not in OVERRIDES, this is to prevent potential naming pollution with other meta layers, and also check the required variables are not empty. This sota_sanity.bbclass is a common class that could be extended easily in furture, and one of its most advantages is that all the check are done in bb.event.SanityCheck event handler, so the end users could get the error message at very beginning of the recipe parsing time. Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Diffstat (limited to 'classes/image_types_ostree.bbclass')
-rw-r--r--classes/image_types_ostree.bbclass50
1 files changed, 18 insertions, 32 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass
index 44a3aa4..41b8d0d 100644
--- a/classes/image_types_ostree.bbclass
+++ b/classes/image_types_ostree.bbclass
@@ -1,35 +1,28 @@
1# OSTree deployment 1# OSTree deployment
2 2
3do_image_ostree[depends] += "ostree-native:do_populate_sysroot \
4 coreutils-native:do_populate_sysroot \
5 virtual/kernel:do_deploy \
6 ${INITRAMFS_IMAGE}:do_image_complete \
7"
8do_image_ostree[lockfiles] += "${OSTREE_REPO}/ostree.lock"
9
10OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}" 3OSTREE_KERNEL ??= "${KERNEL_IMAGETYPE}"
4OSTREE_ROOTFS ??= "${WORKDIR}/ostree-rootfs"
11OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}" 5OSTREE_COMMIT_SUBJECT ??= "Commit-id: ${IMAGE_NAME}"
12OSTREE_COMMIT_BODY ??= "" 6OSTREE_COMMIT_BODY ??= ""
13OSTREE_UPDATE_SUMMARY ??= "0" 7OSTREE_UPDATE_SUMMARY ??= "0"
14 8
15SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}" 9BUILD_OSTREE_TARBALL ??= "1"
16 10
17IMAGE_CMD_ostree () { 11SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager', True) == 'systemd', 'true', '')}"
18 if [ -z "$OSTREE_REPO" ]; then
19 bbfatal "OSTREE_REPO should be set in your local.conf"
20 fi
21 12
22 if [ -z "$OSTREE_BRANCHNAME" ]; then 13IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*"
23 bbfatal "OSTREE_BRANCHNAME should be set in your local.conf" 14CONVERSION_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 ]"
24 fi 15CONVERSIONTYPES_append = " tar"
25 16
26 OSTREE_ROOTFS=`mktemp -du ${WORKDIR}/ostree-root-XXXXX` 17OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}"
27 cp -a ${IMAGE_ROOTFS} ${OSTREE_ROOTFS} 18do_image_ostree[dirs] = "${OSTREE_ROOTFS}"
19do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}"
20do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete"
21IMAGE_CMD_ostree () {
22 cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS}
28 chmod a+rx ${OSTREE_ROOTFS} 23 chmod a+rx ${OSTREE_ROOTFS}
29 sync 24 sync
30 25
31 cd ${OSTREE_ROOTFS}
32
33 for d in var/*; do 26 for d in var/*; do
34 if [ "${d}" != "var/local" ]; then 27 if [ "${d}" != "var/local" ]; then
35 rm -rf ${d} 28 rm -rf ${d}
@@ -132,17 +125,12 @@ IMAGE_CMD_ostree () {
132 125
133 # Copy image manifest 126 # Copy image manifest
134 cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest 127 cat ${IMAGE_MANIFEST} | cut -d " " -f1,3 > usr/package.manifest
128}
135 129
136 cd ${WORKDIR} 130IMAGE_TYPEDEP_ostreecommit = "ostree"
137 131do_image_ostreecommit[depends] += "ostree-native:do_populate_sysroot"
138 # Create a tarball that can be then commited to OSTree repo 132do_image_ostreecommit[lockfiles] += "${WORKDIR}/${OSTREE_REPO}-commit.lock"
139 OSTREE_TAR=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ostree.tar.bz2 133IMAGE_CMD_ostreecommit () {
140 tar -C ${OSTREE_ROOTFS} --xattrs --xattrs-include='*' -cjf ${OSTREE_TAR} .
141 sync
142
143 rm -f ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2
144 ln -s ${IMAGE_NAME}.rootfs.ostree.tar.bz2 ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.rootfs.ostree.tar.bz2
145
146 if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then 134 if ! ostree --repo=${OSTREE_REPO} refs 2>&1 > /dev/null; then
147 ostree --repo=${OSTREE_REPO} init --mode=archive-z2 135 ostree --repo=${OSTREE_REPO} init --mode=archive-z2
148 fi 136 fi
@@ -158,11 +146,9 @@ IMAGE_CMD_ostree () {
158 if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then 146 if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then
159 ostree --repo=${OSTREE_REPO} summary -u 147 ostree --repo=${OSTREE_REPO} summary -u
160 fi 148 fi
161
162 rm -rf ${OSTREE_ROOTFS}
163} 149}
164 150
165IMAGE_TYPEDEP_ostreepush = "ostree" 151IMAGE_TYPEDEP_ostreepush = "ostreecommit"
166do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot" 152do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot"
167IMAGE_CMD_ostreepush () { 153IMAGE_CMD_ostreepush () {
168 # Print warnings if credetials are not set or if the file has not been found. 154 # Print warnings if credetials are not set or if the file has not been found.