Blame 0025-dmsquash-live-add-support-for-iso-scan-filename-kern.patch

Harald Hoyer e787af
From 14499534ba9694591bbcf8741ba7e3a66d71e2d3 Mon Sep 17 00:00:00 2001
Harald Hoyer e787af
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer e787af
Date: Mon, 15 Apr 2013 11:39:32 +0200
Harald Hoyer e787af
Subject: [PATCH] dmsquash-live: add support for "iso-scan/filename" kernel
Harald Hoyer e787af
 parameter
Harald Hoyer e787af
Harald Hoyer e787af
now you can write grub entries like
Harald Hoyer e787af
Harald Hoyer e787af
  set isofile="/Fedora-live.iso"
Harald Hoyer e787af
  loopback loop $isofile
Harald Hoyer e787af
  linux loop)/isolinux/vmlinuz iso-scan/filename=$isofile root=live:CDLABEL=Fedora-...
Harald Hoyer e787af
  initrd (loop)/isolinux/initrd0.img
Harald Hoyer e787af
---
Harald Hoyer e787af
 modules.d/90dmsquash-live/iso-scan.sh       | 25 +++++++++++++++++++++++++
Harald Hoyer e787af
 modules.d/90dmsquash-live/module-setup.sh   |  2 ++
Harald Hoyer e787af
 modules.d/90dmsquash-live/parse-iso-scan.sh | 14 ++++++++++++++
Harald Hoyer e787af
 3 files changed, 41 insertions(+)
Harald Hoyer e787af
 create mode 100755 modules.d/90dmsquash-live/iso-scan.sh
Harald Hoyer e787af
 create mode 100755 modules.d/90dmsquash-live/parse-iso-scan.sh
Harald Hoyer e787af
Harald Hoyer e787af
diff --git a/modules.d/90dmsquash-live/iso-scan.sh b/modules.d/90dmsquash-live/iso-scan.sh
Harald Hoyer e787af
new file mode 100755
Harald Hoyer e787af
index 0000000..9300d12
Harald Hoyer e787af
--- /dev/null
Harald Hoyer e787af
+++ b/modules.d/90dmsquash-live/iso-scan.sh
Harald Hoyer e787af
@@ -0,0 +1,25 @@
Harald Hoyer e787af
+#!/bin/sh
Harald Hoyer e787af
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer e787af
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer e787af
+
Harald Hoyer e787af
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
Harald Hoyer e787af
+
Harald Hoyer e787af
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
Harald Hoyer e787af
+
Harald Hoyer e787af
+isofile=$1
Harald Hoyer e787af
+
Harald Hoyer e787af
+[ -z "$isofile" ] && exit 1
Harald Hoyer e787af
+
Harald Hoyer e787af
+mkdir -p "/run/initramfs/isoscan"
Harald Hoyer e787af
+for dev in /dev/disk/by-uuid/*; do
Harald Hoyer e787af
+    mount -t auto -o ro "$dev" "/run/initramfs/isoscan" || continue
Harald Hoyer e787af
+    if [ -f "/run/initramfs/isoscan/$isofile" ]; then
Harald Hoyer e787af
+        losetup -f "/run/initramfs/isoscan/$isofile"
Harald Hoyer e787af
+        exit 0
Harald Hoyer e787af
+    else
Harald Hoyer e787af
+        umount "/run/initramfs/isoscan"
Harald Hoyer e787af
+    fi
Harald Hoyer e787af
+done
Harald Hoyer e787af
+
Harald Hoyer e787af
+rmdir "/run/initramfs/isoscan"
Harald Hoyer e787af
+exit 1
Harald Hoyer e787af
diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh
Harald Hoyer e787af
index 76358da..5b283d1 100755
Harald Hoyer e787af
--- a/modules.d/90dmsquash-live/module-setup.sh
Harald Hoyer e787af
+++ b/modules.d/90dmsquash-live/module-setup.sh
Harald Hoyer e787af
@@ -23,10 +23,12 @@ install() {
Harald Hoyer e787af
     dracut_install umount dmsetup blkid dd losetup grep blockdev
Harald Hoyer e787af
     dracut_install -o checkisomd5
Harald Hoyer e787af
     inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
Harald Hoyer e787af
+    inst_hook cmdline 31 "$moddir/parse-iso-scan.sh"
Harald Hoyer e787af
     inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
Harald Hoyer e787af
     inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
Harald Hoyer e787af
     inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
Harald Hoyer e787af
     inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
Harald Hoyer e787af
+    inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
Harald Hoyer e787af
     # should probably just be generally included
Harald Hoyer e787af
     inst_rules 60-cdrom_id.rules
Harald Hoyer e787af
     inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
Harald Hoyer e787af
diff --git a/modules.d/90dmsquash-live/parse-iso-scan.sh b/modules.d/90dmsquash-live/parse-iso-scan.sh
Harald Hoyer e787af
new file mode 100755
Harald Hoyer e787af
index 0000000..be071fd
Harald Hoyer e787af
--- /dev/null
Harald Hoyer e787af
+++ b/modules.d/90dmsquash-live/parse-iso-scan.sh
Harald Hoyer e787af
@@ -0,0 +1,14 @@
Harald Hoyer e787af
+#!/bin/sh
Harald Hoyer e787af
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer e787af
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer e787af
+# live images are specified with
Harald Hoyer e787af
+# root=live:backingdev
Harald Hoyer e787af
+
Harald Hoyer e787af
+isofile=$(getarg iso-scan/filename)
Harald Hoyer e787af
+
Harald Hoyer e787af
+if [ -n "$isofile" ]; then
Harald Hoyer e787af
+    {
Harald Hoyer e787af
+        printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/iso-scan %s"\n' \
Harald Hoyer e787af
+            "'${isofile}'"
Harald Hoyer e787af
+    } >> /etc/udev/rules.d/99-isofile-mount.rules
Harald Hoyer e787af
+fi