From 534a0ccfc3e37801b4a51cc518c7cf5c5553b6c2 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sun, 26 Apr 2020 13:42:54 +0000 Subject: image_types_ota: export OSTREE_BOOT_PARTITION when needed The environment variable OSTREE_BOOT_PARTITION is only used when using GRUB. Move the export into the if statement. Also add a comment why manually adding /boot/loader{.0} directory is necessary. Signed-off-by: Stefan Agner --- classes/image_types_ota.bbclass | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 2cc8913..e9f9467 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -45,14 +45,17 @@ do_image_ota[cleandirs] = "${OTA_SYSROOT}" do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER') == 'grub' else ''} \ ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER') == 'u-boot' else ''}" IMAGE_CMD_ota () { - export OSTREE_BOOT_PARTITION=${OSTREE_BOOT_PARTITION} - ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} + + # Preparation required to steer ostree bootloader detection mkdir -p ${OTA_SYSROOT}/boot/loader.0 ln -s loader.0 ${OTA_SYSROOT}/boot/loader if [ "${OSTREE_BOOTLOADER}" = "grub" ]; then + # Used by ostree-grub-generator called by the ostree binary + export OSTREE_BOOT_PARTITION=${OSTREE_BOOT_PARTITION} + mkdir -p ${OTA_SYSROOT}/boot/grub2 ln -s ../loader/grub.cfg ${OTA_SYSROOT}/boot/grub2/grub.cfg elif [ "${OSTREE_BOOTLOADER}" = "u-boot" ]; then -- cgit v1.2.3-54-g00ecf From 8b25f99f49f345b55720f1dc583bd981902191b6 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sun, 26 Apr 2020 14:55:29 +0000 Subject: image_types_ostree: drop unnecessary tmp handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code clears tmp and then creates a symlink inside it to /sysroot/tmp: tmp └── tmp -> sysroot/tmp This is likely a mistake and the root tmp should have pointed to sysroot/tmp. However, since /tmp is mounted as a tmpfs anyways, we can get rid of all this logic. Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 3 --- 1 file changed, 3 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index ce9f984..d29d4c4 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -38,9 +38,6 @@ IMAGE_CMD_ostree () { mkdir sysroot ln -sf sysroot/ostree ostree - rm -rf tmp/* - ln -sf sysroot/tmp tmp - mkdir -p usr/rootdirs mv etc usr/ -- cgit v1.2.3-54-g00ecf From 07a849345ddf3546ce93220d64833bf0e011a1f1 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sat, 25 Apr 2020 22:15:39 +0000 Subject: image_types_ostree: use hardlink tree Instead of copying the files to be commited to the ostree just use a hardlink tree. This improves performance and wasts less diskspace. When using this method the root directory has already the correct permission bits set. Also get rid of the unnecessary sync. This halfs the execution time of the do_image_ostree tasks in my measurments. Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index d29d4c4..758ce00 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}.${ CONVERSIONTYPES_append = " tar" TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}" + +python prepare_ostree_rootfs() { + import oe.path + import shutil + + ostree_rootfs = d.getVar("OSTREE_ROOTFS") + if os.path.lexists(ostree_rootfs): + bb.utils.remove(ostree_rootfs, True) + + # Copy required as we change permissions on some files. + image_rootfs = d.getVar("IMAGE_ROOTFS") + oe.path.copyhardlinktree(image_rootfs, ostree_rootfs) +} + do_image_ostree[dirs] = "${OSTREE_ROOTFS}" -do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}" +do_image_ostree[prefuncs] += "prepare_ostree_rootfs" do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete" IMAGE_CMD_ostree () { - cp -a ${IMAGE_ROOTFS}/* ${OSTREE_ROOTFS} - chmod a+rx ${OSTREE_ROOTFS} - sync - for d in var/*; do if [ "${d}" != "var/local" ]; then rm -rf ${d} -- cgit v1.2.3-54-g00ecf From 142f898125804679baf07e3d19ddebd8cc3250b0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sat, 25 Apr 2020 22:22:37 +0000 Subject: image_types_ostree/ota: do not commit homes to the OSTree The home directory currently are commited to the OSTree, presumably to then use it for the deployment. However, we do have access to the original rootfs in the OSTree deployment tasks (do_image_ota) hence transferring the files "via OSTree" is not necessary. We do already carry over some files from the original OE rootfs to /var/sota. Follow this approach for /var/local and /home as well. The home will still be stored in the sysroot as documented in https://ostree.readthedocs.io/en/latest/manual/adapting-existing/. Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 12 +++++------- classes/image_types_ota.bbclass | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 758ce00..28d9802 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -71,13 +71,11 @@ IMAGE_CMD_ostree () { mkdir -p usr/share/sota/ echo -n "${OSTREE_BRANCHNAME}" > usr/share/sota/branchname - # Preserve data in /home to be later copied to /sysroot/home by sysroot - # generating procedure - mkdir -p usr/homedirs - if [ -d "home" ] && [ ! -L "home" ]; then - mv home usr/homedirs/home - ln -sf var/rootdirs/home home - fi + # home directories get copied from the OE root later to the final sysroot + # Create a symlink to var/rootdirs/home to make sure the OSTree deployment + # redirects /home to /var/rootdirs/home. + rm -rf home/ + ln -sf var/rootdirs/home home # Move persistent directories to /var dirs="opt mnt media srv" diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index e9f9467..8f5a01a 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -80,8 +80,8 @@ IMAGE_CMD_ota () { # Ensure the permissions are correctly set chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota - cp -a ${OSTREE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true - cp -a ${OSTREE_ROOTFS}/usr/homedirs/home ${OTA_SYSROOT}/ || true + cp -a ${IMAGE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true + cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ || true # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local # Set package version for the first deployment -- cgit v1.2.3-54-g00ecf From 218ed67356e1a5389392ef75fe0c8764d9228807 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Sat, 25 Apr 2020 23:36:46 +0000 Subject: image_types_ostree/ota: move home physically to /var/rootdirs/home Instead of using the double indirection mode /home -> /var/rootdirs/home -> /sysroot/home move the home directory physically into /var/rootdirs. This allows to use the --modern flag when initializing the file system. The "old" style is still supported, and does make sense in case the home directories need to be shared between multiple deployments. Since multiple deployments is not a use case in meta-updater use the /var approach. See also: https://github.com/ostreedev/ostree/issues/2085. The modern flag also gets rid of dev, proc, root, run, sys and tmp. All of them have been empty and unused. Note: This change cannot be pushed through updates as this is an initial deployment setting. Only devices provisioned with images built with this change applied will use the new layout. Updates will continue to work on both systems as the symlink from the deployment stays the same (first indirection is still /home -> /var/rootdirs/home). Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 2 -- classes/image_types_ota.bbclass | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 28d9802..a8a6c39 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -56,13 +56,11 @@ IMAGE_CMD_ostree () { mkdir -p usr/etc/tmpfiles.d tmpfiles_conf=usr/etc/tmpfiles.d/00ostree-tmpfiles.conf echo "d /var/rootdirs 0755 root root -" >>${tmpfiles_conf} - echo "L /var/rootdirs/home - - - - /sysroot/home" >>${tmpfiles_conf} else mkdir -p usr/etc/init.d tmpfiles_conf=usr/etc/init.d/tmpfiles.sh echo '#!/bin/sh' > ${tmpfiles_conf} echo "mkdir -p /var/rootdirs; chmod 755 /var/rootdirs" >> ${tmpfiles_conf} - echo "ln -sf /sysroot/home /var/rootdirs/home" >> ${tmpfiles_conf} ln -s ../init.d/tmpfiles.sh usr/etc/rcS.d/S20tmpfiles.sh fi diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 8f5a01a..374ddc2 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -45,7 +45,7 @@ do_image_ota[cleandirs] = "${OTA_SYSROOT}" do_image_ota[depends] = "${@'grub:do_populate_sysroot' if d.getVar('OSTREE_BOOTLOADER') == 'grub' else ''} \ ${@'virtual/bootloader:do_deploy' if d.getVar('OSTREE_BOOTLOADER') == 'u-boot' else ''}" IMAGE_CMD_ota () { - ostree admin --sysroot=${OTA_SYSROOT} init-fs ${OTA_SYSROOT} + ostree admin --sysroot=${OTA_SYSROOT} init-fs --modern ${OTA_SYSROOT} ostree admin --sysroot=${OTA_SYSROOT} os-init ${OSTREE_OSNAME} # Preparation required to steer ostree bootloader detection @@ -81,7 +81,10 @@ IMAGE_CMD_ota () { chmod 700 ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/sota cp -a ${IMAGE_ROOTFS}/var/local ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true - cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ || true + + mkdir -p ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs + cp -a ${IMAGE_ROOTFS}/home ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/rootdirs/home || true + # Ensure that /var/local exists (AGL symlinks /usr/local to /var/local) install -d ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/local # Set package version for the first deployment -- cgit v1.2.3-54-g00ecf From ffd68bd40cfdd66d74787acb03b1de801b1a122c Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Mon, 11 May 2020 19:49:31 +0200 Subject: sota_sanity.bbclass: introduce sota_check_boolean_variable The current sanity check are too strict for some boolean variables, introduce sota_check_boolean_variable to allow a boolean value to be set like yes/y/true/t/1 or no/n/false/f/0. Also change to use oe.types.boolean to check their values. Signed-off-by: Ming Liu --- classes/image_types_ostree.bbclass | 4 ++-- classes/sota_sanity.bbclass | 23 +++++++++++++++-------- recipes-sota/aktualizr/aktualizr-shared-prov.bb | 2 +- recipes-sota/aktualizr/aktualizr_git.bb | 4 ++-- 4 files changed, 20 insertions(+), 13 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a8a6c39..0614dd3 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -141,7 +141,7 @@ IMAGE_CMD_ostree () { checksum=$(sha256sum ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} | cut -f 1 -d " ") touch boot/initramfs-${checksum} else - if [ "${OSTREE_DEPLOY_DEVICETREE}" = "1" ] && [ -n "${KERNEL_DEVICETREE}" ]; then + if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ] && [ -n "${KERNEL_DEVICETREE}" ]; then checksum=$(cat ${DEPLOY_DIR_IMAGE}/${OSTREE_KERNEL} ${DEPLOY_DIR_IMAGE}/${INITRAMFS_IMAGE}-${MACHINE}.${INITRAMFS_FSTYPES} ${KERNEL_DEVICETREE} | sha256sum | cut -f 1 -d " ") for DTS_FILE in ${KERNEL_DEVICETREE}; do DTS_FILE_BASENAME=$(basename ${DTS_FILE}) @@ -177,7 +177,7 @@ IMAGE_CMD_ostreecommit () { --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" - if [ "${OSTREE_UPDATE_SUMMARY}" = "1" ]; then + if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then ostree --repo=${OSTREE_REPO} summary -u fi diff --git a/classes/sota_sanity.bbclass b/classes/sota_sanity.bbclass index 74973eb..02ca2e7 100644 --- a/classes/sota_sanity.bbclass +++ b/classes/sota_sanity.bbclass @@ -1,5 +1,12 @@ # Sanity check the sota setup for common misconfigurations +def sota_check_boolean_variable(var, d): + try: + oe.types.boolean(d.getVar(var)) + except: + return False + return True + def sota_check_overrides(status, d): for var in (d.getVar('SOTA_OVERRIDES_BLACKLIST') or "").split(): if var in d.getVar('OVERRIDES').split(':'): @@ -47,14 +54,14 @@ def sota_check_variables_validity(status, d): path = os.path.abspath(credentials) if not os.path.exists(path): status.addresult("SOTA_PACKED_CREDENTIALS is not set correctly. The zipped credentials file does not exist.\n") - if d.getVar("OSTREE_UPDATE_SUMMARY") and d.getVar("OSTREE_UPDATE_SUMMARY") not in ("0", "1", ""): - status.addresult("OSTREE_UPDATE_SUMMARY should be set to 0 or 1.\n") - if d.getVar("OSTREE_DEPLOY_DEVICETREE") and d.getVar("OSTREE_DEPLOY_DEVICETREE") not in ("0", "1", ""): - status.addresult("OSTREE_DEPLOY_DEVICETREE should be set to 0 or 1.\n") - if d.getVar("GARAGE_SIGN_AUTOVERSION") and d.getVar("GARAGE_SIGN_AUTOVERSION") not in ("0", "1", ""): - status.addresult("GARAGE_SIGN_AUTOVERSION should be set to 0 or 1.\n") - if d.getVar("SOTA_DEPLOY_CREDENTIALS") and d.getVar("SOTA_DEPLOY_CREDENTIALS") not in ("0", "1", ""): - status.addresult("SOTA_DEPLOY_CREDENTIALS should be set to 0 or 1.\n") + if not sota_check_boolean_variable("OSTREE_UPDATE_SUMMARY", d): + status.addresult("OSTREE_UPDATE_SUMMARY (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_UPDATE_SUMMARY")) + if not sota_check_boolean_variable("OSTREE_DEPLOY_DEVICETREE", d): + status.addresult("OSTREE_DEPLOY_DEVICETREE (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("OSTREE_DEPLOY_DEVICETREE")) + if not sota_check_boolean_variable("GARAGE_SIGN_AUTOVERSION", d): + status.addresult("GARAGE_SIGN_AUTOVERSION (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("GARAGE_SIGN_AUTOVERSION")) + if not sota_check_boolean_variable("SOTA_DEPLOY_CREDENTIALS", d): + status.addresult("SOTA_DEPLOY_CREDENTIALS (=%s) should be set to yes/y/true/t/1 or no/n/false/f/0.\n" % d.getVar("SOTA_DEPLOY_CREDENTIALS")) def sota_raise_sanity_error(msg, d): if d.getVar("SANITY_USE_EVENTS") == "1": diff --git a/recipes-sota/aktualizr/aktualizr-shared-prov.bb b/recipes-sota/aktualizr/aktualizr-shared-prov.bb index 2ee47a1..0f712df 100644 --- a/recipes-sota/aktualizr/aktualizr-shared-prov.bb +++ b/recipes-sota/aktualizr/aktualizr-shared-prov.bb @@ -10,7 +10,7 @@ inherit allarch # We need to get the config files from the aktualizr-host-tools package built by # the aktualizr (target) recipe. DEPENDS = "aktualizr" -RDEPENDS_${PN}_append = "${@' aktualizr-shared-prov-creds' if d.getVar('SOTA_DEPLOY_CREDENTIALS') == '1' else ''}" +RDEPENDS_${PN}_append = "${@' aktualizr-shared-prov-creds' if oe.types.boolean(d.getVar('SOTA_DEPLOY_CREDENTIALS')) else ''}" # If the config file from aktualizr used here is changed, you will need to bump # the version here because of SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS! diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index a46eab0..c0d5b10 100644 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb @@ -26,7 +26,7 @@ SRC_URI = " \ file://aktualizr-secondary.service \ file://aktualizr-serialcan.service \ file://10-resource-control.conf \ - ${@ d.expand("https://tuf-cli-releases.ota.here.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0;name=garagesign") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \ + ${@ d.expand("https://tuf-cli-releases.ota.here.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0;name=garagesign") if not oe.types.boolean(d.getVar('GARAGE_SIGN_AUTOVERSION')) else ''} \ " SRC_URI[garagesign.md5sum] = "febc186527b324b23c5be3affcf90e54" @@ -49,7 +49,7 @@ SYSTEMD_SERVICE_${PN}-secondary = "aktualizr-secondary.service" EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release ${@bb.utils.contains('PTEST_ENABLED', '1', '-DTESTSUITE_VALGRIND=on', '', d)}" -GARAGE_SIGN_OPS = "${@ d.expand('-DGARAGE_SIGN_ARCHIVE=${WORKDIR}/cli-${GARAGE_SIGN_PV}.tgz') if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''}" +GARAGE_SIGN_OPS = "${@ d.expand('-DGARAGE_SIGN_ARCHIVE=${WORKDIR}/cli-${GARAGE_SIGN_PV}.tgz') if not oe.types.boolean(d.getVar('GARAGE_SIGN_AUTOVERSION')) else ''}" PKCS11_ENGINE_PATH = "${libdir}/engines-1.1/pkcs11.so" PACKAGECONFIG ?= "ostree ${@bb.utils.filter('SOTA_CLIENT_FEATURES', 'hsm serialcan ubootenv', d)}" -- cgit v1.2.3-54-g00ecf From cca888367cd3aeaff44ff12f129bbbfa68cb64e7 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 28 Apr 2020 16:28:14 +0000 Subject: image_types_ostree/ota: use hash from ostree commit Relying on a OSTree branch reference has been problematic in the past and addressed by adding more attributes to it in commit 202a8c70ba8c ("image_types_ostree: Add a unique ref to fix simultaneous bitbaking."). However, depening on what kind of OpenEmbedded builds are running in parallel, even more attributes would need to be taken into account. Instead of relying on a reference, store the exact ostree commit hash in a manifest file and reuse it in the do_image_ota deploy task. This guarantees that the correct reference gets picked even when two builds with the exact same machine/image name run in parallel. Note: This gets rid of the second branch name again. If the branch name with image name is preferred, the variable OSTREE_BRANCHNAME can be used: OSTREE_BRANCHNAME = "${SOTA_HARDWARE_ID}-${IMAGE_BASENAME}" Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 18 ++++++------------ classes/image_types_ota.bbclass | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 0614dd3..ab11da9 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -168,25 +168,19 @@ IMAGE_CMD_ostreecommit () { fi # Commit the result - ostree --repo=${OSTREE_REPO} commit \ + ostree_target_hash=$(ostree --repo=${OSTREE_REPO} commit \ --tree=dir=${OSTREE_ROOTFS} \ --skip-if-unchanged \ --branch=${OSTREE_BRANCHNAME} \ --subject="${OSTREE_COMMIT_SUBJECT}" \ --body="${OSTREE_COMMIT_BODY}" \ - --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ - --bind-ref="${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}" + --add-metadata-string=version="${OSTREE_COMMIT_VERSION}") + + echo $ostree_target_hash > ${WORKDIR}/ostree_manifest if [ ${@ oe.types.boolean('${OSTREE_UPDATE_SUMMARY}')} = True ]; then ostree --repo=${OSTREE_REPO} summary -u fi - - # To enable simultaneous bitbaking of two images with the same branch name, - # create a new ref in the repo using the basename of the image. (This first - # requires deleting it if it already exists.) Fixes OTA-2211. - ostree --repo=${OSTREE_REPO} refs --delete ${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) - ostree --repo=${OSTREE_REPO} refs --create=${OSTREE_BRANCHNAME}-${IMAGE_BASENAME} ${ostree_target_hash} } IMAGE_TYPEDEP_ostreepush = "ostreecommit" @@ -236,7 +230,7 @@ IMAGE_CMD_garagesign () { --home-dir ${GARAGE_SIGN_REPO} \ --credentials ${SOTA_PACKED_CREDENTIALS} - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) + ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) # Use OSTree target hash as version if none was provided by the user target_version=${ostree_target_hash} @@ -312,7 +306,7 @@ IMAGE_CMD_garagecheck () { # if credentials are issued by a server that doesn't support offline signing, exit silently unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) + ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) garage-check --ref=${ostree_target_hash} \ --credentials=${SOTA_PACKED_CREDENTIALS} \ diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 374ddc2..56c7794 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -64,7 +64,7 @@ IMAGE_CMD_ota () { bbfatal "Invalid bootloader: ${OSTREE_BOOTLOADER}" fi - ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}-${IMAGE_BASENAME}) + ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} kargs_list="" -- cgit v1.2.3-54-g00ecf From 532c19a81277f099d139d96031ae3bf2a2eeb939 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 28 Apr 2020 18:54:39 +0000 Subject: image_types_ota: use named reference Use named reference when deploying the device tree. This makes sure that this reference will end up in the deployments .origin file, which will be visible by the user in ostree admin status. This reference will also be used when running ostree admin upgrade. This is not really required when using aktualizr, but can be useful during test/debugging when using pure OSTree updates. Make sure to make ${OSTREE_REPO} accessible via http and add a remote on the device called ${OSTREE_OSNAME} pointing to the http exposed archive OSTree. With that ostree admin upgrade should work. Note: We could use the name reference in ostree pull-local already, but this is potentially racy if multiple builds are committing to the same branch. Use the OSTree commit hash to get the actual commit and recreate a local reference to this commit. This makes absolutely sure that we use the same OSTree commit this bitbake execution committed during the do_image_ostreecommit task. Signed-off-by: Stefan Agner --- classes/image_types_ota.bbclass | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 56c7794..a8a19b5 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -66,13 +66,23 @@ IMAGE_CMD_ota () { ostree_target_hash=$(cat ${WORKDIR}/ostree_manifest) + # Use OSTree hash to avoid any potential race conditions between + # multiple builds accessing the same ${OSTREE_REPO}. ostree --repo=${OTA_SYSROOT}/ostree/repo pull-local --remote=${OSTREE_OSNAME} ${OSTREE_REPO} ${ostree_target_hash} kargs_list="" for arg in ${OSTREE_KERNEL_ARGS}; do kargs_list="${kargs_list} --karg-append=$arg" done - ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${ostree_target_hash} + # Create the same reference on the device we use in the archive OSTree + # repo in ${OSTREE_REPO}. This reference will show up when showing the + # deployment on the device: + # ostree admin status + # If a remote with the name ${OSTREE_OSNAME} is configured, this also + # will allow to use: + # ostree admin upgrade + ostree --repo=${OTA_SYSROOT}/ostree/repo refs --create=${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} ${ostree_target_hash} + ostree admin --sysroot=${OTA_SYSROOT} deploy ${kargs_list} --os=${OSTREE_OSNAME} ${OSTREE_OSNAME}:${OSTREE_BRANCHNAME} cp -a ${IMAGE_ROOTFS}/var/sota ${OTA_SYSROOT}/ostree/deploy/${OSTREE_OSNAME}/var/ || true # Create /var/sota if it doesn't exist yet -- cgit v1.2.3-54-g00ecf From 217fdc817794510e71e6d5bddf47b2d7a426401d Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 26 May 2020 16:04:24 +0000 Subject: image_types_ostree: allow to add layer specific OSTree commit arguments The OSTree commit command allows to add metadata to the commit. This might be customized in a distro layer for distribution specific needs. Allow to pass extra arguments using EXTRA_OSTREE_COMMIT variable (using a variable named similar to EXTRA_OEMAKE used to pass extra make arguments). Signed-off-by: Stefan Agner --- classes/image_types_ostree.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index ab11da9..bab4ed7 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -174,7 +174,8 @@ IMAGE_CMD_ostreecommit () { --branch=${OSTREE_BRANCHNAME} \ --subject="${OSTREE_COMMIT_SUBJECT}" \ --body="${OSTREE_COMMIT_BODY}" \ - --add-metadata-string=version="${OSTREE_COMMIT_VERSION}") + --add-metadata-string=version="${OSTREE_COMMIT_VERSION}" \ + ${EXTRA_OSTREE_COMMIT}) echo $ostree_target_hash > ${WORKDIR}/ostree_manifest -- cgit v1.2.3-54-g00ecf From 99907dd06234a9e703882929c10827558bc5ed99 Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Fri, 29 May 2020 13:51:36 +0200 Subject: Update garage-push invocation for new cli Signed-off-by: Laurent Bonnans --- classes/image_types_ostree.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index bab4ed7..fd38d28 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -196,7 +196,7 @@ IMAGE_CMD_ostreepush () { if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then - garage-push -vv --repo=${OSTREE_REPO} \ + garage-push --loglevel 0 --repo=${OSTREE_REPO} \ --ref=${OSTREE_BRANCHNAME} \ --credentials=${SOTA_PACKED_CREDENTIALS} \ --cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \ -- cgit v1.2.3-54-g00ecf