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

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