Fix patch offsets for quilt patches
[live-boot-grml.git] / debian / patches / 07_support_findiso.patch
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 --- a/scripts/live
14 +++ b/scripts/live
15 @@ -106,6 +106,11 @@
16                                 export FETCH
17                                 ;;
18  
19 +                       findiso=*)
20 +                               FINDISO="${ARGUMENT#findiso=}"
21 +                               export FINDISO
22 +                               ;;
23 +
24                         forcepersistentfsck)
25                                 FORCEPERSISTENTFSCK="Yes"
26                                 export FORCEPERSISTENTFSCK
27 @@ -1629,13 +1634,28 @@
28                 mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
29                 [ -n "$devuid" ] && echo "$devuid" >> $tried
30  
31 +               if [ -n "${FINDISO}" ]
32 +               then
33 +                       if [ -f ${mountpoint}/${FINDISO} ]
34 +                       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*" 0 "")
39 +                               devname="${loopdevname}"
40 +                               mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
41 +                       else
42 +                               umount ${mountpoint}
43 +                       fi
44 +               fi
45 +
46                 if is_live_path ${mountpoint} && \
47                         ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
48                 then
49                         echo ${mountpoint}
50                         return 0
51                 else
52 -                       umount ${mountpoint}
53 +                       umount ${mountpoint} 2>/dev/null
54                 fi
55         fi
56  
57 @@ -1933,6 +1953,22 @@
58         # when booting FAI, this simple workaround solves it
59         ls /root/* >/dev/null 2>&1
60  
61 +       # Move findiso directory to the new root filesystem so that programs there can get at it.
62 +       if [ -d /live/findiso -a ! -d /root/live/findiso ]
63 +       then
64 +               mkdir -p /root/live/findiso
65 +               mount -n --move /live/findiso /root/live/findiso
66 +       fi
67 +
68 +       # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
69 +       # because the mountpoint is left behind in /proc/mounts, so let's get
70 +       # rid of it when running from RAM
71 +       if [ -n "$FINDISO" ] && [ "${TORAM}" ]
72 +       then
73 +               losetup -d /dev/loop0
74 +               grep -q /live/findiso /proc/mounts && umount /root/live/findiso
75 +       fi
76 +
77         # copy snapshot configuration if exists
78         if [ -f snapshot.conf ]
79         then