Fix patch offsets for quilt patches
[live-boot-grml.git] / debian / patches / 12_uuid_support.patch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 12_uuid_support.dpatch by Michael Prokop <prokop@grml-forensic.org>
3 ##
4 ## DP: This patch enables support for verifying the ISO through bootid=.... bootoption.
5 ## DP: Logic behind bootoptions and possible combinations:
6 ## DP: * bootid.txt + wrong bootid=...                    => fails to boot
7 ## DP: * bootid.txt + right bootid=...                    => boots
8 ## DP: * bootid.txt + ignore_bootid                       => boots
9 ## DP: * bootid.txt + no bootid=... + no ignore_bootid    => fails to boot
10 ## DP: * no bootid.txt + no bootid=... + no ignore_bootid => boots
11 ## DP: * no bootid.txt + bootid=...                       => fails to boot
12 ## DP: * no bootid.txt + ignore_bootid=...                => boots
13
14 @DPATCH@
15 --- a/scripts/live
16 +++ b/scripts/live
17 @@ -63,6 +63,11 @@
18                                 export ACCESS
19                                 ;;
20  
21 +                       bootid=*)
22 +                               BOOTID="${ARGUMENT#bootid=}"
23 +                               export BOOTID
24 +                               ;;
25 +
26                         console=*)
27                                 DEFCONSOLE="${ARGUMENT#*=}"
28                                 export DEFCONSOLE
29 @@ -144,6 +149,11 @@
30                                 export FROMISO
31                                 ;;
32  
33 +                       ignore_bootid)
34 +                               IGNORE_BOOTID="Yes"
35 +                               export IGNORE_BOOTID
36 +                               ;;
37 +
38                         ignore_uuid)
39                                 IGNORE_UUID="Yes"
40                                 export IGNORE_UUID
41 @@ -410,6 +420,42 @@
42         return 1
43  }
44  
45 +grml_match_bootid()
46 +{
47 +       path="$1"
48 +
49 +       if [ -n "$IGNORE_BOOTID" ] ; then
50 +               echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/live-boot.log
51 +               return 0
52 +       fi
53 +
54 +       if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
55 +               echo "  * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/live-boot.log
56 +               return 1
57 +       fi
58 +
59 +       [ -r "${path}/conf/bootid.txt" ] || return 0
60 +
61 +       bootid_conf=$(cat "${path}/conf/bootid.txt")
62 +
63 +       if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
64 +       then
65 +               echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/live-boot.log
66 +               return 1
67 +       fi
68 +
69 +       if [ "$BOOTID" = "$bootid_conf" ]
70 +       then
71 +               echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/live-boot.log
72 +       else
73 +               echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/live-boot.log
74 +               return 1
75 +       fi
76 +
77 +       return 0
78 +}
79 +
80 +
81  matches_uuid ()
82  {
83         if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
84 @@ -1655,7 +1701,7 @@
85                 fi
86  
87                 if is_live_path ${mountpoint} && \
88 -                       ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
89 +                       ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
90                 then
91                         echo ${mountpoint}
92                         return 0
93 @@ -1769,19 +1815,6 @@
94                                         return 0
95                                 fi
96                         done
97 -               elif [ "${fstype}" = "squashfs" -o \
98 -                       "${fstype}" = "btrfs" -o \
99 -                       "${fstype}" = "ext2" -o \
100 -                       "${fstype}" = "ext3" -o \
101 -                       "${fstype}" = "ext4" -o \
102 -                       "${fstype}" = "jffs2" ]
103 -               then
104 -                       # This is an ugly hack situation, the block device has
105 -                       # an image directly on it.  It's hopefully
106 -                       # live-boot, so take it and run with it.
107 -                       ln -s "${devname}" "${devname}.${fstype}"
108 -                       echo "${devname}.${fstype}"
109 -                       return 0
110                 fi
111         done
112