From 96794bde2e2e0ce93583de80b9ad7e9b8bd87a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Thu, 30 May 2024 16:07:12 +0100 Subject: [PATCH 1/4] factory: do not mount /lib/{modules,firmware} if there is a drivers tree Do not mount /lib/{modules,firmware} in case snapd created a drivers tree for our kernel snap, as in that case these mounts will be created by snapd-generator from the base or from the snapd deb package for hybrid systems. This situation is expected to happen only for 24+ systems. --- factory/usr/lib/core/extra-paths | 15 ++++++++++++++- .../system-generators/kernel-snap-generator | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/factory/usr/lib/core/extra-paths b/factory/usr/lib/core/extra-paths index 70b2877a..b0db3d55 100755 --- a/factory/usr/lib/core/extra-paths +++ b/factory/usr/lib/core/extra-paths @@ -2,8 +2,21 @@ set -eu -cat <>/sysroot/etc/fstab +cat <<'EOF' >>/sysroot/etc/fstab /run/mnt/data /writable none bind,x-initrd.mount 0 0 +EOF + +# Find out kernel name / revision +kernelPath=$(cat /sys/dev/block/"$(mountpoint --fs-devno /run/mnt/kernel)"/loop/backing_file) +kernelFile=$(basename "$kernelPath") +kernelName=${kernelFile%%_*} +rev=${kernelFile#*_} +rev=${rev%%.*} + +# Mount /lib/{firmware,modules} only if there is no drivers tree created by snapd +if [ ! -d /run/mnt/data/system-data/var/lib/snapd/kernel/"$kernelName"/"$rev" ]; then + cat <<'EOF' >>/sysroot/etc/fstab /run/mnt/kernel/firmware /usr/lib/firmware none bind,x-initrd.mount 0 0 /run/mnt/kernel/modules /usr/lib/modules none bind,x-initrd.mount 0 0 EOF +fi diff --git a/factory/usr/lib/systemd/system-generators/kernel-snap-generator b/factory/usr/lib/systemd/system-generators/kernel-snap-generator index e9b8dcf4..dbad82c6 100755 --- a/factory/usr/lib/systemd/system-generators/kernel-snap-generator +++ b/factory/usr/lib/systemd/system-generators/kernel-snap-generator @@ -35,6 +35,18 @@ if ! grep -q "^ID=ubuntu$" "${OS_RELEASE}"; then exit 0 fi +# Find out kernel name / revision +kernelPath=$(cat /sys/dev/block/"$(mountpoint --fs-devno "$KERNEL_MNT_POINT")"/loop/backing_file) +kernelFile=$(basename "$kernelPath") +kernelName=${kernelFile%%_*} +rev=${kernelFile#*_} +rev=${rev%%.*} + +# Mount /lib/{firmware,modules} only if there is no drivers tree created by snapd +if [ -d /run/mnt/data/var/lib/snapd/kernel/"$kernelName"/"$rev" ]; then + exit 0 +fi + for entry in firmware modules; do what="${KERNEL_MNT_POINT}/${entry}" where="${sysroot}/usr/lib/${entry}" From 19f83e478c45981cebe4c3dacef57be0626ac207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Wed, 12 Jun 2024 11:40:29 -0400 Subject: [PATCH 2/4] tests: enable serial output when repacking gadget --- tests/lib/prepare-utils.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib/prepare-utils.sh b/tests/lib/prepare-utils.sh index 46e2a3dd..6dfe477b 100644 --- a/tests/lib/prepare-utils.sh +++ b/tests/lib/prepare-utils.sh @@ -236,6 +236,11 @@ repack_and_sign_gadget() { create_cloud_init_cdimage_config "${gadget_dir}/cloud.conf" fi + # Show output in serial + cat > "${gadget_dir}/cmdline.extra" << 'EOF' +console=ttyS0 systemd.journald.forward_to_console=1 rd.systemd.journald.forward_to_console=1 +EOF + sbattach --remove "$gadget_dir/shim.efi.signed" sbsign --key "$snakeoil_dir/PkKek-1-snakeoil.key" --cert "$snakeoil_dir/PkKek-1-snakeoil.pem" --output "$gadget_dir/shim.efi.signed" "$gadget_dir/shim.efi.signed" From 7273f210e7b3f494af15584c7d3b97fe8afacd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Wed, 12 Jun 2024 15:13:50 -0400 Subject: [PATCH 3/4] tests/build: use channel 24 for the kernel now --- tests/spread/build/build-initrd/task.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spread/build/build-initrd/task.yaml b/tests/spread/build/build-initrd/task.yaml index 78a33833..5b8b8cfd 100644 --- a/tests/spread/build/build-initrd/task.yaml +++ b/tests/spread/build/build-initrd/task.yaml @@ -13,7 +13,7 @@ prepare: | # download pc-kernel and pc gadget # FIXME: switch to 24 channel when available - snap download pc-kernel --channel=22/${SNAP_BRANCH} --basename=upstream-pc-kernel + snap download pc-kernel --channel=24/${SNAP_BRANCH} --basename=upstream-pc-kernel snap download pc --channel=24/${SNAP_BRANCH} --basename=upstream-pc-gadget execute: | From c6217257cacbd252746a6fc16f917d19e227136e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= Date: Wed, 12 Jun 2024 15:14:19 -0400 Subject: [PATCH 4/4] .github: fix typo --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 40a011e5..f5e19249 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -99,7 +99,7 @@ jobs: echo "************* DOWNLOADING SNAPS *************" download_core_initrd_snaps 'edge' - echo "************* PREPAREING CORE24 IMAGE *************" + echo "************* PREPARING CORE24 IMAGE *************" rm -f "upstream-pc-kernel.snap" "upstream-pc-gadget.snap" mv "pc-kernel.artifact" "upstream-pc-kernel.snap" mv "pc-gadget.artifact" "upstream-pc-gadget.snap"