4fb21fd4bbaaa1e89428d3ac60449781a9c8e987
[live-initramfs-grml.git] / debian / patches / 15_support_cciss_in_isofrom.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 15_support_cciss_in_isofrom.dpatch by Michael Prokop <mika@grml.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Support unusual device names like /dev/cciss/c0d0p1 in isofrom bootoption.
6
7 @DPATCH@
8 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
9 --- live-initramfs-grml~/scripts/live   2010-03-11 11:27:33.574467706 +0100
10 +++ live-initramfs-grml/scripts/live    2010-03-11 11:35:59.275256127 +0100
11 @@ -1537,12 +1537,30 @@
12         # support for fromiso=.../isofrom=....
13         if [ -n "$FROMISO" ]
14         then
15 -               mkdir /isofrom
16 -               ISO_DEVICE="$(echo $FROMISO | sed 's|\(/dev/[a-z]*[0-9]*\).*|\1|')"
17 -               mount "$ISO_DEVICE" /isofrom
18 -               ISO_NAME="$(echo $FROMISO | sed 's|/dev/[a-z]*[0-9]*/||')"
19 -               loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
20 -               devname="${loopdevname}"
21 +               ISO_DEVICE=$(dirname $FROMISO)
22 +               if ! [ -b $ISO_DEVICE ]
23 +               then
24 +                       # to support unusual device names like /dev/cciss/c0d0p1
25 +                       # as well we have to identify the block device name, let's
26 +                       # do that for up to 10 levels
27 +                       i=10
28 +                       while ! [ -b "$ISO_DEVICE" ] && [ -n "$ISO_DEVICE" ] && [ "$ISO_DEVICE" != "/dev" ] && [ "$i" -gt 0 ]
29 +                       do
30 +                               ISO_DEVICE=$(dirname ${ISO_DEVICE%/*})
31 +                               i=$(($i -1))
32 +                       done
33 +               fi
34 +               
35 +               if [ "$ISO_DEVICE" = "/dev" ]
36 +               then
37 +                       echo "Warning: specified device for bootoption isofrom= ($FROMISO) not found.">>/live.log
38 +               else
39 +                       mkdir /isofrom
40 +                       mount "$ISO_DEVICE" /isofrom
41 +                       ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
42 +                       loopdevname=$(setup_loop "/isofrom/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
43 +                       devname="${loopdevname}"
44 +               fi
45         fi
46  
47         if [ -z "${devname}" ]