Do not support raw images on block devices. This is too unreliable for robust booting.
[live-initramfs-grml.git] / debian / patches / 12_uuid_support.dpatch
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 diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' live-initramfs-grml~/scripts/live live-initramfs-grml/scripts/live
16 --- live-initramfs-grml~/scripts/live   2010-05-27 23:42:10.129873950 +0200
17 +++ live-initramfs-grml/scripts/live    2010-05-27 23:43:46.209031380 +0200
18 @@ -85,6 +85,12 @@
19                                 export ACCESS
20                                 ;;
21  
22 +                       bootid=*)
23 +                               BOOTID="${ARGUMENT#bootid=}"
24 +                               export BOOTID
25 +                               ;;
26 +
27 +
28                         console=*)
29                                 DEFCONSOLE="${ARGUMENT#*=}"
30                                 export DEFCONSOLE
31 @@ -165,6 +171,11 @@
32                                 export USERFULLNAME LIVECONF
33                                 ;;
34  
35 +                       ignore_bootid)
36 +                               IGNORE_BOOTID="Yes"
37 +                               export IGNORE_BOOTID
38 +                               ;;
39 +
40                         ignore_uuid)
41                                 IGNORE_UUID="Yes"
42                                 export IGNORE_UUID
43 @@ -597,6 +608,41 @@
44         return 1
45  }
46  
47 +grml_match_bootid()
48 +{
49 +       path="$1"
50 +
51 +       if [ -n "$IGNORE_BOOTID" ] ; then
52 +               echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/live.log
53 +               return 0
54 +       fi
55 +
56 +       if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
57 +               echo "  * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/live.log
58 +               return 1
59 +       fi
60 +
61 +       [ -r "${path}/conf/bootid.txt" ] || return 0
62 +
63 +       bootid_conf=$(cat "${path}/conf/bootid.txt")
64 +
65 +       if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
66 +       then
67 +               echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/live.log
68 +               return 1
69 +       fi
70 +
71 +       if [ "$BOOTID" = "$bootid_conf" ]
72 +       then
73 +               echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/live.log
74 +       else
75 +               echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/live.log
76 +               return 1
77 +       fi
78 +
79 +       return 0
80 +}
81 +
82  matches_uuid ()
83  {
84         if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
85 @@ -1616,7 +1662,7 @@
86                 fi
87  
88                 if is_live_path ${mountpoint} && \
89 -                       ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
90 +                       ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
91                 then
92                         echo ${mountpoint}
93                         return 0
94 @@ -1731,18 +1777,6 @@
95                                         return 0
96                                 fi
97                         done
98 -               elif [ "${fstype}" = "squashfs" -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-initramfs, 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