os-prober: call dmraid -r *once*
authorJeff Mahoney <jeffm@suse.com>
Thu, 19 Jan 2017 21:43:11 +0000 (21:43 +0000)
committerColin Watson <cjwatson@debian.org>
Thu, 19 Jan 2017 21:43:11 +0000 (21:43 +0000)
os-prober calls dmraid -r -c unqualifed for every partition and then greps
the result. dmraid -r -c without a device list will scan every device
on the system. Every time. The results will not differ between runs.

This patch saves the results and performs the grep afterward.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Tweaked-by: Colin Watson <cjwatson@debian.org>
debian/changelog
os-prober

index a96b667..a4958a5 100644 (file)
@@ -23,6 +23,7 @@ os-prober (1.72) UNRELEASED; urgency=medium
     Vatankhah; closes: #698598).
   * Replace basename/dirname with shell string processing (thanks, Hedayat
     Vatankhah; part of #694668).
+  * Call dmraid only once (thanks, Jeff Mahoney).
 
  -- Colin Watson <cjwatson@debian.org>  Sat, 31 Dec 2016 17:11:49 +0000
 
index 0e51682..a48863e 100755 (executable)
--- a/os-prober
+++ b/os-prober
@@ -14,11 +14,16 @@ log_output () {
        fi
 }
 
+: >"$OS_PROBER_TMP/dmraid-map"
+DMRAID=$(type dmraid >/dev/null 2>&1 || true)
+if [ "$DMRAID" ]; then
+       dmraid -r -c >"$OS_PROBER_TMP/dmraid-map"
+fi
+
 on_sataraid () {
-       type dmraid >/dev/null 2>&1 || return 1
        local parent="${1%/*}"
        local device="/dev/${parent##*/}"
-       if dmraid -r -c | grep -q "$device"; then
+       if grep -q "$device" "$OS_PROBER_TMP/dmraid-map"; then
                return 0
        fi
        return 1