From 6680bfb70ce2285ef5243e489073fb26bc63f0e7 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Fri, 1 Nov 2019 11:02:30 +0100 Subject: OTA-3988: Non-systemd/poky-sota local.conf Signed-off-by: Mykhaylo Sul --- conf/local.nonsystemd.conf.sample.append | 19 +++++++++++++++++++ scripts/envsetup.sh | 9 +++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 conf/local.nonsystemd.conf.sample.append diff --git a/conf/local.nonsystemd.conf.sample.append b/conf/local.nonsystemd.conf.sample.append new file mode 100644 index 0000000..6aeb61c --- /dev/null +++ b/conf/local.nonsystemd.conf.sample.append @@ -0,0 +1,19 @@ + +# +# meta-updater configuration, see README.adoc and aktualizr's +# documentation for more options and detailed documentation +# + +MACHINE = "##MACHINE##" +DISTRO = "poky-sota" + +# General SOTA setup +#SOTA_CLIENT_PROV = "aktualizr-shared-prov" +#SOTA_PACKED_CREDENTIALS = "/path/to/credentials.zip" + +# Uncomment this line to start an ssh server at boot automatically +#IMAGE_FEATURES += "ssh-server-dropbear" + +# Uncomment this line to set the log level of aktualizr to 'debug' (from 'info' +# by default) +#IMAGE_INSTALL_append += " aktualizr-log-debug" diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 5827bc2..4754e1d 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh @@ -3,9 +3,12 @@ SCRIPT="envsetup.sh" MACHINE="$1" BUILDDIR="build" +DISTRO="poky-sota-systemd" +declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.sample.append" ["poky-sota"]="local.nonsystemd.conf.sample.append" ) -[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} [builddir]"; return 1; } +[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; } [[ "$#" -eq 2 ]] && { BUILDDIR="$2"; } +[[ "$#" -eq 3 ]] && { DISTRO="$3"; } # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 SOURCED=0 @@ -22,6 +25,8 @@ if [[ $SOURCED -ne 1 ]]; then fi METADIR=${METADIR:-${SOURCEDIR}/../..} +DISTRO_CONF=${supported_distros[$DISTRO]} +[[ -n $DISTRO_CONF ]] && { echo "Using $DISTRO_CONF for the specified distro $DISTRO"; } || { echo "The specified distro $DISTRO is not supported"; return 1; } if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" @@ -30,7 +35,7 @@ if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf - sed "s/##MACHINE##/$MACHINE/g" "${METADIR}/meta-updater/conf/local.conf.sample.append" >> conf/local.conf + sed "s/##MACHINE##/$MACHINE/g" "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf else source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" fi -- cgit v1.2.3-54-g00ecf From 4ae9917bf2475c118e8015ec7a2ce10bd01a0124 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Fri, 1 Nov 2019 11:44:44 +0100 Subject: OTA-3988: Don't build the networkd-dhcp recipe if systemd is not included into the disto feature list Signed-off-by: Mykhaylo Sul --- recipes-connectivity/networkd-dhcp-conf/networkd-dhcp-conf.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes-connectivity/networkd-dhcp-conf/networkd-dhcp-conf.bb b/recipes-connectivity/networkd-dhcp-conf/networkd-dhcp-conf.bb index 394531e..40a3958 100644 --- a/recipes-connectivity/networkd-dhcp-conf/networkd-dhcp-conf.bb +++ b/recipes-connectivity/networkd-dhcp-conf/networkd-dhcp-conf.bb @@ -15,7 +15,7 @@ SRC_URI = " \ " PR = "r1" -RDEPENDS_${PN} = "systemd" +REQUIRED_DISTRO_FEATURES_${PN} = "systemd" RCONFLICTS_${PN} = "connman" S = "${WORKDIR}" -- cgit v1.2.3-54-g00ecf From eccef5c18bdcaf4f6c439428d03004c4cd359460 Mon Sep 17 00:00:00 2001 From: Eugene Smirnov Date: Wed, 23 Oct 2019 17:34:19 +0200 Subject: Indicate an OSTree boot on start Signed-off-by: Mykhaylo Sul --- classes/sota.bbclass | 2 +- recipes-sota/ostree/files/touch-ostree | 21 +++++++++++++++++++++ recipes-sota/ostree/ostree-booted_1.0.bb | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 recipes-sota/ostree/files/touch-ostree create mode 100644 recipes-sota/ostree/ostree-booted_1.0.bb diff --git a/classes/sota.bbclass b/classes/sota.bbclass index 5b06397..ecf08ae 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass @@ -21,7 +21,7 @@ python () { d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov-hsm") } -IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" +IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV} ostree-booted" IMAGE_CLASSES += " image_types_ostree image_types_ota" IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'ostreepush garagesign garagecheck ota-ext4 wic', ' ', d)}" diff --git a/recipes-sota/ostree/files/touch-ostree b/recipes-sota/ostree/files/touch-ostree new file mode 100755 index 0000000..28cb672 --- /dev/null +++ b/recipes-sota/ostree/files/touch-ostree @@ -0,0 +1,21 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: touch-ostree +# Required-Start: $network $remote_fs +# Required-Stop: $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Indicate OSTree boot +### END INIT INFO + +case "$1" in + start) + touch /run/ostree-booted + ;; + stop) + ;; + *) + echo "Usage: /etc/init.d/touch-ostree {start|stop}" + exit 1 + ;; +esac diff --git a/recipes-sota/ostree/ostree-booted_1.0.bb b/recipes-sota/ostree/ostree-booted_1.0.bb new file mode 100644 index 0000000..d74cf24 --- /dev/null +++ b/recipes-sota/ostree/ostree-booted_1.0.bb @@ -0,0 +1,15 @@ +SUMMARY = "Indicate an OSTree boot" +DESCRIPTION = "Indicate an OSTree boot" +LICENSE = "MPL-2.0" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad" +SRC_URI = "file://touch-ostree" + +inherit allarch update-rc.d + +INITSCRIPT_NAME = "touch-ostree" +INITSCRIPT_PARAMS = "start 8 2 3 4 5 . stop 20 0 1 6 ." + +do_install() { + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/touch-ostree ${D}${sysconfdir}/init.d/touch-ostree +} -- cgit v1.2.3-54-g00ecf From 40153ba5d77a83e78a9b844a8117b44be8b55df0 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Tue, 5 Nov 2019 09:17:53 +0100 Subject: OTA-3988: force an ostree boot indication only in case of non-systemd distro Signed-off-by: Mykhaylo Sul --- classes/sota.bbclass | 2 +- conf/distro/poky-sota.conf | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/sota.bbclass b/classes/sota.bbclass index ecf08ae..5b06397 100644 --- a/classes/sota.bbclass +++ b/classes/sota.bbclass @@ -21,7 +21,7 @@ python () { d.setVar("SOTA_CLIENT_PROV", "aktualizr-device-prov-hsm") } -IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV} ostree-booted" +IMAGE_INSTALL_append_sota = " ostree os-release ${SOTA_CLIENT} ${SOTA_CLIENT_PROV}" IMAGE_CLASSES += " image_types_ostree image_types_ota" IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'ostreepush garagesign garagecheck ota-ext4 wic', ' ', d)}" diff --git a/conf/distro/poky-sota.conf b/conf/distro/poky-sota.conf index 3fb1d20..bfac90f 100644 --- a/conf/distro/poky-sota.conf +++ b/conf/distro/poky-sota.conf @@ -5,3 +5,5 @@ DISTRO = "poky-sota" DISTRO_NAME = "OTA-enabled Linux" DISTRO_VERSION = "1.0" DISTRO_CODENAME = "sota" + +IMAGE_INSTALL_append_sota = " ostree-booted" -- cgit v1.2.3-54-g00ecf From c8ea7747f26172b9152496c1ab6b1d431eda7988 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Tue, 5 Nov 2019 10:05:27 +0100 Subject: OTA-3988: oe-selftest for the non-systemd case Signed-off-by: Mykhaylo Sul --- lib/oeqa/selftest/cases/updater_qemux86_64.py | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/oeqa/selftest/cases/updater_qemux86_64.py b/lib/oeqa/selftest/cases/updater_qemux86_64.py index 4506300..5f152ad 100644 --- a/lib/oeqa/selftest/cases/updater_qemux86_64.py +++ b/lib/oeqa/selftest/cases/updater_qemux86_64.py @@ -465,4 +465,40 @@ class ResourceControlTests(OESelftestTestCase): stdout, stderr, retcode = self.qemu_command('systemctl --no-pager show --property=ExecMainStatus aktualizr') self.assertIn(b'ExecMainStatus=0', stdout, 'Aktualizr did not restart') + +class NonSystemdTests(OESelftestTestCase): + def setUpLocal(self): + layer = "meta-updater-qemux86-64" + result = runCmd('bitbake-layers show-layers') + if re.search(layer, result.output) is None: + self.meta_qemu = metadir() + layer + runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu) + else: + self.meta_qemu = None + self.append_config('MACHINE = "qemux86-64"') + self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "') + self.append_config('IMAGE_FSTYPES_remove = "ostreepush garagesign garagecheck"') + self.append_config('DISTRO = "poky-sota"') + self.append_config('IMAGE_INSTALL_remove += " aktualizr-resource-control"') + self.qemu, self.s = qemu_launch(machine='qemux86-64') + + def tearDownLocal(self): + qemu_terminate(self.s) + if self.meta_qemu: + runCmd('bitbake-layers remove-layer "%s"' % self.meta_qemu, ignore_status=True) + + def qemu_command(self, command): + return qemu_send_command(self.qemu.ssh_port, command) + + def test_provisioning(self): + print('Checking if systemd is not installed...') + stdout, stderr, retcode = self.qemu_command('systemctl') + self.assertTrue(retcode != 0, 'systemd is installed while it is not supposed to: ' + str(stdout)) + + stdout, stderr, retcode = self.qemu_command('aktualizr --run-mode once') + self.assertEqual(retcode, 0, 'Failed to run aktualizr: ' + str(stdout) + str(stderr)) + + machine = get_bb_var('MACHINE', 'core-image-minimal') + verifyProvisioned(self, machine) + # vim:set ts=4 sw=4 sts=4 expandtab: -- cgit v1.2.3-54-g00ecf From 3f904325ad5d307f308e020e9bc4d24a8afdf7af Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Tue, 5 Nov 2019 17:35:43 +0100 Subject: OTA-3988: make the DISTRO value in poky-sota-systemd.conf aligned to the systemd case Signed-off-by: Mykhaylo Sul --- conf/distro/poky-sota-systemd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/distro/poky-sota-systemd.conf b/conf/distro/poky-sota-systemd.conf index b30b322..0dc50b0 100644 --- a/conf/distro/poky-sota-systemd.conf +++ b/conf/distro/poky-sota-systemd.conf @@ -2,7 +2,7 @@ require conf/distro/poky.conf require conf/distro/sota.conf.inc -DISTRO = "poky-sota" +DISTRO = "poky-sota-systemd" DISTRO_NAME = "OTA-enabled Linux" DISTRO_VERSION = "1.0" DISTRO_CODENAME = "sota" -- cgit v1.2.3-54-g00ecf From c74c4eb5399ed7a195e00172774a283582da6e44 Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Wed, 6 Nov 2019 09:44:03 +0100 Subject: OTA-3988: Split the local.conf to a base and a distro specific part Signed-off-by: Mykhaylo Sul --- conf/local.conf.base.append | 18 ++++++++++++++++ conf/local.conf.sample.append | 35 -------------------------------- conf/local.conf.systemd.append | 15 ++++++++++++++ conf/local.nonsystemd.conf.sample.append | 19 ----------------- scripts/envsetup.sh | 13 +++++++++--- 5 files changed, 43 insertions(+), 57 deletions(-) create mode 100644 conf/local.conf.base.append delete mode 100644 conf/local.conf.sample.append create mode 100644 conf/local.conf.systemd.append delete mode 100644 conf/local.nonsystemd.conf.sample.append diff --git a/conf/local.conf.base.append b/conf/local.conf.base.append new file mode 100644 index 0000000..36b2f59 --- /dev/null +++ b/conf/local.conf.base.append @@ -0,0 +1,18 @@ +# +# meta-updater configuration, see README.adoc and aktualizr's +# documentation for more options and detailed documentation +# + +MACHINE = "##MACHINE##" +DISTRO = "##DISTRO##" + +# General SOTA setup +#SOTA_CLIENT_PROV = "aktualizr-shared-prov" +#SOTA_PACKED_CREDENTIALS = "/path/to/credentials.zip" + +# Uncomment this line to start an ssh server at boot automatically +#IMAGE_FEATURES += "ssh-server-dropbear" + +# Uncomment this line to set the log level of aktualizr to 'debug' (from 'info' +# by default) +#IMAGE_INSTALL_append += " aktualizr-log-debug" diff --git a/conf/local.conf.sample.append b/conf/local.conf.sample.append deleted file mode 100644 index fc565f8..0000000 --- a/conf/local.conf.sample.append +++ /dev/null @@ -1,35 +0,0 @@ - -# -# meta-updater configuration, see README.adoc and aktualizr's -# documentation for more options and detailed documentation -# - -MACHINE = "##MACHINE##" -DISTRO = "poky-sota-systemd" - -# General SOTA setup -#SOTA_CLIENT_PROV = "aktualizr-shared-prov" -#SOTA_PACKED_CREDENTIALS = "/path/to/credentials.zip" - -# Uncomment this line to start an ssh server at boot automatically -#IMAGE_FEATURES += "ssh-server-dropbear" - -# Uncomment this line to set the log level of aktualizr to 'debug' (from 'info' -# by default) -#IMAGE_INSTALL_append += " aktualizr-log-debug" - -# Store systemd logs in persistent storage -# -# It greatly helps diagnosing issues on testing devices but should be -# carefully weighted against file system usage and flash device wear for -# production systems. Please refer to systemd's docs for more details -IMAGE_INSTALL_append += " systemd-journald-persistent" - -# Set resource limits for aktualizr service -# -# Uncomment these lines to change the default parameters. -# -#RESOURCE_CPU_WEIGHT_pn-aktualizr = "100" -#RESOURCE_MEMORY_HIGH_pn-aktualizr = "100M" -#RESOURCE_MEMORY_MAX_pn-aktualizr = "80%" -IMAGE_INSTALL_append += " aktualizr-resource-control" diff --git a/conf/local.conf.systemd.append b/conf/local.conf.systemd.append new file mode 100644 index 0000000..12e0182 --- /dev/null +++ b/conf/local.conf.systemd.append @@ -0,0 +1,15 @@ +# Store systemd logs in persistent storage +# +# It greatly helps diagnosing issues on testing devices but should be +# carefully weighted against file system usage and flash device wear for +# production systems. Please refer to systemd's docs for more details +IMAGE_INSTALL_append += " systemd-journald-persistent" + +# Set resource limits for aktualizr service +# +# Uncomment these lines to change the default parameters. +# +#RESOURCE_CPU_WEIGHT_pn-aktualizr = "100" +#RESOURCE_MEMORY_HIGH_pn-aktualizr = "100M" +#RESOURCE_MEMORY_MAX_pn-aktualizr = "80%" +IMAGE_INSTALL_append += " aktualizr-resource-control" diff --git a/conf/local.nonsystemd.conf.sample.append b/conf/local.nonsystemd.conf.sample.append deleted file mode 100644 index 6aeb61c..0000000 --- a/conf/local.nonsystemd.conf.sample.append +++ /dev/null @@ -1,19 +0,0 @@ - -# -# meta-updater configuration, see README.adoc and aktualizr's -# documentation for more options and detailed documentation -# - -MACHINE = "##MACHINE##" -DISTRO = "poky-sota" - -# General SOTA setup -#SOTA_CLIENT_PROV = "aktualizr-shared-prov" -#SOTA_PACKED_CREDENTIALS = "/path/to/credentials.zip" - -# Uncomment this line to start an ssh server at boot automatically -#IMAGE_FEATURES += "ssh-server-dropbear" - -# Uncomment this line to set the log level of aktualizr to 'debug' (from 'info' -# by default) -#IMAGE_INSTALL_append += " aktualizr-log-debug" diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 4754e1d..19a5c94 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh @@ -4,10 +4,11 @@ SCRIPT="envsetup.sh" MACHINE="$1" BUILDDIR="build" DISTRO="poky-sota-systemd" -declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.sample.append" ["poky-sota"]="local.nonsystemd.conf.sample.append" ) +BASE_CONF="local.conf.base.append" +declare -A supported_distros=( ["poky-sota-systemd"]="local.conf.systemd.append" ["poky-sota"]="local.conf.base.append" ) [[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; } -[[ "$#" -eq 2 ]] && { BUILDDIR="$2"; } +[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; } [[ "$#" -eq 3 ]] && { DISTRO="$3"; } # detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594 @@ -35,7 +36,13 @@ if [[ ! -f "${BUILDDIR}/conf/local.conf" ]]; then cat "${METADIR}/meta-updater/conf/include/bblayers/sota.inc" >> conf/bblayers.conf cat "${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc" >> conf/bblayers.conf - sed "s/##MACHINE##/$MACHINE/g" "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf + sed -e "s/##MACHINE##/$MACHINE/g" \ + -e "s/##DISTRO##/$DISTRO/g" \ + "${METADIR}/meta-updater/conf/$BASE_CONF" >> conf/local.conf + + if [ "$BASE_CONF" != "$DISTRO_CONF" ]; then + cat "${METADIR}/meta-updater/conf/$DISTRO_CONF" >> conf/local.conf + fi else source "$METADIR/poky/oe-init-build-env" "$BUILDDIR" fi -- cgit v1.2.3-54-g00ecf