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 diff -Nru dracut-043.orig/modules.d/99squash-live/apply-live-updates.sh dracut-043/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-043.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 +++ dracut-043/modules.d/99squash-live/apply-live-updates.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,17 @@ @@ -0,0 +1,20 @@
+#!/bin/sh +#!/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..." + info "Applying updates to live image..."
+ mount -o bind /run $NEWROOT/run + mount -o bind /run $NEWROOT/run
+ # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories + # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories
+ ( + for d in /updates /run/initramfs/live/updates; do
+ cd /updates + [ -d "$d" ] || continue
+ find . -depth -type d | while read dir; do + (
+ mkdir -p "$NEWROOT/$dir" + cd $d
+ done + find . -depth -type d | while read dir; do
+ find . -depth \! -type d | while read file; do + mkdir -p "$NEWROOT/$dir"
+ cp -a "$file" "$NEWROOT/$file" + done
+ done + find . -depth \! -type d | while read file; do
+ ) + cp -a "$file" "$NEWROOT/$file"
+ done
+ )
+ done
+ umount $NEWROOT/run + umount $NEWROOT/run
+fi +fi
diff -Nru dracut-037.orig/modules.d/99squash-live/module-setup.sh dracut-037/modules.d/99squash-live/module-setup.sh diff -Nru dracut-043.orig/modules.d/99squash-live/checkisomd5@.service dracut-043/modules.d/99squash-live/checkisomd5@.service
--- dracut-037.orig/modules.d/99squash-live/module-setup.sh 1970-01-01 01:00:00.000000000 +0100 --- dracut-043.orig/modules.d/99squash-live/checkisomd5@.service 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 +++ dracut-043/modules.d/99squash-live/checkisomd5@.service 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,31 @@ @@ -0,0 +1,14 @@
+#!/bin/bash +[Unit]
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +Description=Media check on %f
+# ex: ts=8 sw=4 sts=4 et filetype=sh +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() { +check() {
+ # a live host-only image doesn't really make a lot of sense + # a live host-only image doesn't really make a lot of sense
+ [[ $hostonly ]] && return 1 + [[ $hostonly ]] && return 1
@ -38,26 +98,43 @@ diff -Nru dracut-037.orig/modules.d/99squash-live/module-setup.sh dracut-037/mod
+} +}
+ +
+installkernel() { +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() { +install() {
+ dracut_install umount dmsetup blkid dd losetup grep blockdev + inst_multiple umount dmsetup blkid dd losetup grep blockdev find
+ dracut_install -o checkisomd5 + inst_multiple -o checkisomd5
+ inst_hook cmdline 30 "$moddir/parse-squash-live.sh" + 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-live-genrules.sh"
+ inst_hook pre-udev 30 "$moddir/squash-liveiso-genrules.sh" + inst_hook pre-udev 30 "$moddir/squash-liveiso-genrules.sh"
+ inst_hook pre-pivot 20 "$moddir/apply-live-updates.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/squash-live-root.sh" "/sbin/squash-live-root"
+ inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
+ # should probably just be generally included + # should probably just be generally included
+ inst_rules 60-cdrom_id.rules + 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 + # 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 + 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 diff -Nru dracut-043.orig/modules.d/99squash-live/parse-iso-scan.sh dracut-043/modules.d/99squash-live/parse-iso-scan.sh
--- dracut-037.orig/modules.d/99squash-live/parse-squash-live.sh 1970-01-01 01:00:00.000000000 +0100 --- dracut-043.orig/modules.d/99squash-live/parse-iso-scan.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 +++ dracut-043/modules.d/99squash-live/parse-iso-scan.sh 2015-11-12 15:42:07.545276936 +0100
@@ -0,0 +1,50 @@ @@ -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 +#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh +# 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="${root#live:}"
+ root="live:/dev/disk/by-uuid/${root#UUID=}" + root="live:/dev/disk/by-uuid/${root#UUID=}"
+ rootok=1 ;; + 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]) + live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
+ root="${root#live:}" + root="${root#live:}"
+ root="liveiso:${root}" + 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 +# make sure that init doesn't complain
+[ -z "$root" ] && root="live" +[ -z "$root" ] && root="live"
+ diff -Nru dracut-043.orig/modules.d/99squash-live/squash-live-genrules.sh dracut-043/modules.d/99squash-live/squash-live-genrules.sh
diff -Nru dracut-037.orig/modules.d/99squash-live/squash-live-genrules.sh dracut-037/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-037.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
+++ dracut-037/modules.d/99squash-live/squash-live-genrules.sh 2014-04-16 17:01:00.492528268 +0200
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
+#!/bin/sh +#!/bin/sh
+if [ "${root%%:*}" = "live" ]; then +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 + } >> /etc/udev/rules.d/99-live-squash.rules
+ echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh + echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh
+fi +fi
diff -Nru dracut-037.orig/modules.d/99squash-live/squash-liveiso-genrules.sh dracut-037/modules.d/99squash-live/squash-liveiso-genrules.sh diff -Nru dracut-043.orig/modules.d/99squash-live/squash-live-root.sh dracut-043/modules.d/99squash-live/squash-live-root.sh
--- dracut-037.orig/modules.d/99squash-live/squash-liveiso-genrules.sh 1970-01-01 01:00:00.000000000 +0100 --- dracut-043.orig/modules.d/99squash-live/squash-live-root.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 +++ dracut-043/modules.d/99squash-live/squash-live-root.sh 2015-11-12 16:22:57.150019442 +0100
@@ -0,0 +1,14 @@ @@ -0,0 +1,112 @@
+#!/bin/sh +#!/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 +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="" +getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
+overlay=$(getarg rd.live.overlay -d 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) +[ -b $livedev ] && fs=$(blkid -s TYPE -o value $livedev)
+if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then +if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
+ check="yes" + check="yes"
+fi +fi
+getarg rd.live.check -d check || check="" +getarg rd.live.check -d check || check=""
+if [ -n "$check" ]; then +if [ -n "$check" ]; then
+ [ -x /bin/plymouth ] && /bin/plymouth --hide-splash + type plymouth >/dev/null 2>&1 && plymouth --hide-splash
+ checkisomd5 --verbose $livedev + if [ -n "$DRACUT_SYSTEMD" ]; then
+ if [ $? -ne 0 ]; then + p=$(str_replace "$livedev" "-" '\x2d')
+ warn "CD check failed!" + systemctl start checkisomd5@${p}.service
+ action_on_fail "Could not boot." + else
+ checkisomd5 --verbose $livedev
+ fi + 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 +fi
+ +
+ln -s $livedev /run/initramfs/livedev +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..." + echo "Creating ramdisk (dinamic size=${RAMSIZE}k) using /dev/shm..."
+ mkdir -p /ramfs + mkdir -p /ramfs
+ mount -t tmpfs tmpfs /ramfs -o mode=755 + mount -t tmpfs tmpfs /ramfs -o mode=755
+ echo "Mounting overlayfs using ramdisk" + mkdir /ramfs/upper /ramfs/work
+ mount -t overlayfs -o lowerdir=/squashfs,upperdir=/ramfs overlayfs ${NEWROOT} + echo "Mounting overlay using ramdisk"
+ mount -t overlay -o lowerdir=/squashfs,upperdir=/ramfs/upper,workdir=/ramfs/work overlay ${NEWROOT}
+ mkdir -p ${NEWROOT}/ramfs + mkdir -p ${NEWROOT}/ramfs
+ mount -n -o bind /ramfs ${NEWROOT}/ramfs + mount -n -o bind /ramfs ${NEWROOT}/ramfs
+ else + else
+ echo "Mounting overlayfs using /${DEVLABEL}/rwroot" + echo "Mounting overlay using /${DEVLABEL}/rwroot"
+ mkdir -p /${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 + mkdir -p ${NEWROOT}/flash
+ mount -n -o bind /${DEVLABEL} ${NEWROOT}/flash + mount -n -o bind /${DEVLABEL} ${NEWROOT}/flash
+ fi + 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 +printf '# already mounted' > $hookdir/mount/01-$$-live.sh
+ +
+exit 0 +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 Name: dracut
Version: 043 Version: 043
Release: 1mamba Release: 2mamba
Summary: Generic, modular initramfs generation tool that can be used across various distributions Summary: Generic, modular initramfs generation tool that can be used across various distributions
Group: System/Kernel and Hardware Group: System/Kernel and Hardware
Vendor: openmamba Vendor: openmamba
@ -11,7 +11,7 @@ Source: http://ftp.kernel.org/pub/linux/utils/boot/dracut/dracut-%{versio
Source1: dracut-openmamba.conf Source1: dracut-openmamba.conf
Source2: dracut-openmamba.png Source2: dracut-openmamba.png
Patch0: %{name}-020-openmamba_logo_release.patch 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 Patch6: %{name}-037-mkinitrd-hostonly.patch
Patch8: %{name}-037-fix_devpts_gid.patch Patch8: %{name}-037-fix_devpts_gid.patch
Patch10: %{name}-037-i18n_install_locale-archive.patch Patch10: %{name}-037-i18n_install_locale-archive.patch
@ -357,6 +357,9 @@ fi
#%doc NEWS README README.generic README.kernel README.modules TODO #%doc NEWS README README.generic README.kernel README.modules TODO
%changelog %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 * Sat Aug 15 2015 Silvan Calarco <silvan.calarco@mambasoft.it> 043-1mamba
- update to 043 - update to 043