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

008853
Index: os-prober/common.sh
008853
===================================================================
008853
--- os-prober.orig/common.sh
008853
+++ os-prober/common.sh
008853
@@ -62,10 +62,14 @@ cache_progname() {
008853
   esac
008853
 }
008853
 
008853
-log() {
008853
-  cache_progname
008853
-  logger -t "$progname" "$@"
008853
-}
008853
+# fd_logger: bind value now, possibly after assigning default. 
008853
+eval '
008853
+  log() {
008853
+    cache_progname
008853
+    echo "$progname: $@"  1>&'${fd_logger:=9}'
008853
+  }
008853
+'
008853
+export fd_logger  # so subshells inherit current value by default
008853
 
008853
 error() {
008853
   log "error: $@"
008853
@@ -81,10 +85,14 @@ debug() {
008853
   fi
008853
 }
008853
 
008853
-result () {
008853
-  log "result:" "$@"
008853
-  echo "$@"
008853
-}
008853
+# fd_result: bind value now, possibly after assigning default.
008853
+eval '
008853
+  result() {
008853
+    log "result:" "$@"
008853
+    echo "$@"  1>&'${fd_result:=1}'
008853
+  }
008853
+'
008853
+export fd_result  # so subshells inherit current value by default
008853
 
008853
 # shim to make it easier to use os-prober outside d-i
008853
 if ! type mapdevfs >/dev/null 2>&1; then
008853
Index: os-prober/linux-boot-prober
008853
===================================================================
008853
--- os-prober.orig/linux-boot-prober
008853
+++ os-prober/linux-boot-prober
008853
@@ -1,4 +1,12 @@
008853
 #!/bin/sh
008853
+
008853
+# dash shell does not have "{varname}>&1" feature that bash shell has
008853
+# for auto-assignment of new filedescriptors.
008853
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
008853
+# Therefore use fixed numbers.
008853
+export fd_result=3  # file descriptor for external results
008853
+export fd_logger=9  # file descriptor for input to logger
008853
+
008853
 . /usr/share/os-prober/common.sh
008853
 
008853
 set -e
008853
@@ -19,6 +27,7 @@ bootuuid=
008853
 
008853
 grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true
008853
 
008853
+( (
008853
 if [ -z "$1" ]; then
008853
 	ERR=y
008853
 elif [ "$1" = btrfs -a -z "$2" ]; then
008853
@@ -186,3 +195,5 @@ else
008853
 		fi
008853
 	fi
008853
 fi
008853
+) 9>&1 | logger 1>&-  # fd_logger
008853
+) 3>&1  # fd_result
008853
Index: os-prober/os-prober
008853
===================================================================
008853
--- os-prober.orig/os-prober
008853
+++ os-prober/os-prober
008853
@@ -1,7 +1,14 @@
008853
 #!/bin/sh
008853
 set -e
008853
 
008853
-. /usr/share/os-prober/common.sh
008853
+# dash shell does not have "{varname}>&1" feature that bash shell has
008853
+# for auto-assignment of new filedescriptors.
008853
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
008853
+# Therefore use fixed numbers.
008853
+export fd_result=3  # file descriptor for external results
008853
+export fd_logger=9  # file descriptor for input to logger
008853
+
008853
+ . /usr/share/os-prober/common.sh
008853
 
008853
 newns "$@"
008853
 require_tmpdir
008853
@@ -136,6 +143,7 @@ fi
008853
 
008853
 : >"$OS_PROBER_TMP/btrfs-vols"
008853
 
008853
+( (
008853
 for partition in $(partitions); do
008853
 	if ! mapped="$(mapdevfs "$partition")"; then
008853
 		log "Device '$partition' does not exist; skipping"
008853
@@ -200,3 +208,5 @@ for partition in $(partitions); do
008853
 		fi
008853
 	fi
008853
 done
008853
+) 9>&1 | logger 1>&-  # fd_logger
008853
+) 3>&1  # fd_result