diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6684abf9..01340ee4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,8 +11,29 @@ on: - main jobs: + build-snapd-deb: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + repository: 'valentindavid/snapd' + path: snapd + ref: 'valentindavid/split-snap-bootstrap' + - name: Build snapd deb + working-directory: '${{ github.workspace }}/snapd' + run: | + sudo apt update + sudo DEBIAN_FRONTEND=noninteractive apt build-dep -yqq --no-install-recommends ./ + bash get-deps.sh + DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc + - uses: actions/upload-artifact@v2 + with: + name: snapd + path: "${{ github.workspace }}/snapd_*.deb" + build: runs-on: self-hosted + needs: build-snapd-deb steps: - name: Cleanup job workspace id: cleanup-job-workspace @@ -20,6 +41,9 @@ jobs: rm -rf "${{ github.workspace }}" mkdir "${{ github.workspace }}" - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: snapd - name: Build snap run: | @@ -41,7 +65,9 @@ jobs: tests-main: runs-on: self-hosted - needs: build + needs: + - build + - build-snapd-deb steps: - name: Cleanup job workspace id: cleanup-job-workspace @@ -49,6 +75,9 @@ jobs: rm -rf "${{ github.workspace }}" mkdir "${{ github.workspace }}" - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: snapd - uses: actions/download-artifact@v2 with: name: snaps @@ -66,7 +95,9 @@ jobs: done tests-snapd: runs-on: ubuntu-latest - needs: build + needs: + - build + - build-snapd-deb steps: - name: Cleanup job workspace id: cleanup-job-workspace @@ -79,8 +110,12 @@ jobs: path: core-initrd - uses: actions/checkout@v2 with: - repository: 'snapcore/snapd' + repository: 'valentindavid/snapd' path: snapd + ref: 'valentindavid/split-snap-bootstrap' + - uses: actions/download-artifact@v2 + with: + name: snapd - uses: actions/download-artifact@v2 with: name: snaps @@ -94,7 +129,7 @@ jobs: . "core-initrd/tests/lib/prepare-utils.sh" echo "************* INSTALLING DEPS *************" - install_core_initrd_deps '${{ github.workspace }}/core-initrd' + install_core_initrd_deps '${{ github.workspace }}/core-initrd' '${{ github.workspace }}'/snapd_*.deb echo "************* DOWNLOADING SNAPS *************" download_core_initrd_snaps 'edge' diff --git a/debian/rules b/debian/rules index 11931152..1ffe1f22 100755 --- a/debian/rules +++ b/debian/rules @@ -262,6 +262,7 @@ override_dh_auto_install: cp -a $(CURDIR)/debian/tmp/usr/lib/systemd/libsystemd-shared* $(TEMPLIBDIR) set -e; \ for f in \ + /usr/bin/systemd-escape \ /lib/$(DEB_HOST_MULTIARCH)/libnss_files.so.* \ /lib/$(DEB_HOST_MULTIARCH)/libnss_compat.so.* \ /lib/$(DEB_HOST_MULTIARCH)/libgcc_s.so.1 \ diff --git a/factory/usr/lib/systemd/system-generators/snap-generator b/factory/usr/lib/systemd/system-generators/snap-generator new file mode 120000 index 00000000..777a6281 --- /dev/null +++ b/factory/usr/lib/systemd/system-generators/snap-generator @@ -0,0 +1 @@ +../../snapd/snap-bootstrap \ No newline at end of file diff --git a/factory/usr/lib/systemd/system-generators/snap-mounts b/factory/usr/lib/systemd/system-generators/snap-mounts new file mode 100755 index 00000000..88e26c47 --- /dev/null +++ b/factory/usr/lib/systemd/system-generators/snap-mounts @@ -0,0 +1,90 @@ +#!/bin/sh + +set -eu + +normaldir="${1}" +mkdir -p "${normaldir}" + +generate_unit() { + where="${1}" + fs="${2}" + device="${3}" + shift 3 + + mount_unit="$(systemd-escape --suffix=mount -p "${where}")" + + unset before + for target; do + case "${target}" in + -*) + ;; + *) + before="${before-}${before:+ }$(echo "${target}" | sed 's/[.]\(requires\|wants\)$//')" + ;; + esac + mkdir -p "${normaldir}/${target#-}" + ln -s "../${mount_unit}" "${normaldir}/${target#-}/${mount_unit}" + done + + case "${fs}" in + tmpfs) + cat <"${normaldir}/${mount_unit}" +[Unit] +DefaultDependencies=no +${before:+Before=}${before} + +[Mount] +Type=${fs} +What=${device} +Where=${where} +Options=nosuid,private +EOF + ;; + *) + device_escaped="$(systemd-escape -p "${device}")" + cat <"${normaldir}/${mount_unit}" +[Unit] +DefaultDependencies=no +BindsTo=${device_escaped}.device +After=${device_escaped}.device +Requires=systemd-fsck@${device_escaped}.service +After=systemd-fsck@${device_escaped}.service +${before:+Before=}${before} + +[Mount] +Type=${fs} +What=${device} +Where=${where} +Options=private +EOF + ;; + esac +} + +if mode="$(/usr/libexec/core/get-arg snapd_recovery_mode)"; then + case "${mode}" in + run) + disable_seed=- + disable_save=- + if [ -L /dev/ubuntu/disk ]; then + if udevadm info --query=property /dev/ubuntu/disk | grep -q '^UBUNTU_SEED_UUID='; then + disable_seed= + fi + if udevadm info --query=property /dev/ubuntu/disk | grep -q '^UBUNTU_SAVE_UUID='; then + disable_save= + fi + fi + generate_unit /run/mnt/data ext4 /dev/ubuntu/data initrd-root-fs.target.requires snap-data-save-mounted.target.requires modeenv-available.target.requires + generate_unit /run/mnt/ubuntu-seed vfat /dev/ubuntu/seed ${disable_seed}initrd-root-fs.target.wants ${disable_seed}model-available.target.wants + generate_unit /run/mnt/ubuntu-boot ext4 /dev/ubuntu/boot initrd-root-fs.target.requires model-available.target.requires + generate_unit /run/mnt/ubuntu-save ext4 /dev/ubuntu/save ${disable_save}initrd-root-fs.target.wants ${disable_save}snap-data-save-mounted.target.wants + ;; + install) + generate_unit /run/mnt/ubuntu-seed vfat /dev/ubuntu/seed initrd-root-fs.target.requires model-available.target.requires + generate_unit /run/mnt/data tmpfs tmpfs initrd-root-fs.target.requires + ;; + *) + exit 0 + ;; + esac +fi diff --git a/factory/usr/lib/systemd/system/detect-classic-sysroot.service b/factory/usr/lib/systemd/system/detect-classic-sysroot.service index dfce5562..07ea4f8a 100644 --- a/factory/usr/lib/systemd/system/detect-classic-sysroot.service +++ b/factory/usr/lib/systemd/system/detect-classic-sysroot.service @@ -1,4 +1,6 @@ [Unit] +ConditionKernelCommandLine=!snapd_recovery_mode=run +ConditionKernelCommandLine=!snapd_recovery_mode=install Description=Detect Ubuntu classic sysroot DefaultDependencies=no Before=initrd-root-device.target diff --git a/factory/usr/lib/systemd/system/detect-uc-sysroot.service b/factory/usr/lib/systemd/system/detect-uc-sysroot.service index 093410e0..709e1fc4 100644 --- a/factory/usr/lib/systemd/system/detect-uc-sysroot.service +++ b/factory/usr/lib/systemd/system/detect-uc-sysroot.service @@ -1,4 +1,6 @@ [Unit] +ConditionKernelCommandLine=!snapd_recovery_mode=run +ConditionKernelCommandLine=!snapd_recovery_mode=install Description=Detect Ubuntu Core sysroot DefaultDependencies=no Before=initrd-root-device.target diff --git a/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-data.service b/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-data.service new file mode 120000 index 00000000..89e0678a --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-data.service @@ -0,0 +1 @@ +../snap-unlock-data.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-save.service b/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-save.service new file mode 120000 index 00000000..422d194b --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-device.target.wants/snap-unlock-save.service @@ -0,0 +1 @@ +../snap-unlock-save.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd-root-device.target.wants/populate-writable.service b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/populate-writable.service similarity index 100% rename from factory/usr/lib/systemd/system/initrd-root-device.target.wants/populate-writable.service rename to factory/usr/lib/systemd/system/initrd-root-fs.target.requires/populate-writable.service diff --git a/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-compare-data-save.service b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-compare-data-save.service new file mode 120000 index 00000000..c62c1e26 --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-compare-data-save.service @@ -0,0 +1 @@ +../snap-compare-data-save.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-configure-gadget.service b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-configure-gadget.service new file mode 120000 index 00000000..d227f03a --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-configure-gadget.service @@ -0,0 +1 @@ +../snap-configure-gadget.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-ephemeral-modeenv.service b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-ephemeral-modeenv.service new file mode 120000 index 00000000..057f0a67 --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-fs.target.requires/snap-ephemeral-modeenv.service @@ -0,0 +1 @@ +../snap-ephemeral-modeenv.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd-root-fs.target.wants/reload-model.service b/factory/usr/lib/systemd/system/initrd-root-fs.target.wants/reload-model.service new file mode 120000 index 00000000..219edb60 --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd-root-fs.target.wants/reload-model.service @@ -0,0 +1 @@ +../reload-model.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/initrd.target.wants/snap-update-boot-loader-vars.service b/factory/usr/lib/systemd/system/initrd.target.wants/snap-update-boot-loader-vars.service new file mode 120000 index 00000000..b087191d --- /dev/null +++ b/factory/usr/lib/systemd/system/initrd.target.wants/snap-update-boot-loader-vars.service @@ -0,0 +1 @@ +../snap-update-boot-loader-vars.service \ No newline at end of file diff --git a/factory/usr/lib/systemd/system/modeenv-available.target b/factory/usr/lib/systemd/system/modeenv-available.target new file mode 100644 index 00000000..746e99de --- /dev/null +++ b/factory/usr/lib/systemd/system/modeenv-available.target @@ -0,0 +1,5 @@ +[Unit] +Description=Modeenv available + +Wants=reload-disk.service +After=reload-disk.service diff --git a/factory/usr/lib/systemd/system/model-available.target b/factory/usr/lib/systemd/system/model-available.target new file mode 100644 index 00000000..d78ab3bd --- /dev/null +++ b/factory/usr/lib/systemd/system/model-available.target @@ -0,0 +1,10 @@ +[Unit] +Description=Model available + +# This unit will depend on the mount that will contain the model to load. +# In run mode, it will be run-mnt-ubuntu\x2dseed.mount +# In install/recover/reset, it will be in run-mnt-ubuntu\x2dboot.mount +# Those units will be generated and added by /usr/lib/systemd/system-generators/snap-mounts + +Wants=reload-disk.service +After=reload-disk.service diff --git a/factory/usr/lib/systemd/system/populate-writable.service b/factory/usr/lib/systemd/system/populate-writable.service index 764ff8fd..34791d40 100644 --- a/factory/usr/lib/systemd/system/populate-writable.service +++ b/factory/usr/lib/systemd/system/populate-writable.service @@ -3,7 +3,9 @@ OnFailure=emergency.target OnFailureJobMode=replace-irreversibly DefaultDependencies=no Before=initrd-root-fs.target +# run-mnt-data.mount is generated by /usr/lib/systemd/system-generators/snap-mounts After=run-mnt-data.mount +# run-mnt-base.mount is generated by /usr/lib/systemd/system-generators/snap-generator After=run-mnt-base.mount After=sysroot.mount After=sysroot-writable.mount @@ -11,6 +13,8 @@ Requires=sysroot.mount Requires=sysroot-writable.mount Wants=snap-initramfs-mounts.service After=snap-initramfs-mounts.service +Wants=snap-configure-gadget.service +After=snap-configure-gadget.service ConditionPathIsMountPoint=/run/mnt/base diff --git a/factory/usr/lib/systemd/system/reload-disk.service b/factory/usr/lib/systemd/system/reload-disk.service new file mode 100644 index 00000000..f5b6e879 --- /dev/null +++ b/factory/usr/lib/systemd/system/reload-disk.service @@ -0,0 +1,18 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=run +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Reload disk + +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly + +DefaultDependencies=no + +Requires=dev-ubuntu-disk.device +After=dev-ubuntu-disk.device + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStartPre=-systemctl daemon-reload +ExecStart=-systemctl --no-block start initrd-root-fs.target snap-data-mounted-mounted.target diff --git a/factory/usr/lib/systemd/system/reload-model.service b/factory/usr/lib/systemd/system/reload-model.service new file mode 100644 index 00000000..21f3414a --- /dev/null +++ b/factory/usr/lib/systemd/system/reload-model.service @@ -0,0 +1,27 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=run +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Reload model + +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly + +DefaultDependencies=no + +# run-mnt-data.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +Requires=run-mnt-data.mount +After=run-mnt-data.mount + +After=model-available.target +Requires=model-available.target +After=modeenv-available.target +Requires=modeenv-available.target + +After=sysinit.target +After=tmp.mount + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStartPre=-systemctl daemon-reload +ExecStart=-systemctl --no-block start initrd-root-fs.target diff --git a/factory/usr/lib/systemd/system/snap-compare-data-save.service b/factory/usr/lib/systemd/system/snap-compare-data-save.service new file mode 100644 index 00000000..6e31ce61 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-compare-data-save.service @@ -0,0 +1,19 @@ +[Unit] +ConditionKernelCommandLine=snapd_recovery_mode=run +ConditionPathIsEncrypted=/run/mnt/data +Description=Compare data and save partitions +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +Before=initrd-root-fs.target + +Wants=snap-data-save-mounted.target +After=snap-data-save-mounted.target + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap compare-data-save +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-configure-gadget.service b/factory/usr/lib/systemd/system/snap-configure-gadget.service new file mode 100644 index 00000000..13a42499 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-configure-gadget.service @@ -0,0 +1,20 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Configure the gadget +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +Requires=reload-model.service +After=reload-model.service + +# run-mnt-data.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +Requires=run-mnt-data.mount +After=run-mnt-data.mount + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap configure-gadget +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-data-save-mounted.target b/factory/usr/lib/systemd/system/snap-data-save-mounted.target new file mode 100644 index 00000000..e07fad48 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-data-save-mounted.target @@ -0,0 +1,5 @@ +[Unit] +Description=Data mounted + +Wants=reload-model.service +After=reload-model.service diff --git a/factory/usr/lib/systemd/system/snap-ephemeral-modeenv.service b/factory/usr/lib/systemd/system/snap-ephemeral-modeenv.service new file mode 100644 index 00000000..d4d0bdd7 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-ephemeral-modeenv.service @@ -0,0 +1,20 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Generate an ephemeral modeenv +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +Requires=reload-model.service +After=reload-model.service + +# run-mnt-data.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +Requires=run-mnt-data.mount +After=run-mnt-data.mount + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap ephemeral-modeenv +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-initramfs-mounts.service b/factory/usr/lib/systemd/system/snap-initramfs-mounts.service index c4329cc1..fd2c7e8d 100644 --- a/factory/usr/lib/systemd/system/snap-initramfs-mounts.service +++ b/factory/usr/lib/systemd/system/snap-initramfs-mounts.service @@ -1,4 +1,6 @@ [Unit] +ConditionKernelCommandLine=!snapd_recovery_mode=run +ConditionKernelCommandLine=!snapd_recovery_mode=install Description=Mount initial filesystems OnFailure=emergency.target OnFailureJobMode=replace-irreversibly @@ -7,6 +9,9 @@ DefaultDependencies=no After=sysinit.target Before=initrd-root-device.target +BindsTo=dev-ubuntu-disk.device +After=dev-ubuntu-disk.device + [Service] Type=oneshot RemainAfterExit=true diff --git a/factory/usr/lib/systemd/system/snap-measure-epoch.service b/factory/usr/lib/systemd/system/snap-measure-epoch.service new file mode 100644 index 00000000..2c1975eb --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-measure-epoch.service @@ -0,0 +1,14 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=run +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Measure the epoch +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap measure-epoch +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-measure-model.service b/factory/usr/lib/systemd/system/snap-measure-model.service new file mode 100644 index 00000000..0402aeec --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-measure-model.service @@ -0,0 +1,19 @@ +[Unit] +ConditionKernelCommandLine=|snapd_recovery_mode=run +ConditionKernelCommandLine=|snapd_recovery_mode=install +Description=Measure the model +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +After=snap-measure-epoch.service +Requires=snap-measure-epoch.service +After=model-available.target +Requires=model-available.target + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap measure-model +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-unlock-data.service b/factory/usr/lib/systemd/system/snap-unlock-data.service new file mode 100644 index 00000000..e15779c3 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-unlock-data.service @@ -0,0 +1,20 @@ +[Unit] +ConditionKernelCommandLine=snapd_recovery_mode=run +Description=Unlock data partition +DefaultDependencies=no +JobTimeoutSec=3min + +After=snap-measure-model.service +Requires=snap-measure-model.service +# run-mnt-ubuntu\x2dboot.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +RequiresMountsFor=/run/mnt/ubuntu-boot +# /dev/ubuntu/data-luks is created by /usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules +BindsTo=dev-ubuntu-data\x2dluks.device +After=dev-ubuntu-data\x2dluks.device + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap unlock-data +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-unlock-save.service b/factory/usr/lib/systemd/system/snap-unlock-save.service new file mode 100644 index 00000000..d2bf6a2b --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-unlock-save.service @@ -0,0 +1,20 @@ +[Unit] +ConditionKernelCommandLine=snapd_recovery_mode=run +Description=Unlock save partition +DefaultDependencies=no +JobTimeoutSec=3min + +After=snap-measure-model.service +Requires=snap-measure-model.service +# run-mnt-data.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +RequiresMountsFor=/run/mnt/data +# /dev/ubuntu/save-luks is created by /usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules +BindsTo=dev-ubuntu-save\x2dluks.device +After=dev-ubuntu-save\x2dluks.device + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap unlock-save +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/snap-update-boot-loader-vars.service b/factory/usr/lib/systemd/system/snap-update-boot-loader-vars.service new file mode 100644 index 00000000..37d84fd0 --- /dev/null +++ b/factory/usr/lib/systemd/system/snap-update-boot-loader-vars.service @@ -0,0 +1,16 @@ +[Unit] +ConditionKernelCommandLine=snapd_recovery_mode=run +Description=Update bootloader variables +OnFailure=emergency.target +OnFailureJobMode=replace-irreversibly +DefaultDependencies=no + +# run-mnt-boot.mount is generated by /usr/lib/systemd/system-generators/snap-mounts +After=run-mnt-boot.mount + +[Service] +Type=oneshot +RemainAfterExit=true +ExecStart=/usr/lib/snapd/snap-bootstrap update-boot-loader-vars +StandardOutput=journal+console +StandardError=journal+console diff --git a/factory/usr/lib/systemd/system/sysroot.mount b/factory/usr/lib/systemd/system/sysroot.mount index 5b2c954e..64637488 100644 --- a/factory/usr/lib/systemd/system/sysroot.mount +++ b/factory/usr/lib/systemd/system/sysroot.mount @@ -8,6 +8,9 @@ After=detect-classic-sysroot.service Wants=detect-classic-sysroot.service After=run-mnt-base.mount After=snap-initramfs-mounts.service +After=reload-model.service +After=run-mnt-base.mount +After=run-mnt-data.mount AssertPathIsSymbolicLink=/run/mnt/sysroot diff --git a/factory/usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules b/factory/usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules new file mode 100644 index 00000000..51a17c01 --- /dev/null +++ b/factory/usr/lib/udev/rules.d/90-ubuntu-core-partitions.rules @@ -0,0 +1,15 @@ +SUBSYSTEM!="block", GOTO="ubuntu_core_partitions_end" + +ENV{DEVTYPE}=="partition", IMPORT{parent}="UBUNTU_*_UUID" +IMPORT{program}="/usr/lib/snapd/snap-bootstrap scan-disk" +ENV{DEVTYPE}=="disk", ENV{UBUNTU_DISK}=="1", SYMLINK+="ubuntu/disk" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_SEED}=="1", SYMLINK+="ubuntu/seed" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_BOOT}=="1", SYMLINK+="ubuntu/boot" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_DATA}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="ubuntu/data-luks" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_DATA}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="ubuntu/data" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_SAVE}=="1", ENV{ID_FS_TYPE}=="crypto_LUKS", SYMLINK+="ubuntu/save-luks" +ENV{DEVTYPE}=="partition", ENV{UBUNTU_SAVE}=="1", ENV{ID_FS_TYPE}!="crypto_LUKS", SYMLINK+="ubuntu/save" +ENV{DM_UUID}=="CRYPT-*", ENV{DM_NAME}=="ubuntu-data-*", SYMLINK+="ubuntu/data" +ENV{DM_UUID}=="CRYPT-*", ENV{DM_NAME}=="ubuntu-save-*", SYMLINK+="ubuntu/save" + +LABEL="ubuntu_core_partitions_end" diff --git a/tests/lib/prepare-uc.sh b/tests/lib/prepare-uc.sh index fa6df6c1..b1daeb8e 100755 --- a/tests/lib/prepare-uc.sh +++ b/tests/lib/prepare-uc.sh @@ -7,7 +7,7 @@ set -x . "$TESTSLIB/prepare-utils.sh" # install dependencies -install_core_initrd_deps "$PROJECT_PATH" +install_core_initrd_deps "$PROJECT_PATH" "$PROJECT_PATH"/snapd_*.deb # TODO: is this still necessary for core-initrd? (this was copied from snapd) # create test user for spread to use diff --git a/tests/lib/prepare-utils.sh b/tests/lib/prepare-utils.sh index c406fd72..9cca8ca2 100644 --- a/tests/lib/prepare-utils.sh +++ b/tests/lib/prepare-utils.sh @@ -116,6 +116,11 @@ start_snapd_core_vm() { install_core_initrd_deps() { local project_dir="$1" + if [ -n "${2-}" ]; then + snapd_deb="$(realpath "$2")" + else + snapd_deb=snapd + fi # needed for dracut which is a build-dep of ubuntu-core-initramfs # and for the version of snapd here which we want to use to pull snap-bootstrap @@ -126,7 +131,9 @@ install_core_initrd_deps() { # these are already installed in the lxd image which speeds things up, but they # are missing in qemu and google images. - sudo DEBIAN_FRONTEND=noninteractive apt install initramfs-tools-core psmisc fdisk snapd mtools ovmf qemu-system-x86 sshpass whois openssh-server -yqq + sudo DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends initramfs-tools-core psmisc fdisk mtools ovmf qemu-system-x86 sshpass whois openssh-server -yqq + + sudo DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends --allow-downgrades "${snapd_deb}" -yqq # use the snapd snap explicitly # TODO: since ubuntu-image ships it's own version of `snap prepare-image`, @@ -238,6 +245,9 @@ repack_and_sign_gadget() { 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" rm "$gadget_snap" + + echo "console=ttyS0 systemd.journald.foward_to_console=1" >"${gadget_dir}/cmdline.extra" + snap pack --filename=$gadget_name "$gadget_dir" rm -rf "$gadget_dir" } diff --git a/tests/spread/build/build-initrd/task.yaml b/tests/spread/build/build-initrd/task.yaml index a4598be5..1840df53 100644 --- a/tests/spread/build/build-initrd/task.yaml +++ b/tests/spread/build/build-initrd/task.yaml @@ -9,7 +9,7 @@ prepare: | . "$TESTSLIB/prepare-utils.sh" # install dependencies - install_core_initrd_deps "$PROJECT_PATH" + install_core_initrd_deps "$PROJECT_PATH" "$PROJECT_PATH"/snapd_*.deb # download pc-kernel and pc gadget snap download pc-kernel --channel=22/${SNAP_BRANCH} --basename=upstream-pc-kernel