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

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