squash-live: add system generator to fix sysroot.mount problem and other changes ported from dmsquash-live [release 043-2mamba;Thu Nov 12 2015]

This commit is contained in:
Silvan Calarco 2024-01-05 21:56:17 +01:00
parent 2efe697f52
commit c483c12b3d
2 changed files with 161 additions and 69 deletions

View File

@ -1,32 +1,92 @@
diff -Nru dracut-037.orig/modules.d/99squash-live/apply-live-updates.sh dracut-037/modules.d/99squash-live/apply-live-updates.sh
--- dracut-037.orig/modules.d/99squash-live/apply-live-updates.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/apply-live-updates.sh 2014-04-16 17:01:00.492528268 +0200
@@ -0,0 +1,17 @@
diff -Nru dracut-043.orig/modules.d/99squash-live/apply-live-updates.sh dracut-043/modules.d/99squash-live/apply-live-updates.sh
--- dracut-043.orig/modules.d/99squash-live/apply-live-updates.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/apply-live-updates.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -d /updates ]; then
+if [ -b /dev/mapper/live-rw ] && [ -d /run/initramfs/live/updates -o -d /updates ]; then
+ info "Applying updates to live image..."
+ mount -o bind /run $NEWROOT/run
+ # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories
+ (
+ cd /updates
+ find . -depth -type d | while read dir; do
+ mkdir -p "$NEWROOT/$dir"
+ done
+ find . -depth \! -type d | while read file; do
+ cp -a "$file" "$NEWROOT/$file"
+ done
+ )
+ for d in /updates /run/initramfs/live/updates; do
+ [ -d "$d" ] || continue
+ (
+ cd $d
+ find . -depth -type d | while read dir; do
+ mkdir -p "$NEWROOT/$dir"
+ done
+ find . -depth \! -type d | while read file; do
+ cp -a "$file" "$NEWROOT/$file"
+ done
+ )
+ done
+ umount $NEWROOT/run
+fi
diff -Nru dracut-037.orig/modules.d/99squash-live/module-setup.sh dracut-037/modules.d/99squash-live/module-setup.sh
--- dracut-037.orig/modules.d/99squash-live/module-setup.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/module-setup.sh 2014-04-16 17:15:26.401669184 +0200
@@ -0,0 +1,31 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
diff -Nru dracut-043.orig/modules.d/99squash-live/checkisomd5@.service dracut-043/modules.d/99squash-live/checkisomd5@.service
--- dracut-043.orig/modules.d/99squash-live/checkisomd5@.service 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/checkisomd5@.service 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,14 @@
+[Unit]
+Description=Media check on %f
+DefaultDependencies=no
+Before=shutdown.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/usr/bin/checkisomd5 --verbose %f
+StandardInput=tty-force
+StandardOutput=inherit
+StandardError=inherit
+TimeoutSec=0
+SuccessExitStatus=2
diff -Nru dracut-043.orig/modules.d/99squash-live/iso-scan.sh dracut-043/modules.d/99squash-live/iso-scan.sh
--- dracut-043.orig/modules.d/99squash-live/iso-scan.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/iso-scan.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+isofile=$1
+
+[ -z "$isofile" ] && exit 1
+
+ismounted "/run/initramfs/isoscan" && exit 0
+
+mkdir -p "/run/initramfs/isoscan"
+
+do_iso_scan() {
+ local _name
+ local dev
+ for dev in /dev/disk/by-uuid/*; do
+ _name=$(dev_unit_name "$dev")
+ [ -e /tmp/isoscan-${_name} ] && continue
+ > /tmp/isoscan-${_name}
+ mount -t auto -o ro "$dev" "/run/initramfs/isoscan" || continue
+ if [ -f "/run/initramfs/isoscan/$isofile" ]; then
+ losetup -f "/run/initramfs/isoscan/$isofile"
+ rm -f -- "$job"
+ exit 0
+ else
+ umount "/run/initramfs/isoscan"
+ fi
+ done
+}
+
+do_iso_scan
+
+rmdir "/run/initramfs/isoscan"
+exit 1
diff -Nru dracut-043.orig/modules.d/99squash-live/module-setup.sh dracut-043/modules.d/99squash-live/module-setup.sh
--- dracut-043.orig/modules.d/99squash-live/module-setup.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/module-setup.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+ # a live host-only image doesn't really make a lot of sense
+ [[ $hostonly ]] && return 1
@ -38,26 +98,43 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/module-setup.sh dracut-037/mod
+}
+
+installkernel() {
+ instmods squashfs loop overlayfs ehci-hcd ohci-hcd uhci-hcd xhci-hcd usb_storage iso9660
+ instmods squashfs loop overlay overlayfs ehci-hcd ohci-hcd uhci-hcd xhci-hcd usb_storage iso9660
+}
+
+install() {
+ dracut_install umount dmsetup blkid dd losetup grep blockdev
+ dracut_install -o checkisomd5
+ inst_multiple umount dmsetup blkid dd losetup grep blockdev find
+ inst_multiple -o checkisomd5
+ inst_hook cmdline 30 "$moddir/parse-squash-live.sh"
+ inst_hook cmdline 31 "$moddir/parse-iso-scan.sh"
+ inst_hook pre-udev 30 "$moddir/squash-live-genrules.sh"
+ inst_hook pre-udev 30 "$moddir/squash-liveiso-genrules.sh"
+ inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
+ inst_script "$moddir/squash-live-root.sh" "/sbin/squash-live-root"
+ inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
+ # should probably just be generally included
+ inst_rules 60-cdrom_id.rules
+ inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
+ dracut_need_initqueue
+ # fix required since systemd-udev 212 because udev now mounts in its own namespace
+ sed -i "s/MountFlags=.*/MountFlags=shared/" ${initdir}/lib/systemd/system/systemd-udevd.service
+}
diff -Nru dracut-037.orig/modules.d/99squash-live/parse-squash-live.sh dracut-037/modules.d/99squash-live/parse-squash-live.sh
--- dracut-037.orig/modules.d/99squash-live/parse-squash-live.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/parse-squash-live.sh 2014-04-16 17:01:00.492528268 +0200
@@ -0,0 +1,50 @@
diff -Nru dracut-043.orig/modules.d/99squash-live/parse-iso-scan.sh dracut-043/modules.d/99squash-live/parse-iso-scan.sh
--- dracut-043.orig/modules.d/99squash-live/parse-iso-scan.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/parse-iso-scan.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,9 @@
+#!/bin/sh
+# live images are specified with
+# root=live:backingdev
+
+isofile=$(getarg iso-scan/filename)
+
+if [ -n "$isofile" ]; then
+ /sbin/initqueue --settled --unique /sbin/iso-scan "$isofile"
+fi
diff -Nru dracut-043.orig/modules.d/99squash-live/parse-squash-live.sh dracut-043/modules.d/99squash-live/parse-squash-live.sh
--- dracut-043.orig/modules.d/99squash-live/parse-squash-live.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/parse-squash-live.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,57 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
@ -94,6 +171,14 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/parse-squash-live.sh dracut-03
+ root="${root#live:}"
+ root="live:/dev/disk/by-uuid/${root#UUID=}"
+ rootok=1 ;;
+ live:PARTUUID=*|PARTUUID=*) \
+ root="${root#live:}"
+ root="live:/dev/disk/by-partuuid/${root#PARTUUID=}"
+ rootok=1 ;;
+ live:PARTLABEL=*|PARTLABEL=*) \
+ root="${root#live:}"
+ root="live:/dev/disk/by-partlabel/${root#PARTLABEL=}"
+ rootok=1 ;;
+ live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
+ root="${root#live:}"
+ root="liveiso:${root}"
@ -107,10 +192,9 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/parse-squash-live.sh dracut-03
+
+# make sure that init doesn't complain
+[ -z "$root" ] && root="live"
+
diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-genrules.sh dracut-037/modules.d/99squash-live/squash-live-genrules.sh
--- dracut-037.orig/modules.d/99squash-live/squash-live-genrules.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/squash-live-genrules.sh 2014-04-16 17:01:00.492528268 +0200
diff -Nru dracut-043.orig/modules.d/99squash-live/squash-live-genrules.sh dracut-043/modules.d/99squash-live/squash-live-genrules.sh
--- dracut-043.orig/modules.d/99squash-live/squash-live-genrules.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/squash-live-genrules.sh 2015-11-12 15:42:07.546276928 +0100
@@ -0,0 +1,16 @@
+#!/bin/sh
+if [ "${root%%:*}" = "live" ]; then
@ -128,31 +212,11 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-genrules.sh dracut
+ } >> /etc/udev/rules.d/99-live-squash.rules
+ echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh
+fi
diff -Nru dracut-037.orig/modules.d/99squash-live/squash-liveiso-genrules.sh dracut-037/modules.d/99squash-live/squash-liveiso-genrules.sh
--- dracut-037.orig/modules.d/99squash-live/squash-liveiso-genrules.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/squash-liveiso-genrules.sh 2014-04-16 17:01:00.492528268 +0200
@@ -0,0 +1,14 @@
diff -Nru dracut-043.orig/modules.d/99squash-live/squash-live-root.sh dracut-043/modules.d/99squash-live/squash-live-root.sh
--- dracut-043.orig/modules.d/99squash-live/squash-live-root.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/squash-live-root.sh 2015-11-12 16:22:57.150019442 +0100
@@ -0,0 +1,112 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+if [ "${root%%:*}" = "liveiso" ]; then
+ DEVLABEL=${root#liveiso:/}
+ DEVLABEL=${DEVLABEL%%/*}
+ {
+ printf 'ENV{ID_FS_LABEL}=="%s", RUN+="/bin/mkdir /%s", RUN+="/bin/mount /dev/%%k /%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root `/sbin/losetup -f --show %s` /%s"\n' \
+ ${DEVLABEL} ${DEVLABEL} ${DEVLABEL} ${root#liveiso:} ${DEVLABEL}
+# printf 'KERNEL=="loop-control", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root `/sbin/losetup -f --show %s` /%s"\n' \
+# ${root#liveiso:} ${DEVLABEL}
+ } >> /etc/udev/rules.d/99-liveiso-mount.rules
+ echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh
+fi
diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-root.sh dracut-037/modules.d/99squash-live/squash-live-root.sh
--- dracut-037.orig/modules.d/99squash-live/squash-live-root.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-037/modules.d/99squash-live/squash-live-root.sh 2014-04-16 17:01:00.492528268 +0200
@@ -0,0 +1,107 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
@ -179,20 +243,25 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-root.sh dracut-037
+getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
+overlay=$(getarg rd.live.overlay -d overlay)
+
+# FIXME: we need to be able to hide the plymouth splash for the check really
+# CD/DVD media check
+[ -b $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
+if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
+ check="yes"
+fi
+getarg rd.live.check -d check || check=""
+if [ -n "$check" ]; then
+ [ -x /bin/plymouth ] && /bin/plymouth --hide-splash
+ checkisomd5 --verbose $livedev
+ if [ $? -ne 0 ]; then
+ warn "CD check failed!"
+ action_on_fail "Could not boot."
+ type plymouth >/dev/null 2>&1 && plymouth --hide-splash
+ if [ -n "$DRACUT_SYSTEMD" ]; then
+ p=$(str_replace "$livedev" "-" '\x2d')
+ systemctl start checkisomd5@${p}.service
+ else
+ checkisomd5 --verbose $livedev
+ fi
+ [ -x /bin/plymouth ] && /bin/plymouth --show-splash
+ if [ $? -eq 1 ]; then
+ die "CD check failed!"
+ exit 1
+ fi
+ type plymouth >/dev/null 2>&1 && plymouth --show-splash
+fi
+
+ln -s $livedev /run/initramfs/livedev
@ -232,14 +301,16 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-root.sh dracut-037
+ echo "Creating ramdisk (dinamic size=${RAMSIZE}k) using /dev/shm..."
+ mkdir -p /ramfs
+ mount -t tmpfs tmpfs /ramfs -o mode=755
+ echo "Mounting overlayfs using ramdisk"
+ mount -t overlayfs -o lowerdir=/squashfs,upperdir=/ramfs overlayfs ${NEWROOT}
+ mkdir /ramfs/upper /ramfs/work
+ echo "Mounting overlay using ramdisk"
+ mount -t overlay -o lowerdir=/squashfs,upperdir=/ramfs/upper,workdir=/ramfs/work overlay ${NEWROOT}
+ mkdir -p ${NEWROOT}/ramfs
+ mount -n -o bind /ramfs ${NEWROOT}/ramfs
+ else
+ echo "Mounting overlayfs using /${DEVLABEL}/rwroot"
+ echo "Mounting overlay using /${DEVLABEL}/rwroot"
+ mkdir -p /${DEVLABEL}/rwroot
+ mount -t overlayfs -o lowerdir=/squashfs,upperdir=/${DEVLABEL}/rwroot overlayfs ${NEWROOT}
+ mkdir -p /${DEVLABEL}/rwwork
+ mount -t overlay -o lowerdir=/squashfs,upperdir=/${DEVLABEL}/rwroot,workdir=/${DEVLABEL}/rwwork overlay ${NEWROOT}
+ mkdir -p ${NEWROOT}/flash
+ mount -n -o bind /${DEVLABEL} ${NEWROOT}/flash
+ fi
@ -257,3 +328,21 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-root.sh dracut-037
+printf '# already mounted' > $hookdir/mount/01-$$-live.sh
+
+exit 0
diff -Nru dracut-043.orig/modules.d/99squash-live/squash-liveiso-genrules.sh dracut-043/modules.d/99squash-live/squash-liveiso-genrules.sh
--- dracut-043.orig/modules.d/99squash-live/squash-liveiso-genrules.sh 1970-01-01 01:00:00.000000000 +0100
+++ dracut-043/modules.d/99squash-live/squash-liveiso-genrules.sh 2015-11-12 15:42:07.546276928 +0100
@@ -0,0 +1,14 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+if [ "${root%%:*}" = "liveiso" ]; then
+ DEVLABEL=${root#liveiso:/}
+ DEVLABEL=${DEVLABEL%%/*}
+ {
+ printf 'ENV{ID_FS_LABEL}=="%s", RUN+="/bin/mkdir /%s", RUN+="/bin/mount /dev/%%k /%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root `/sbin/losetup -f --show %s` /%s"\n' \
+ ${DEVLABEL} ${DEVLABEL} ${DEVLABEL} ${root#liveiso:} ${DEVLABEL}
+# printf 'KERNEL=="loop-control", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root `/sbin/losetup -f --show %s` /%s"\n' \
+# ${root#liveiso:} ${DEVLABEL}
+ } >> /etc/udev/rules.d/99-liveiso-mount.rules
+ echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh
+fi

View File

@ -1,6 +1,6 @@
Name: dracut
Version: 043
Release: 1mamba
Release: 2mamba
Summary: Generic, modular initramfs generation tool that can be used across various distributions
Group: System/Kernel and Hardware
Vendor: openmamba
@ -11,7 +11,7 @@ Source: http://ftp.kernel.org/pub/linux/utils/boot/dracut/dracut-%{versio
Source1: dracut-openmamba.conf
Source2: dracut-openmamba.png
Patch0: %{name}-020-openmamba_logo_release.patch
Patch5: %{name}-037-squash-overlayfs-live-openmamba.patch
Patch5: %{name}-043-squash-overlayfs-live-openmamba.patch
Patch6: %{name}-037-mkinitrd-hostonly.patch
Patch8: %{name}-037-fix_devpts_gid.patch
Patch10: %{name}-037-i18n_install_locale-archive.patch
@ -357,6 +357,9 @@ fi
#%doc NEWS README README.generic README.kernel README.modules TODO
%changelog
* Thu Nov 12 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 043-2mamba
- squash-live: add system generator to fix sysroot.mount problem and other changes ported from dmsquash-live
* Sat Aug 15 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 043-1mamba
- update to 043