ed5191603b1549ad3ffde72c3c835eedd52713f3
[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/boot/9990-misc-helpers.sh
16 +++ b/scripts/boot/9990-misc-helpers.sh
17 @@ -20,6 +20,42 @@
18         return 1
19  }
20  
21 +grml_match_bootid()
22 +{
23 +       path="$1"
24 +
25 +       if [ -n "$IGNORE_BOOTID" ] ; then
26 +               echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/live-boot.log
27 +               return 0
28 +       fi
29 +
30 +       if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
31 +               echo "  * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/live-boot.log
32 +               return 1
33 +       fi
34 +
35 +       [ -r "${path}/conf/bootid.txt" ] || return 0
36 +
37 +       bootid_conf=$(cat "${path}/conf/bootid.txt")
38 +
39 +       if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
40 +       then
41 +               echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/live-boot.log
42 +               return 1
43 +       fi
44 +
45 +       if [ "$BOOTID" = "$bootid_conf" ]
46 +       then
47 +               echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/live-boot.log
48 +       else
49 +               echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/live-boot.log
50 +               return 1
51 +       fi
52 +
53 +       return 0
54 +}
55 +
56 +
57  matches_uuid ()
58  {
59         if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
60 @@ -247,7 +283,7 @@
61                 fi
62  
63                 if is_live_path ${mountpoint} && \
64 -                       ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
65 +                       ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
66                 then
67                         echo ${mountpoint}
68                         return 0
69 @@ -343,19 +379,6 @@
70                                         return 0
71                                 fi
72                         done
73 -               elif [ "${fstype}" = "squashfs" -o \
74 -                       "${fstype}" = "btrfs" -o \
75 -                       "${fstype}" = "ext2" -o \
76 -                       "${fstype}" = "ext3" -o \
77 -                       "${fstype}" = "ext4" -o \
78 -                       "${fstype}" = "jffs2" ]
79 -               then
80 -                       # This is an ugly hack situation, the block device has
81 -                       # an image directly on it.  It's hopefully
82 -                       # live-boot, so take it and run with it.
83 -                       ln -s "${devname}" "${devname}.${fstype}"
84 -                       echo "${devname}.${fstype}"
85 -                       return 0
86                 fi
87         done
88  
89 --- a/scripts/boot/9990-cmdline-old
90 +++ b/scripts/boot/9990-cmdline-old
91 @@ -18,6 +18,11 @@
92                                 BOOTIF="${x#BOOTIF=}"
93                                 ;;
94  
95 +                       bootid=*)
96 +                               BOOTID="${_PARAMETER#bootid=}"
97 +                               export BOOTID
98 +                               ;;
99 +
100                         dhcp)
101                                 # Force dhcp even while netbooting
102                                 # Use for debugging in case somebody works on fixing dhclient
103 @@ -79,6 +84,11 @@
104                                 export FROMISO
105                                 ;;
106  
107 +                       ignore_bootid)
108 +                               IGNORE_BOOTID="Yes"
109 +                               export IGNORE_BOOTID
110 +                               ;;
111 +
112                         ignore_uuid)
113                                 IGNORE_UUID="true"
114                                 export IGNORE_UUID