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