Blame SOURCES/os-prober-factor-out-logger.patch

c62eab
diff -up os-prober-1.57/common.sh.logger-factor-out os-prober-1.57/common.sh
c62eab
--- os-prober-1.57/common.sh.logger-factor-out	2013-02-05 21:19:38.896088800 +0330
c62eab
+++ os-prober-1.57/common.sh	2013-02-05 21:20:04.624767147 +0330
c62eab
@@ -62,10 +62,14 @@ cache_progname() {
c62eab
   esac
c62eab
 }
c62eab
 
c62eab
-log() {
c62eab
-  cache_progname
c62eab
-  logger -t "$progname" "$@"
c62eab
-}
c62eab
+# fd_logger: bind value now, possibly after assigning default. 
c62eab
+eval '
c62eab
+  log() {
c62eab
+    cache_progname
c62eab
+    echo "$progname: $@"  1>&'${fd_logger:=9}'
c62eab
+  }
c62eab
+'
c62eab
+export fd_logger  # so subshells inherit current value by default
c62eab
 
c62eab
 error() {
c62eab
   log "error: $@"
c62eab
@@ -81,10 +85,14 @@ debug() {
c62eab
   fi
c62eab
 }
c62eab
 
c62eab
-result () {
c62eab
-  log "result:" "$@"
c62eab
-  echo "$@"
c62eab
-}
c62eab
+# fd_result: bind value now, possibly after assigning default.
c62eab
+eval '
c62eab
+  result() {
c62eab
+    log "result:" "$@"
c62eab
+    echo "$@"  1>&'${fd_result:=1}'
c62eab
+  }
c62eab
+'
c62eab
+export fd_result  # so subshells inherit current value by default
c62eab
 
c62eab
 # shim to make it easier to use os-prober outside d-i
c62eab
 if ! type mapdevfs >/dev/null 2>&1; then
c62eab
diff -up os-prober-1.57/linux-boot-prober.logger-factor-out os-prober-1.57/linux-boot-prober
c62eab
--- os-prober-1.57/linux-boot-prober.logger-factor-out	2013-02-05 21:19:59.395832518 +0330
c62eab
+++ os-prober-1.57/linux-boot-prober	2013-02-05 21:24:42.301295713 +0330
c62eab
@@ -1,4 +1,12 @@
c62eab
 #!/bin/sh
c62eab
+
c62eab
+# dash shell does not have "{varname}>&1" feature that bash shell has
c62eab
+# for auto-assignment of new filedescriptors.
c62eab
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
c62eab
+# Therefore use fixed numbers.
c62eab
+export fd_result=3  # file descriptor for external results
c62eab
+export fd_logger=9  # file descriptor for input to logger
c62eab
+
c62eab
 . /usr/share/os-prober/common.sh
c62eab
 
c62eab
 set -e
c62eab
@@ -147,6 +155,7 @@ if ! mapped="$(mapdevfs "$partition")";
c62eab
 	continue
c62eab
 fi
c62eab
 
c62eab
+( (
c62eab
 if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then
c62eab
 	for test in /usr/lib/linux-boot-probes/*; do
c62eab
 		if [ -x $test ] && [ -f $test ]; then
c62eab
@@ -186,3 +195,5 @@ else
c62eab
 		fi
c62eab
 	fi
c62eab
 fi
c62eab
+) 9>&1 | logger 1>&-  # fd_logger
c62eab
+) 3>&1  # fd_result
c62eab
diff -up os-prober-1.57/os-prober.logger-factor-out os-prober-1.57/os-prober
c62eab
--- os-prober-1.57/os-prober.logger-factor-out	2013-02-05 21:19:52.914913541 +0330
c62eab
+++ os-prober-1.57/os-prober	2013-02-05 21:25:35.168634780 +0330
c62eab
@@ -1,7 +1,14 @@
c62eab
 #!/bin/sh
c62eab
 set -e
c62eab
 
c62eab
-. /usr/share/os-prober/common.sh
c62eab
+# dash shell does not have "{varname}>&1" feature that bash shell has
c62eab
+# for auto-assignment of new filedescriptors.
c62eab
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
c62eab
+# Therefore use fixed numbers.
c62eab
+export fd_result=3  # file descriptor for external results
c62eab
+export fd_logger=9  # file descriptor for input to logger
c62eab
+
c62eab
+ . /usr/share/os-prober/common.sh
c62eab
 
c62eab
 newns "$@"
c62eab
 require_tmpdir
c62eab
@@ -129,6 +136,7 @@ fi
c62eab
 
c62eab
 : >"$OS_PROBER_TMP/btrfs-vols"
c62eab
 
c62eab
+( (
c62eab
 for partition in $(partitions); do
c62eab
 	if ! mapped="$(mapdevfs "$partition")"; then
c62eab
 		log "Device '$partition' does not exist; skipping"
c62eab
@@ -193,3 +201,5 @@ for partition in $(partitions); do
c62eab
 		fi
c62eab
 	fi
c62eab
 done
c62eab
+) 9>&1 | logger 1>&-  # fd_logger
c62eab
+) 3>&1  # fd_result