Explicit specify offset parameter for setup_loop [Closes: issue1003]
[live-boot-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_2010.05.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 --git a/scripts/live b/scripts/live
14 index d79beed..04ad61e 100755
15 --- a/scripts/live
16 +++ b/scripts/live
17 @@ -102,6 +102,11 @@ Arguments ()
18                                  export FETCH
19                                  ;;
20  
21 +                       findiso=*)
22 +                               FINDISO="${ARGUMENT#findiso=}"
23 +                               export FINDISO
24 +                               ;;
25 +
26                         forcepersistentfsck)
27                                 FORCEPERSISTENTFSCK="Yes"
28                                 export FORCEPERSISTENTFSCK
29 @@ -1526,6 +1531,19 @@ check_dev ()
30                 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
31                 [ -n "$devuid" ] && echo "$devuid" >> $tried
32  
33 +               if [ -n "${FINDISO}" ]
34 +               then
35 +                       if [ -f ${mountpoint}/${FINDISO} ]
36 +                       then
37 +                               umount ${mountpoint}
38 +                               mkdir /live/findiso -p
39 +                               mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
40 +                               loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
41 +                               devname="${loopdevname}"
42 +                               mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
43 +                       fi
44 +               fi
45 +
46                 if is_live_path ${mountpoint} && \
47                         ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
48                 then
49 diff --git a/scripts/live b/scripts/live
50 index d79beed..d19a5c5 100755
51 --- a/scripts/live
52 +++ b/scripts/live
53 @@ -1831,6 +1831,22 @@ mountroot ()
54         # when booting FAI, this simple workaround solves it
55         ls /root/* >/dev/null 2>&1
56  
57 +       # Move findiso directory to the new root filesystem so that programs there can get at it.
58 +       if [ -d /live/findiso -a ! -d /root/live/findiso ]
59 +       then
60 +               mkdir -p /root/live/findiso
61 +               mount -n --move /live/findiso /root/live/findiso
62 +       fi
63 +
64 +       # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
65 +       # because the mountpoint is left behind in /proc/mounts, so let's get
66 +       # rid of it when running from RAM
67 +       if [ -n "$FINDISO" ] && [ "${TORAM}" ]
68 +       then
69 +               losetup -d /dev/loop0
70 +               grep -q /live/findiso /proc/mounts && umount /root/live/findiso
71 +       fi
72 +
73         # copy snapshot configuration if exists
74         if [ -f snapshot.conf ]
75         then