From 1841b99deec9aee37156726c1a895776b0ccf96a 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/image_types_ota.bbclass b/classes/image_types_ota.bbclass index 857161a..e9f9467 100644 --- a/classes/image_types_ota.bbclass +++ b/classes/image_types_ota.bbclass @@ -45,13 +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 52276a4ee4f2e8cd63a186ed8775c8d2f2b18216 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 50835b85ab5fa5fa7b2c340a35f829766c6d0be9 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 a9a04e7d1d4b0b05a10a9f92bf980235a2a5bf38 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 919ce317bd42659048154c25a13716f6fc9e0d2c 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 95035e2..4b27f34 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -142,7 +142,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}) @@ -178,7 +178,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 a20d46b..667765a 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 c5e1b209c3d2ab9a54553520a6ad4cec09e6184f 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 16e01f337d04cedce7a47e0f024379d2bbdfce3d 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 4b27f34..3e67043 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -169,25 +169,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" @@ -237,7 +231,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} @@ -313,7 +307,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 8f5a01a..17be0ee 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 b4ea02c0e1ebafa4d57d4104118b3b4886e3d0fe 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 17be0ee..ad067da 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 79ca75e8415d1fe65ae5af124d99f7747a8bc9d9 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 49234059ba1af24619d77e20eb0fcf238455bacf 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 3e67043..0bc40f8 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -175,7 +175,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 255408e639959a65cb2aab5ef166201afa7ee022 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 667765a..7a77759 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 c2306aa74b4ed8997e82b079b35b32ab1250aee8 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 0bc40f8..3b86b35 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass @@ -197,7 +197,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