Blob Blame History Raw
From 14499534ba9694591bbcf8741ba7e3a66d71e2d3 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Mon, 15 Apr 2013 11:39:32 +0200
Subject: [PATCH] dmsquash-live: add support for "iso-scan/filename" kernel
 parameter

now you can write grub entries like

  set isofile="/Fedora-live.iso"
  loopback loop $isofile
  linux loop)/isolinux/vmlinuz iso-scan/filename=$isofile root=live:CDLABEL=Fedora-...
  initrd (loop)/isolinux/initrd0.img
---
 modules.d/90dmsquash-live/iso-scan.sh       | 25 +++++++++++++++++++++++++
 modules.d/90dmsquash-live/module-setup.sh   |  2 ++
 modules.d/90dmsquash-live/parse-iso-scan.sh | 14 ++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100755 modules.d/90dmsquash-live/iso-scan.sh
 create mode 100755 modules.d/90dmsquash-live/parse-iso-scan.sh

diff --git a/modules.d/90dmsquash-live/iso-scan.sh b/modules.d/90dmsquash-live/iso-scan.sh
new file mode 100755
index 0000000..9300d12
--- /dev/null
+++ b/modules.d/90dmsquash-live/iso-scan.sh
@@ -0,0 +1,25 @@
+#!/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
+
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+
+isofile=$1
+
+[ -z "$isofile" ] && exit 1
+
+mkdir -p "/run/initramfs/isoscan"
+for dev in /dev/disk/by-uuid/*; do
+    mount -t auto -o ro "$dev" "/run/initramfs/isoscan" || continue
+    if [ -f "/run/initramfs/isoscan/$isofile" ]; then
+        losetup -f "/run/initramfs/isoscan/$isofile"
+        exit 0
+    else
+        umount "/run/initramfs/isoscan"
+    fi
+done
+
+rmdir "/run/initramfs/isoscan"
+exit 1
diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh
index 76358da..5b283d1 100755
--- a/modules.d/90dmsquash-live/module-setup.sh
+++ b/modules.d/90dmsquash-live/module-setup.sh
@@ -23,10 +23,12 @@ install() {
     dracut_install umount dmsetup blkid dd losetup grep blockdev
     dracut_install -o checkisomd5
     inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
+    inst_hook cmdline 31 "$moddir/parse-iso-scan.sh"
     inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
     inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
     inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
     inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-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"
diff --git a/modules.d/90dmsquash-live/parse-iso-scan.sh b/modules.d/90dmsquash-live/parse-iso-scan.sh
new file mode 100755
index 0000000..be071fd
--- /dev/null
+++ b/modules.d/90dmsquash-live/parse-iso-scan.sh
@@ -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
+# live images are specified with
+# root=live:backingdev
+
+isofile=$(getarg iso-scan/filename)
+
+if [ -n "$isofile" ]; then
+    {
+        printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/iso-scan %s"\n' \
+            "'${isofile}'"
+    } >> /etc/udev/rules.d/99-isofile-mount.rules
+fi