From 1791c8a5e53e0a6740c70ea40d0a526f86738893 Mon Sep 17 00:00:00 2001 From: Harald Sitter Date: Thu, 15 May 2025 15:09:28 +0200 Subject: [PATCH] update calamares to support rootfsv1 and erofs --- mkosi.extra/live/usr/bin/_calamares@subvol | 67 ++++++++++++++----- .../usr/bin/_kde-linux-install-flatpaks | 2 +- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/mkosi.extra/live/usr/bin/_calamares@subvol b/mkosi.extra/live/usr/bin/_calamares@subvol index 6767bee..b2a1dc0 100755 --- a/mkosi.extra/live/usr/bin/_calamares@subvol +++ b/mkosi.extra/live/usr/bin/_calamares@subvol @@ -31,25 +31,44 @@ rm -rfv ./* btrfs subvolume sync . || true btrfs quota enable --simple . -btrfs send --compressed-data "/system/@kde-linux_$IMAGE_VERSION" | btrfs receive . -btrfs subvolume create @home -btrfs subvolume create @root -btrfs subvolume create @locale -btrfs subvolume create @snap -btrfs subvolume create @var-overlay -btrfs subvolume create @etc-overlay -mkdir @var-overlay/upper @var-overlay/work @etc-overlay/upper @etc-overlay/work +if grep "kde-linux.erofs=1" /proc/cmdline; then + btrfs subvolume create @system + mkdir @system/boot @system/proc @system/sys @system/dev @system/run @system/usr + cp /dev/gpt-auto-root kde-linux_$IMAGE_VERSION.erofs -# Overmount calamares' mount with the subvol mount -mount -o "subvol=@kde-linux_$IMAGE_VERSION" "$device" "$ROOT" -mount -t proc proc "$ROOT/proc" -mount -t sysfs sys "$ROOT/sys" -mount -o bind /dev "$ROOT/dev" -mount -t tmpfs tmpfs "$ROOT/run" -mkdir "$ROOT/run/udev" -mount -o bind /run/udev "$ROOT/run/udev" -mount -t efivarfs efivarfs "$ROOT/sys/firmware/efi/efivars" -_kde-linux-overlay "$device" "$ROOT" + # Overmount calamares' mount with the subvol mount + mount -o "subvol=@system" "$device" "$ROOT" + mount -t proc proc "$ROOT/proc" + mount -t sysfs sys "$ROOT/sys" + mount -o bind /dev "$ROOT/dev" + mount -t tmpfs tmpfs "$ROOT/run" + mkdir "$ROOT/run/udev" # This is not part of @system but rather the $ROOT (do not move this to the mkdir list of @system!) + mount -o bind /run/udev "$ROOT/run/udev" + mount -t efivarfs efivarfs "$ROOT/sys/firmware/efi/efivars" + mount -o ro,X-mount.subdir=usr /dev/gpt-auto-root "$ROOT/usr" +else + btrfs subvolume create @kde-linux_$IMAGE_VERSION + cp -ra /system/. @kde-linux_$IMAGE_VERSION + btrfs send --compressed-data "/system/@kde-linux_$IMAGE_VERSION" | btrfs receive . + btrfs subvolume create @home + btrfs subvolume create @root + btrfs subvolume create @locale + btrfs subvolume create @snap + btrfs subvolume create @var-overlay + btrfs subvolume create @etc-overlay + mkdir @var-overlay/upper @var-overlay/work @etc-overlay/upper @etc-overlay/work + + # Overmount calamares' mount with the subvol mount + mount -o "subvol=@kde-linux_$IMAGE_VERSION" "$device" "$ROOT" + mount -t proc proc "$ROOT/proc" + mount -t sysfs sys "$ROOT/sys" + mount -o bind /dev "$ROOT/dev" + mount -t tmpfs tmpfs "$ROOT/run" + mkdir "$ROOT/run/udev" # This is not part of @system but rather the $ROOT (do not move this to the mkdir list of @system!) + mount -o bind /run/udev "$ROOT/run/udev" + mount -t efivarfs efivarfs "$ROOT/sys/firmware/efi/efivars" + _kde-linux-overlay "$device" "$ROOT" +fi # ESP is a bit tricky. Find the block device of the root partition and then we'll ask systemd for an ESP on that device. # ... and luks devices are even more tricky because we need to get the real device first @@ -70,6 +89,18 @@ mount "$espdev" "$ROOT/boot" # TODO: doing it this way means we can't factory reset flatpaks. Figure out what to do about that. rm -rf "$ROOT/var/lib/flatpak" cp -ra /system/@flatpak "$ROOT/var/lib/flatpak" + +# TODO: fix in calamares (doesn't mkdir properly) +mkdir --parents "$ROOT/etc/sudoers.d/" + +# Bit of a crutch to get systemd's base_filesystem_create() to run so the / gets populated with symlinks. +systemd-nspawn -D "$ROOT" "true" || true + +# Initialize systemd stuff +systemd-sysusers --root="$ROOT" +# exclude /usr because some tmpfiles are rubbish and assume /usr is writable... +systemd-tmpfiles --root="$ROOT" --exclude-prefix=/usr --create + # Make sure presets are applied systemctl --root="$ROOT" preset-all systemctl --root="$ROOT" preset-all --global diff --git a/mkosi.extra/usr/bin/_kde-linux-install-flatpaks b/mkosi.extra/usr/bin/_kde-linux-install-flatpaks index 7b61cdb..b83da90 100755 --- a/mkosi.extra/usr/bin/_kde-linux-install-flatpaks +++ b/mkosi.extra/usr/bin/_kde-linux-install-flatpaks @@ -4,4 +4,4 @@ set -eux -flatpak install --noninteractive --assumeyes --sideload-repo=/system/@flatpak/.ostree/repo org.kde.dolphin org.kde.elisa org.kde.gwenview org.kde.okular org.kde.konsole org.kde.kate org.kde.kwrite org.kde.haruna org.kde.ark org.mozilla.firefox +flatpak install --noninteractive --assumeyes --sideload-repo=/usr/share/factory/var/lib/flatpak/.ostree/repo org.kde.dolphin org.kde.elisa org.kde.gwenview org.kde.okular org.kde.konsole org.kde.kate org.kde.kwrite org.kde.haruna org.kde.ark org.mozilla.firefox