Bug#694668: A patch improve the performance of os-prober for systems with many partitions

2013-02-05 Thread Hedayat Vatankhah
A patch (part of the original) to pipe all logs to logger rather than 
running it repeatedly.


P.S. Isn't there any 'development' branch in os-prober which is not tied 
to Debian releases? That's weird.
diff -up os-prober-1.57/common.sh.logger-factor-out os-prober-1.57/common.sh
--- os-prober-1.57/common.sh.logger-factor-out	2013-02-05 21:19:38.896088800 +0330
+++ os-prober-1.57/common.sh	2013-02-05 21:20:04.624767147 +0330
@@ -62,10 +62,14 @@ cache_progname() {
   esac
 }
 
-log() {
-  cache_progname
-  logger -t $progname $@
-}
+# fd_logger: bind value now, possibly after assigning default. 
+eval '
+  log() {
+cache_progname
+echo $progname: $@  1'${fd_logger:=9}'
+  }
+'
+export fd_logger  # so subshells inherit current value by default
 
 error() {
   log error: $@
@@ -81,10 +85,14 @@ debug() {
   fi
 }
 
-result () {
-  log result: $@
-  echo $@
-}
+# fd_result: bind value now, possibly after assigning default.
+eval '
+  result() {
+log result: $@
+echo $@  1'${fd_result:=1}'
+  }
+'
+export fd_result  # so subshells inherit current value by default
 
 # shim to make it easier to use os-prober outside d-i
 if ! type mapdevfs /dev/null 21; then
diff -up os-prober-1.57/linux-boot-prober.logger-factor-out os-prober-1.57/linux-boot-prober
--- os-prober-1.57/linux-boot-prober.logger-factor-out	2013-02-05 21:19:59.395832518 +0330
+++ os-prober-1.57/linux-boot-prober	2013-02-05 21:24:42.301295713 +0330
@@ -1,4 +1,12 @@
 #!/bin/sh
+
+# dash shell does not have {varname}1 feature that bash shell has
+# for auto-assignment of new filedescriptors.
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
+# Therefore use fixed numbers.
+export fd_result=3  # file descriptor for external results
+export fd_logger=9  # file descriptor for input to logger
+
 . /usr/share/os-prober/common.sh
 
 set -e
@@ -147,6 +155,7 @@ if ! mapped=$(mapdevfs $partition);
 	continue
 fi
 
+( (
 if ! grep -q ^$mapped  $OS_PROBER_TMP/mounted-map; then
 	for test in /usr/lib/linux-boot-probes/*; do
 		if [ -x $test ]  [ -f $test ]; then
@@ -186,3 +195,5 @@ else
 		fi
 	fi
 fi
+) 91 | logger 1-  # fd_logger
+) 31  # fd_result
diff -up os-prober-1.57/os-prober.logger-factor-out os-prober-1.57/os-prober
--- os-prober-1.57/os-prober.logger-factor-out	2013-02-05 21:19:52.914913541 +0330
+++ os-prober-1.57/os-prober	2013-02-05 21:25:35.168634780 +0330
@@ -1,7 +1,14 @@
 #!/bin/sh
 set -e
 
-. /usr/share/os-prober/common.sh
+# dash shell does not have {varname}1 feature that bash shell has
+# for auto-assignment of new filedescriptors.
+# It is cumbersome to write the 'eval' to use our own variables in redirections.
+# Therefore use fixed numbers.
+export fd_result=3  # file descriptor for external results
+export fd_logger=9  # file descriptor for input to logger
+
+ . /usr/share/os-prober/common.sh
 
 newns $@
 require_tmpdir
@@ -129,6 +136,7 @@ fi
 
 : $OS_PROBER_TMP/btrfs-vols
 
+( (
 for partition in $(partitions); do
 	if ! mapped=$(mapdevfs $partition); then
 		log Device '$partition' does not exist; skipping
@@ -193,3 +201,5 @@ for partition in $(partitions); do
 		fi
 	fi
 done
+) 91 | logger 1-  # fd_logger
+) 31  # fd_result


Bug#694668: A patch improve the performance of os-prober for systems with many partitions

2013-01-22 Thread Hedayat Vatankhah
Yes, you are right specially since the patch does many things at once. I 
am going to break up the patch to smaller ones so that I can maintain 
them personally. I thought that you might also prefer this. Therefore, 
I'll post the smaller patches. But if you think that is not needed, let 
me know.
Anyway, attached you'll find a small patch which just replaces usage of 
'basename' with shell string processing (already used in some parts of 
the code, so should be supported in the target shell(s)).



/*Cyril Brulebois k...@debian.org*/ wrote on Tue, 25 Dec 2012 19:33:56 
+0100:

Hi,

Hedayat Vatankhah heday...@gmail.com (29/11/2012):

This bug is reported by one of our users, and also the patch is
provided by him. And this is his comments on the provided patch:
[…]

thanks for forwarding. Unfortunately it's too late in the release
cycle to consider this kind of large changes, so it's probably only
going to be considered during the 'jessie' release cycle.

Mraw,
KiBi.


diff -up os-prober-1.57/common.sh.remove-basename os-prober-1.57/common.sh
--- os-prober-1.57/common.sh.remove-basename	2013-01-23 01:06:50.023992389 +0330
+++ os-prober-1.57/common.sh	2013-01-23 02:01:09.435244141 +0330
@@ -57,7 +57,7 @@ progname=
 cache_progname() {
   case $progname in
 '')
-  progname=$(basename $0)
+  progname=${0##*/}
   ;;
   esac
 }
diff -up os-prober-1.57/linux-boot-probes/mounted/powerpc/40yaboot.remove-basename os-prober-1.57/linux-boot-probes/mounted/powerpc/40yaboot
--- os-prober-1.57/linux-boot-probes/mounted/powerpc/40yaboot.remove-basename	2013-01-23 02:04:03.855063593 +0330
+++ os-prober-1.57/linux-boot-probes/mounted/powerpc/40yaboot	2013-01-23 02:02:34.876175982 +0330
@@ -27,7 +27,7 @@ recordstanza () {
 		fi
 
 		if [ -z $title ]; then
-			title=$(basename $kernel)
+			title=${kernel##*/}
 		fi
 		if [ $read_only ]; then
 			parameters=ro $parameters


Bug#694668: A patch improve the performance of os-prober for systems with many partitions

2012-12-25 Thread Cyril Brulebois
Hi,

Hedayat Vatankhah heday...@gmail.com (29/11/2012):
 This bug is reported by one of our users, and also the patch is
 provided by him. And this is his comments on the provided patch:
 […]

thanks for forwarding. Unfortunately it's too late in the release
cycle to consider this kind of large changes, so it's probably only
going to be considered during the 'jessie' release cycle.

Mraw,
KiBi.


signature.asc
Description: Digital signature