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

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