Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/warrior/2019.10 #633

Merged
merged 14 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ Build core-image-minimal:
except:
- pushes

Build core-image-minimal (rpi):
extends: .bitbake

stage: test
variables:
TEST_BUILD_DIR: 'build-core-image-minimal-rpi'
BITBAKE_TARGETS: 'core-image-minimal'
TEST_MACHINE: 'raspberrypi3'
except:
- pushes

Oe-selftest qemux86_64:
extends: .oe-selftest

Expand Down
15 changes: 11 additions & 4 deletions classes/image_types_ostree.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ BUILD_OSTREE_TARBALL ??= "1"
SYSTEMD_USED = "${@oe.utils.ifelse(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd', 'true', '')}"

IMAGE_CMD_TAR = "tar --xattrs --xattrs-include=*"
CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}; ${IMAGE_CMD_TAR} --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.tar -C ${OTA_IMAGE_ROOTFS} . || [ $? -eq 1 ]"
CONVERSION_CMD_tar = "touch ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}; ${IMAGE_CMD_TAR} --numeric-owner -cf ${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}.tar -C ${TAR_IMAGE_ROOTFS} . || [ $? -eq 1 ]"
CONVERSIONTYPES_append = " tar"

REQUIRED_DISTRO_FEATURES = "usrmerge"
OTA_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}"
TAR_IMAGE_ROOTFS_task-image-ostree = "${OSTREE_ROOTFS}"
do_image_ostree[dirs] = "${OSTREE_ROOTFS}"
do_image_ostree[cleandirs] = "${OSTREE_ROOTFS}"
do_image_ostree[depends] = "coreutils-native:do_populate_sysroot virtual/kernel:do_deploy ${INITRAMFS_IMAGE}:do_image_complete"
Expand Down Expand Up @@ -186,13 +186,20 @@ IMAGE_CMD_ostreecommit () {
IMAGE_TYPEDEP_ostreepush = "ostreecommit"
do_image_ostreepush[depends] += "aktualizr-native:do_populate_sysroot ca-certificates-native:do_populate_sysroot"
IMAGE_CMD_ostreepush () {
# Print warnings if credetials are not set or if the file has not been found.
# send a copy of the repo manifest to backend if available
local SEND_MANIFEST=""
# check if garage-push supports the --repo-manifest option before trying
if $(garage-push --help | grep -q '^\s*--repo-manifest') && [ -f ${IMAGE_ROOTFS}${sysconfdir}/manifest.xml ]; then
SEND_MANIFEST="--repo-manifest ${IMAGE_ROOTFS}${sysconfdir}/manifest.xml"
fi

if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then
if [ -e ${SOTA_PACKED_CREDENTIALS} ]; then
garage-push -vv --repo=${OSTREE_REPO} \
--ref=${OSTREE_BRANCHNAME} \
--credentials=${SOTA_PACKED_CREDENTIALS} \
--cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt
--cacert=${STAGING_ETCDIR_NATIVE}/ssl/certs/ca-certificates.crt \
$SEND_MANIFEST
else
bbwarn "SOTA_PACKED_CREDENTIALS file does not exist."
fi
Expand Down
2 changes: 1 addition & 1 deletion classes/image_types_ota.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ calculate_size () {
}

OTA_SYSROOT = "${WORKDIR}/ota-sysroot"
OTA_IMAGE_ROOTFS_task-image-ota = "${OTA_SYSROOT}"
TAR_IMAGE_ROOTFS_task-image-ota = "${OTA_SYSROOT}"
IMAGE_TYPEDEP_ota = "ostreecommit"
do_image_ota[dirs] = "${OTA_SYSROOT}"
do_image_ota[cleandirs] = "${OTA_SYSROOT}"
Expand Down
2 changes: 1 addition & 1 deletion conf/distro/poky-sota-systemd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions conf/distro/poky-sota.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 18 additions & 0 deletions conf/local.conf.base.append
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 0 additions & 20 deletions conf/local.conf.sample.append → conf/local.conf.systemd.append
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@

#
# 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
Expand Down
36 changes: 36 additions & 0 deletions lib/oeqa/selftest/cases/updater_qemux86_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,4 +465,40 @@ def test_aktualizr_resource_control(self):
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:
16 changes: 0 additions & 16 deletions lib/oeqa/selftest/cases/updater_raspberrypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,10 @@ def setUpLocal(self):
else:
self.meta_upd_rpi = None

# This is trickier that I would've thought. The fundamental problem is
# that the qemu layer changes the u-boot file extension to .rom, but
# raspberrypi still expects .bin. To prevent this, the qemu layer must
# be temporarily removed if it is present. It has to be removed by name
# without the complete path, but to add it back when we are done, we
# need the full path.
p = re.compile(r'meta-updater-qemux86-64\s*(\S*meta-updater-qemux86-64)\s')
m = p.search(result.output)
if m and m.lastindex > 0:
self.meta_qemu = m.group(1)
runCmd('bitbake-layers remove-layer meta-updater-qemux86-64')
else:
self.meta_qemu = None

self.append_config('MACHINE = "raspberrypi3"')
self.append_config('SOTA_CLIENT_PROV = " aktualizr-shared-prov "')

def tearDownLocal(self):
if self.meta_qemu:
runCmd('bitbake-layers add-layer "%s"' % self.meta_qemu, ignore_status=True)
if self.meta_upd_rpi:
runCmd('bitbake-layers remove-layer "%s"' % self.meta_upd_rpi, ignore_status=True)
if self.meta_rpi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SRC_URI = " \
"
PR = "r1"

RDEPENDS_${PN} = "systemd"
REQUIRED_DISTRO_FEATURES_${PN} = "systemd"
RCONFLICTS_${PN} = "connman"

S = "${WORKDIR}"
Expand Down
9 changes: 4 additions & 5 deletions recipes-sota/aktualizr/aktualizr_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RDEPENDS_${PN}-ptest += "bash cmake curl net-tools python3-core python3-misc pyt
PV = "1.0+git${SRCPV}"
PR = "7"

GARAGE_SIGN_PV = "0.7.0-49-g5ffd420"
GARAGE_SIGN_PV = "0.7.0-59-gf6013d6"

SRC_URI = " \
gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH};name=aktualizr \
Expand All @@ -27,10 +27,10 @@ SRC_URI = " \
${@ d.expand("https://ats-tuf-cli-releases.s3-eu-central-1.amazonaws.com/cli-${GARAGE_SIGN_PV}.tgz;unpack=0;name=garagesign") if d.getVar('GARAGE_SIGN_AUTOVERSION') != '1' else ''} \
"

SRC_URI[garagesign.md5sum] = "de0877ecb693fd48ec11052e51b0ff1a"
SRC_URI[garagesign.sha256sum] = "cf25759574c9c1206835daeaf6fc345f6db7b5ccdb95fb828c86d7451f78f0aa"
SRC_URI[garagesign.md5sum] = "3d38908f9b536a02cc73778b11bbc32e"
SRC_URI[garagesign.sha256sum] = "eceeb16a781e0e8d1f554defbcd5bbcea86d448ebd350fc6a2529372bf867dba"

SRCREV = "fa59e33208d3b1dc690a30ce8339b3b4162f8022"
SRCREV = "662aa23f0b9c97a2c93a428438dacae72333c751"
BRANCH ?= "master"

S = "${WORKDIR}/git"
Expand All @@ -55,7 +55,6 @@ PACKAGECONFIG[warning-as-error] = "-DWARNING_AS_ERROR=ON,-DWARNING_AS_ERROR=OFF,
PACKAGECONFIG[ostree] = "-DBUILD_OSTREE=ON,-DBUILD_OSTREE=OFF,ostree,"
PACKAGECONFIG[hsm] = "-DBUILD_P11=ON,-DBUILD_P11=OFF,libp11,"
PACKAGECONFIG[sota-tools] = "-DBUILD_SOTA_TOOLS=ON ${GARAGE_SIGN_OPS},-DBUILD_SOTA_TOOLS=OFF,glib-2.0,"
PACKAGECONFIG[systemd] = "-DBUILD_SYSTEMD=ON,-DBUILD_SYSTEMD=OFF,systemd,"
PACKAGECONFIG[load-tests] = "-DBUILD_LOAD_TESTS=ON,-DBUILD_LOAD_TESTS=OFF,"
PACKAGECONFIG[serialcan] = ",,,slcand-start"
PACKAGECONFIG[ubootenv] = ",,,u-boot-fw-utils aktualizr-uboot-env-rollback"
Expand Down
21 changes: 21 additions & 0 deletions recipes-sota/ostree/files/touch-ostree
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions recipes-sota/ostree/ostree-booted_1.0.bb
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 15 additions & 3 deletions scripts/envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
SCRIPT="envsetup.sh"
MACHINE="$1"
BUILDDIR="build"
DISTRO="poky-sota-systemd"
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} <machine> [builddir]"; return 1; }
[[ "$#" -eq 2 ]] && { BUILDDIR="$2"; }
[[ "$#" -lt 1 ]] && { echo "Usage: ${SCRIPT} <machine> [builddir] [distro=< poky-sota-systemd | poky-sota >]"; return 1; }
[[ "$#" -ge 2 ]] && { BUILDDIR="$2"; }
[[ "$#" -eq 3 ]] && { DISTRO="$3"; }

# detect if this script is sourced: see http://stackoverflow.com/a/38128348/6255594
SOURCED=0
Expand All @@ -22,6 +26,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"
Expand All @@ -30,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/local.conf.sample.append" >> 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