[readonly/geninitrd: 472/1068] - fix inst_exec() using inst()

draenog draenog at pld-linux.org
Sat Nov 2 19:52:04 CET 2013


commit 17e97aecba0dfece2dd1ea7440a18917ed25b4ba
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Thu Oct 25 14:15:34 2007 +0000

    - fix inst_exec() using inst()
    
    svn-id: @8871

 geninitrd | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index 5e1cd72..3a1edf5 100755
--- a/geninitrd
+++ b/geninitrd
@@ -284,15 +284,25 @@ findmodule() {
 # it will operate recursively (copying directories)
 # and will symlink destinations if source is symlink.
 inst() {
-	if [ "$#" -lt "2" ];then
-		die 'Usage: inst <file> $MNTIMAGE<destination>'
+	if [ $# -lt 2 ]; then
+		die 'Usage: inst <file> [<file>] $MNTIMAGE<destination>'
 	fi
-	debug "cp $1 $MNTIMAGE$2"
-	cp -HR "$1" "$MNTIMAGE$2"
+
+	local src i=0 c=$(($# - 1))
+	while [ $i -lt $c ]; do
+		src="$src $1"
+		i=$((i + 1))
+		shift
+	done
+	local dest=$1
+	set -- $src
+
+	debug "cp $* $MNTIMAGE$dest"
+	cp -HR "$@" "$MNTIMAGE$dest"
 }
 
 inst_d() {
-	if [ "$#" = "0" ];then
+	if [ $# = 0 ]; then
 		die 'Usage: inst_d $MNTIMAGE<destination> $MNTIMAGE<destination>'
 	fi
 	for dir in "$@"; do
@@ -302,6 +312,9 @@ inst_d() {
 
 # install executable and it's shared libraries
 inst_exec() {
+	if [ $# -lt 2 ]; then
+		die 'Usage: inst_exec <file> [, <file>] $MNTIMAGE<destination>'
+	fi
 	local src i=0 c=$(($# - 1))
 	while [ $i -lt $c ]; do
 		src="$src $1"
@@ -313,11 +326,13 @@ inst_exec() {
 
 	inst "$@" $dest
 
-	local lib libs=$(ldd "$@" | awk '/linux-gate\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
+	local lib libdir libs=$(ldd "$@" | awk '/statically|linux-gate\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
 	for lib in $libs; do
-		local libdir=/$(echo "$lib" | cut -d/ -f2)/
-		inst_d $libdir
-		inst $lib $libdir
+		libdir=/$(echo "$lib" | cut -d/ -f2)/
+		if [ ! -f "$MNTIMAGE/$libdir/${lib##*/}" ]; then
+			inst_d $libdir
+			inst_exec $lib $libdir
+		fi
 	done
 }
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/readonly/geninitrd.git/commitdiff/147754ca159d40ca5eb541074dc043d8cbd92090



More information about the pld-cvs-commit mailing list