1375666d2a87676c50c7c961ff189fa3892c5f08
[live-initramfs-grml.git] / debian / patches / 07_support_findiso.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 07_support_findiso.dpatch by Michael Schierl <schierlm@gmx.de>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: support for findoiso bootoption
6 # When booting with findiso=/grml_2008.11.iso, it will look for
7 # that .iso file on all disks where it usually looks for the .squashfs
8 # file. When it is found, the disk containing the iso is read-only mounted
9 # as /live/findiso (and exposed there after boot completed). The squashfs
10 # file is searched inside that ISO file then.
11
12 @DPATCH@
13 diff -urNad live-initramfs-grml~/scripts/live live-initramfs-grml/scripts/live
14 --- live-initramfs-grml~/scripts/live   2009-01-12 15:42:17.752549464 +0100
15 +++ live-initramfs-grml/scripts/live    2009-01-12 15:42:20.323387590 +0100
16 @@ -92,6 +92,11 @@
17                                 export HOSTNAME LIVECONF
18                                 ;;
19  
20 +                       findiso=*)
21 +                               FINDISO="${ARGUMENT#findiso=}"
22 +                               export FINDISO
23 +                               ;;
24 +
25                         isofrom=*|fromiso=*)
26                                 FROMISO="${ARGUMENT#*=}"
27                                 export FROMISO
28 @@ -1385,6 +1390,17 @@
29         if is_supported_fs ${fstype}
30         then
31                 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
32 +               if [ -n "${FINDISO}" ]
33 +               then
34 +                       if [ -f ${mountpoint}/${FINDISO} ]; then
35 +                               umount ${mountpoint}
36 +                               mkdir /live/findiso -p
37 +                               mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
38 +                               loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" "" '')
39 +                               devname="${loopdevname}"
40 +                               mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
41 +                       fi
42 +               fi
43  
44                 if is_live_path ${mountpoint} && \
45                         ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
46 diff --git a/grml/05mountpoints b/grml/05mountpoints
47 index e2b07a4..6411171 100755
48 --- a/grml/05mountpoints
49 +++ b/grml/05mountpoints
50 @@ -38,4 +38,21 @@ if [ -n "$MOUNTED_ON" ] ; then
51     echo "   -> Mounted live system on $MOUNTED_ON">/dev/console
52  fi
53  
54 +# Move findiso directory to the new root filesystem so that programs there can get at it.
55 +if [ -d /live/findiso -a ! -d /root/live/findiso ]
56 +then
57 +       mkdir -p /root/live/findiso
58 +       mount -n --move /live/findiso /root/live/findiso
59 +fi
60 +
61 +# if we do not unmount the ISO we can't run "fsck /dev/ice" later on
62 +# because the mountpoint is left behind in /proc/mounts, so let's get
63 +# rid of it when running from RAM
64 +if [ -n "$FINDISO" ] && [ "${TORAM}" ]
65 +then
66 +  losetup -d /dev/loop0
67 +  grep -q /live/findiso /proc/mounts && umount /root/live/findiso
68 +fi
69 +
70 +
71  log_end_msg