568221c7f794570c4f095e94db41d9e524be759c
[live-initramfs-grml.git] / debian / patches / 14_prefer_removable_devices.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 14_prefer_removable_devices.dpatch by Michael Prokop <mika@grml.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: prefer removable devices over non-removable devices, so scan them first
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 09:21:56.059389954 +0100
10 +++ live-initramfs-grml/scripts/live    2010-03-11 10:17:05.482395328 +0100
11 @@ -1669,8 +1669,20 @@
12         esac
13  
14         # or do the scan of block devices
15 +       # prefer removable devices over non-removable devices, so scan them first
16         for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -vE "/(loop|ram|dm-|fd)")
17         do
18 +               if [ "$(cat ${sysblock}/removable)" = "1" ]
19 +               then
20 +                       removable_devices_to_scan="$removable_devices_to_scan $sysblock"
21 +               else
22 +                       nonremovable_devices_to_scan="$nonremovable_devices_to_scan $sysblock"
23 +               fi
24 +       done
25 +       devices_to_scan="$removable_devices_to_scan $nonremovable_devices_to_scan"
26 +
27 +       for sysblock in $devices_to_scan
28 +       do
29                 devname=$(sys2dev "${sysblock}")
30                 fstype=$(get_fstype "${devname}")
31