Merge upstream version 1.173.2-1.
[live-initramfs-grml.git] / debian / patches / 04_drop_usage_of_fstype.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 04_drop_usage_of_fstype.dpatch <mika@grml.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Avoid the use of fstype in a running live system, as it's
6 ## DP: a executable and not a shell function and causes problems
7 ## DP: for example within live-snapshot.
8 ## DP: Further switch from vol_id to blkid if using udev >=146-1.
9
10 @DPATCH@
11 diff -urNad live-initramfs-grml~/scripts/live-helpers live-initramfs-grml/scripts/live-helpers
12 --- live-initramfs-grml~/scripts/live-helpers   2009-11-13 23:45:28.000000000 +0100
13 +++ live-initramfs-grml/scripts/live-helpers    2009-11-13 23:59:36.524643320 +0100
14 @@ -76,25 +76,17 @@
15  
16  get_fstype ()
17  {
18 -       local FSTYPE
19 -       local FSSIZE
20 -
21 -       # fstype misreports LUKS devices
22 -       if is_luks "${1}"
23 -       then
24 -           /lib/udev/vol_id -t ${1} 2>/dev/null
25 -           return
26 -       fi
27 -
28 -       eval $(fstype ${1} 2>/dev/null)
29 -
30 -       if [ "${FSTYPE}" != "unknown" ]
31 +       # udev >=146-1 no longer provides vol_id:
32 +       if [ -x /lib/udev/vol_id ]
33         then
34 -               echo ${FSTYPE}
35 -               return 0
36 +               /lib/udev/vol_id -t ${1} 2>/dev/null
37 +       else
38 +               eval $(blkid -o udev "${1}")
39 +               if [ -n "$ID_FS_TYPE" ]
40 +               then
41 +                       echo "${ID_FS_TYPE}"
42 +               fi
43         fi
44 -
45 -       /lib/udev/vol_id -t ${1} 2>/dev/null
46  }
47  
48  where_is_mounted ()
49 @@ -357,10 +349,21 @@
50                                 done
51                         fi
52  
53 -                       if [ "$(/lib/udev/vol_id -l ${devname} 2>/dev/null)" = "${pers_label}" ]
54 +                       # udev >=146-1 no longer provides vol_id:
55 +                       if [ -x /lib/udev/vol_id ]
56                         then
57 -                               echo "${devname}"
58 -                               return 0
59 +                               if [ "$(/lib/udev/vol_id -l ${devname} 2>/dev/null)" = "${pers_label}" ]
60 +                               then
61 +                                       echo "${devname}"
62 +                                       return 0
63 +                               fi
64 +                       else
65 +                               eval $(blkid -o udev "${devname}")
66 +                               if [ "$ID_FS_LABEL" = "${pers_label}" ]
67 +                               then
68 +                                       echo "${devname}"
69 +                                       return 0
70 +                               fi
71                         fi
72  
73                         if [ "${PERSISTENT}" = "nofiles" ]