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

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