SVN: geninitrd/trunk/geninitrd

baggins baggins at pld-linux.org
Thu Jul 5 11:54:20 CEST 2012


Author: baggins
Date: Thu Jul  5 11:54:20 2012
New Revision: 12573

Modified:
   geninitrd/trunk/geninitrd
Log:
- add search paths to find_tool() so it will fall back to standard,
  dynamically linked programs if those specified at command invocation
  cannot be found


Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd	(original)
+++ geninitrd/trunk/geninitrd	Thu Jul  5 11:54:20 2012
@@ -96,15 +96,28 @@
 
 # find program from specified paths
 find_tool() {
-	local x
+	local x p b n
+	local paths="$initrd_dir /bin /sbin /usr/bin /usr/sbin"
 	for x in "$@"; do
+		verbose "find_tool: checking $x"
 		if [ -x "$x" ]; then
 			echo $x
 			verbose "find_tool: found $x"
 			return 0
 		fi
+		n="$x"
+		for p in $paths; do
+			b=$(basename $x)
+			verbose "find_tool: checking $p/$b"
+			if [ -x "$p/$b" ]; then
+				echo $p/$b
+				verbose "find_tool: found $p/$b"
+				return 0
+			fi
+			n="$n $p/$b"
+		done
 	done
-	debug "find_tool: did not find any of: $@"
+	debug "find_tool: did not find any of: $n"
 	return 1
 }
 


More information about the pld-cvs-commit mailing list