Skip to content

Commit

Permalink
Install in initrd
Browse files Browse the repository at this point in the history
  • Loading branch information
valentindavid committed Jun 14, 2023
1 parent 81c9d47 commit 03c4c56
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Build-Depends: debhelper-compat (= 12), dh-python, python3:any, dracut-core, qui
squashfs-tools,
snapd (>= 2.50+20.04),
systemd-bootchart,
golang-go, indent, libapparmor-dev, libcap-dev, libfuse-dev, libglib2.0-dev, liblzma-dev, liblzo2-dev, libseccomp-dev, libudev-dev, openssh-client, pkg-config, python3, python3-docutils, python3-markdown, squashfs-tools, tzdata, udev, xfslibs-dev
golang-go, indent, libapparmor-dev, libcap-dev, libfuse-dev, libglib2.0-dev, liblzma-dev, liblzo2-dev, libseccomp-dev, libudev-dev, openssh-client, pkg-config, python3, python3-docutils, python3-markdown, squashfs-tools, tzdata, udev, xfslibs-dev, cryptsetup-bin
Standards-Version: 4.4.1
Build-Conflicts: snapd (= 2.59.3+20.04)
Homepage: https://launchpad.net/ubuntu-core-initramfs
Expand Down
29 changes: 23 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ override_dh_auto_clean:
cd vendor/systemd; QUILT_PATCHES=debian/patches quilt pop -a || true
rm -rf vendor/systemd/.pc

INSTALL_FILES_FROM_HOST= \
/bin/kmod \
/bin/mount \
/bin/umount \
/lib/$(DEB_HOST_MULTIARCH)/libgcc_s.so.1 \
/lib/$(DEB_HOST_MULTIARCH)/libnss_compat.so.* \
/lib/$(DEB_HOST_MULTIARCH)/libnss_files.so.* \
/lib/systemd/system/snapd.recovery-chooser-trigger.service \
/lib/systemd/systemd-bootchart \
/sbin/cryptsetup \
/sbin/dmsetup \
/sbin/e2fsck \
/sbin/fsck \
/sbin/fsck.vfat \
/sbin/sfdisk \
/usr/bin/partx \
/usr/bin/tar \
/usr/bin/unsquashfs \
/usr/lib/snapd/info \
/usr/lib/snapd/snap-bootstrap \
/usr/sbin/mkfs.ext4

override_dh_auto_install: TEMPLIBDIR := $(shell mktemp -d)
override_dh_auto_install:
rm -rf debian/tmp
Expand Down Expand Up @@ -192,12 +214,7 @@ override_dh_auto_install:
cp -a $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/$$lib* $(TEMPLIBDIR); \
done
cp -a $(CURDIR)/debian/tmp/usr/lib/systemd/libsystemd-shared* $(TEMPLIBDIR)

set -e; \
for f in "/lib/$(DEB_HOST_MULTIARCH)/libnss_files.so.* /lib/$(DEB_HOST_MULTIARCH)/libnss_compat.so.* /lib/$(DEB_HOST_MULTIARCH)/libgcc_s.so.1 /sbin/e2fsck /sbin/fsck.vfat /sbin/fsck /bin/umount /bin/mount /bin/kmod /usr/bin/unsquashfs /sbin/dmsetup /usr/lib/snapd/snap-bootstrap /usr/lib/snapd/info /lib/systemd/systemd-bootchart /lib/systemd/system/snapd.recovery-chooser-trigger.service"; do \
LD_PRELOAD= LD_LIBRARY_PATH=$(TEMPLIBDIR) \
/usr/lib/dracut/dracut-install -D $(CURDIR)/debian/tmp --ldd $$f; \
done
LD_PRELOAD= LD_LIBRARY_PATH=$(TEMPLIBDIR) /usr/lib/dracut/dracut-install -D $(CURDIR)/debian/tmp --ldd $(INSTALL_FILES_FROM_HOST)
dpkg -L dmsetup | grep rules.d | xargs -L1 /usr/lib/dracut/dracut-install -D $(CURDIR)/debian/tmp --ldd
ifeq ($(DEB_HOST_ARCH),amd64)
-cp $(CURDIR)/factory/usr/lib/snapd/snap-bootstrap $(CURDIR)/debian/tmp/usr/lib/snapd/snap-bootstrap
Expand Down
1 change: 1 addition & 0 deletions factory/usr/lib/modules-load.d/ubuntu-core-initramfs.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ahci
libahci
usb-storage
nls_iso8859-1
kmod-nls-cp437
sdhci
sdhci-pci
sdhci-acpi
Expand Down
4 changes: 3 additions & 1 deletion factory/usr/lib/the-modeenv
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ cp /sysroot/run/image.fstab /run/
# TODO:UC20: move this logic into snap-bootstrap to be incorporated with
# initramfs-mounts

mode="$(/usr/libexec/core/get-mode mode)" || mode="$(/usr/libexec/core/get-arg snapd_recovery_mode)" || mode="unknown"

# Always bind-mount all the host filesystems
mkdir -p /run/mnt/host
echo '/run/mnt/host /host none rbind 0 0' >> /run/image.fstab
if grep -q snapd_recovery_mode=run /proc/cmdline; then
if [ "${mode}" = "run" ]; then
# TODO:UC20: support other bootloaders too
if [ -f /run/mnt/ubuntu-boot/EFI/ubuntu/grub.cfg ]; then
echo '/run/mnt/ubuntu-boot/EFI/ubuntu /boot/grub none bind 0 0' >> /run/image.fstab
Expand Down

0 comments on commit 03c4c56

Please sign in to comment.