From 17347988d63bb265be674e36383504c5c684c2b7 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(-) 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 7621621aa3a37f21200adc4c21f1b9118312735e 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 533d338..a3eae24 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -37,9 +37,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 2e3098b33e07b099b6a3cca9b07211e07c7003eb 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a3eae24..7275867 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -19,14 +19,24 @@ CONVERSIONTYPES_append = " tar" REQUIRED_DISTRO_FEATURES = "usrmerge" 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 20c8a0dbda0295d4973559a96b92c2ac5169f213 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 7275867..95035e2 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -70,13 +70,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 237edebe4170db9a22e4d14a65120e8a627bab14 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 95035e2..7cc4baa 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -55,13 +55,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 2ce7fcf6f8866682735d382c51a7500572a321d6 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 7cc4baa..31f8d40 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -140,7 +140,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}) @@ -176,7 +176,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 4e5a1d0299378487602af80bedd29febe9ff9cfb Mon Sep 17 00:00:00 2001 From: Ming Liu Date: Mon, 11 May 2020 13:53:22 +0200 Subject: initramfs-ostree-image: drop qemuboot from IMAGE_CLASSES To avoid generating a qemuboot.conf for qemu machines, it's useless for a initramfs image. Signed-off-by: Ming Liu --- recipes-core/images/initramfs-ostree-image.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes-core/images/initramfs-ostree-image.bb b/recipes-core/images/initramfs-ostree-image.bb index 936c59a..bc21ed3 100644 --- a/recipes-core/images/initramfs-ostree-image.bb +++ b/recipes-core/images/initramfs-ostree-image.bb @@ -13,7 +13,7 @@ IMAGE_LINGUAS = "" LICENSE = "MIT" -IMAGE_CLASSES_remove = "image_repo_manifest" +IMAGE_CLASSES_remove = "image_repo_manifest qemuboot" IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" -- cgit v1.2.3-54-g00ecf From 8d300f28c5e5d69022aee31c24bee36426b45f7d 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 31f8d40..0c076c8 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -167,25 +167,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" @@ -235,7 +229,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} @@ -311,7 +305,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 e12cf4e7ff4a36aced4ce75f1c2b47dd85417cf7 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(-) 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 37ec9b5467da27cabcd14e3cc56343a28eab2b6f Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Thu, 7 May 2020 16:44:49 +0200 Subject: Adding collectd coniguration for aktualizr Signed-off-by: Laurent Bonnans --- recipes-extended/collectd/collectd_%.bbappend | 5 +++++ recipes-sota/aktualizr/aktualizr-collectd.bb | 21 +++++++++++++++++++++ .../aktualizr/files/aktualizr-collectd.conf | 9 +++++++++ 3 files changed, 35 insertions(+) create mode 100644 recipes-extended/collectd/collectd_%.bbappend create mode 100644 recipes-sota/aktualizr/aktualizr-collectd.bb create mode 100644 recipes-sota/aktualizr/files/aktualizr-collectd.conf diff --git a/recipes-extended/collectd/collectd_%.bbappend b/recipes-extended/collectd/collectd_%.bbappend new file mode 100644 index 0000000..fb3e6c4 --- /dev/null +++ b/recipes-extended/collectd/collectd_%.bbappend @@ -0,0 +1,5 @@ +do_install_append() { + printf "\nFilter \"*.conf\"\n\n" >> ${D}/${sysconfdir}/collectd.conf + + install -d ${D}/${sysconfdir}/collectd.conf.d +} diff --git a/recipes-sota/aktualizr/aktualizr-collectd.bb b/recipes-sota/aktualizr/aktualizr-collectd.bb new file mode 100644 index 0000000..c1fc717 --- /dev/null +++ b/recipes-sota/aktualizr/aktualizr-collectd.bb @@ -0,0 +1,21 @@ +SUMMARY = "Aktualizr metric collection" +HOMEPAGE = "https://github.com/advancedtelematic/aktualizr" +SECTION = "base" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" + +RDEPENDS_${PN} = "collectd" + +SRC_URI = " file://aktualizr-collectd.conf" + +S = "${WORKDIR}" + +do_install() { + install -d ${D}${sysconfdir}/collectd.conf.d + install -m 0644 ${WORKDIR}/aktualizr-collectd.conf ${D}${sysconfdir}/collectd.conf.d/aktualizr.conf +} + +FILES_${PN} = " \ + ${sysconfdir}/collectd.conf.d \ + ${sysconfdir}/collectd.conf.d/aktualizr.conf \ + " diff --git a/recipes-sota/aktualizr/files/aktualizr-collectd.conf b/recipes-sota/aktualizr/files/aktualizr-collectd.conf new file mode 100644 index 0000000..35a1f61 --- /dev/null +++ b/recipes-sota/aktualizr/files/aktualizr-collectd.conf @@ -0,0 +1,9 @@ + + Interval 1 + + + CollectFileDescriptor true + CollectContextSwitch true + CollectMemoryMaps true + Process "aktualizr" + -- cgit v1.2.3-54-g00ecf From b11a2f689c1babe916352e7cff9179343f1bccff 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index 0c076c8..a569381 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -173,7 +173,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 4a25703ec8908e832e1df36255b003dd5c70f591 Mon Sep 17 00:00:00 2001 From: Laurent Bonnans Date: Fri, 29 May 2020 11:30:53 +0200 Subject: Bump aktualizr to 2020.7 revision And garage-sign to 0.7.1-4 Signed-off-by: Laurent Bonnans --- recipes-sota/aktualizr/aktualizr_git.bb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index c0d5b10..56a6389 100644 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb @@ -17,7 +17,7 @@ PRIVATE_LIBS_${PN}-ptest = "libaktualizr.so libaktualizr_secondary.so" PV = "1.0+git${SRCPV}" PR = "7" -GARAGE_SIGN_PV = "0.7.1" +GARAGE_SIGN_PV = "0.7.1-4-gf10c1da" SRC_URI = " \ gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH};name=aktualizr \ @@ -29,10 +29,10 @@ SRC_URI = " \ ${@ 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" -SRC_URI[garagesign.sha256sum] = "a87c3f39d61492d6f813754159ed7ef1e59966c15726edef4cd188a63cde60d6" +SRC_URI[garagesign.md5sum] = "5f8eea81d1559d6fcb28d49c4298727c" +SRC_URI[garagesign.sha256sum] = "8b2f5bb164f19b41972069d3377e39c2eb9edffd471777161691039e12a71738" -SRCREV = "a6392dec3fb9dda3cb8ab8aa10a81b2c0494cb3c" +SRCREV = "cf44da79555d1897115eb350cbc43db1e213db03" BRANCH ?= "master" S = "${WORKDIR}/git" -- cgit v1.2.3-54-g00ecf From 9dcbb6e9afe3a328ec76aa98ffe64445edf35655 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(-) diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index a569381..8d68b5a 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -195,7 +195,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