349 lines
13 KiB
Diff
349 lines
13 KiB
Diff
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 [ -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
|
|
+ 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-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
|
|
+ return 0
|
|
+}
|
|
+
|
|
+depends() {
|
|
+ return 0
|
|
+}
|
|
+
|
|
+installkernel() {
|
|
+ instmods squashfs loop overlay overlayfs ehci-hcd ohci-hcd uhci-hcd xhci-hcd usb_storage iso9660
|
|
+}
|
|
+
|
|
+install() {
|
|
+ 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-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
|
|
+# live images are specified with
|
|
+# root=live:backingdev
|
|
+
|
|
+[ -z "$root" ] && root=$(getarg root=)
|
|
+
|
|
+# support legacy syntax of passing liveimg and then just the base root
|
|
+if getargbool 0 rd.live.image -d -y liveimg; then
|
|
+ liveroot="live:$root"
|
|
+fi
|
|
+
|
|
+if [ "${root%%:*}" = "live" ] ; then
|
|
+ liveroot=$root
|
|
+fi
|
|
+
|
|
+[ "${liveroot%%:*}" = "live" ] || return
|
|
+
|
|
+modprobe -q loop
|
|
+
|
|
+case "$liveroot" in
|
|
+ live:LABEL=*|LABEL=*) \
|
|
+ root="${root#live:}"
|
|
+ root="$(echo $root | sed 's,/,\\x2f,g')"
|
|
+ root="live:/dev/disk/by-label/${root#LABEL=}"
|
|
+ rootok=1 ;;
|
|
+ live:CDLABEL=*|CDLABEL=*) \
|
|
+ root="${root#live:}"
|
|
+ root="$(echo $root | sed 's,/,\\x2f,g')"
|
|
+ root="live:/dev/disk/by-label/${root#CDLABEL=}"
|
|
+ rootok=1 ;;
|
|
+ live:UUID=*|UUID=*) \
|
|
+ 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}"
|
|
+ rootok=1 ;;
|
|
+ live:/dev/*)
|
|
+ rootok=1 ;;
|
|
+ live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
|
|
+ [ -f "${root#live:}" ] && rootok=1 ;;
|
|
+esac
|
|
+info "root was $liveroot, is now $root"
|
|
+
|
|
+# make sure that init doesn't complain
|
|
+[ -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
|
|
--- 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
|
|
+ {
|
|
+ printf 'KERNEL=="%s", SYMLINK+="live"\n' \
|
|
+ ${root#live:/dev/}
|
|
+ printf 'SYMLINK=="%s", SYMLINK+="live"\n' \
|
|
+ ${root#live:/dev/}
|
|
+ } >> /etc/udev/rules.d/99-live-mount.rules
|
|
+ {
|
|
+ printf 'KERNEL=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root $env{DEVNAME}"\n' \
|
|
+ ${root#live:/dev/}
|
|
+ printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/squash-live-root $env{DEVNAME}"\n' \
|
|
+ ${root#live:/dev/}
|
|
+ } >> /etc/udev/rules.d/99-live-squash.rules
|
|
+ echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/squash.sh
|
|
+fi
|
|
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
|
|
+
|
|
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
|
+
|
|
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
+
|
|
+if getargbool 0 rd.live.debug -n -y rdlivedebug; then
|
|
+ exec > /tmp/liveroot.$$.out
|
|
+ exec 2>> /tmp/liveroot.$$.out
|
|
+ set -x
|
|
+fi
|
|
+
|
|
+[ -z "$1" ] && { warn "Missing livedvd from command line."; action_on_fail "Could not boot."; }
|
|
+livedev="$1"
|
|
+
|
|
+# With e.g. root=live:/openmamba_live/openmamba-live.iso DEVLABEL is /openmamba_live
|
|
+DEVLABEL="$2"
|
|
+
|
|
+# parse various live image specific options that make sense to be
|
|
+# specified as their own things
|
|
+live_dir=$(getarg rd.live.dir -d live_dir)
|
|
+[ -z "$live_dir" ] && live_dir="LiveOS"
|
|
+getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
|
|
+getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
|
|
+getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
|
|
+overlay=$(getarg rd.live.overlay -d overlay)
|
|
+
|
|
+# 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
|
|
+ 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
|
|
+ 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
|
|
+
|
|
+getarg ro && liverw=ro
|
|
+getarg rw && liverw=rw
|
|
+[ -z "$liverw" ] && liverw=ro
|
|
+
|
|
+# FIXME: loop to wait for partition to become available
|
|
+c=0
|
|
+while [ ! -e $livedev -a $c -lt 10 ]; do
|
|
+ echo "Device $livedev not ready; sleeping 1 second"
|
|
+ sleep 1
|
|
+ c=$(($c+1))
|
|
+done
|
|
+
|
|
+# mount the backing of the live image first
|
|
+mkdir /cdrom
|
|
+mount -n -t $fstype -o $liverw $livedev /cdrom
|
|
+RES=$?
|
|
+if [ "$RES" != "0" ]; then
|
|
+ warn "Failed to mount block device of live image"
|
|
+ action_on_fail "Could not boot."
|
|
+fi
|
|
+
|
|
+if [ -e /cdrom/${live_dir}/squashfs.img ]; then
|
|
+ SQUASHED="/cdrom/${live_dir}/squashfs.img"
|
|
+fi
|
|
+
|
|
+if [ -e "$SQUASHED" ] ; then
|
|
+ echo "Mounting compressed filesystem"
|
|
+ losetup -r /dev/loop1 $SQUASHED
|
|
+ mkdir -p /squashfs
|
|
+ mount -r -t squashfs /dev/loop1 /squashfs
|
|
+
|
|
+ if [ ! "${DEVLABEL}" -o "$live_ram" = "yes" ]; then
|
|
+ echo "Creating ramdisk (dinamic size=${RAMSIZE}k) using /dev/shm..."
|
|
+ mkdir -p /ramfs
|
|
+ mount -t tmpfs tmpfs /ramfs -o mode=755
|
|
+ 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 overlay using /${DEVLABEL}/rwroot"
|
|
+ mkdir -p /${DEVLABEL}/rwroot
|
|
+ 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
|
|
+ mkdir -p ${NEWROOT}/squashfs ${NEWROOT}/cdrom
|
|
+ mount -n -o bind /cdrom ${NEWROOT}/cdrom
|
|
+ mount -n -o bind /squashfs ${NEWROOT}/squashfs
|
|
+fi
|
|
+
|
|
+ROOTFLAGS="$(getarg rootflags)"
|
|
+if [ -n "$ROOTFLAGS" ]; then
|
|
+ ROOTFLAGS="-o $ROOTFLAGS"
|
|
+fi
|
|
+
|
|
+ln -s /dev/shm /dev/root
|
|
+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
|