Permalink
Browse files

fixes for dynagrab and another tweak

  • Loading branch information...
1 parent 9efa969 commit a4e5bc5ca849a45b031c20d485f60a57576873b2 @danielrobbins danielrobbins committed Jun 5, 2011
Showing with 35 additions and 31 deletions.
  1. +4 −0 TODO
  2. +31 −31 dynagrab.sh
View
4 TODO
@@ -39,3 +39,7 @@
- Interactive
- Ask user what to do
+Funtoo -
+
+ add mdadm runtime dep to next genkernel. Also, it seems mdadm is always static even with -static.
+
View
@@ -4,66 +4,66 @@ run() {
if [ -n "$DRYRUN" ]
then
echo $*
- elif [ -n "$DEBUG" ]
- then
+ else
echo $*
$*
fi
}
linky() {
out=$1
+ libout=$2
+ shift
shift
if [ "$*" = "statically linked" ]
then
- echo "# static"
return
elif [ "$*" = "not a dynamic executable" ]
then
- echo "# static"
return
elif [ "${1:0:1}" == "/" ]
then
- libsrcpath="$1"
+ src="$1"
elif [ "${3:0:1}" == "(" ]
then
# no target
return
else
- libsrcpath=$3
+ src=$3
fi
- libname=${libsrcpath##*/}
- libnewpath=$out/${libname}
- if [ -L $libsrcpath ]; then
- linkdest=$(readlink $libsrcpath)
- if [ ! -L $libnewpath ]; then
- run "ln -sf $linkdest $libnewpath"
+ dynagrab $src $out $libout
+}
+
+dynagrab() {
+ out=$2
+ libout=$3
+ if [ ! -L $1 ]; then
+ # normal file - copy it over to $out:
+ if [ ! -e $out/${1##*/} ]; then
+ run "cp $1 $out"
else
- echo "# $libnewpath exists, skipping"
+ echo "# $out/${1##*/} exists, skipping..."
fi
+ ldd $1 | while read line; do
+ linky $libout $libout $line
+ done
else
- if [ ! -e $libnewpath ]; then
- run "cp $libsrcpath $libnewpath"
+ # symlink - create symlink in $libout:
+ linkdest=$(readlink $1)
+ if [ ! -L $libout/${1##*/} ];
+ then
+ run "ln -sf $linkdest $libout/${1##*/}"
else
- echo "# $libnewpath exists, skipping"
+ echo "# $libout/${1##*/} exists, skipping..."
fi
- dynagrab $libsrcpath $out
+ # recurse on target of original symlink, so we can grab everything:
+ recurse_on="${1%/*}/${linkdest}"
+ dynagrab $recurse_on $libout $libout
fi
}
-dynagrab() {
- ldd $1 | while read line; do
- linky $2 $line
- done
-}
-
-binarygrab() {
- [ ! -e $2/bin ] && run "install -d $2/bin"
- [ ! -e $2/lib ] && run "install -d $2/lib"
- run "cp $1 $2/bin"
- dynagrab $1 $2/lib
-}
-export DRYRUN=1
# grab all shared libs required by binary $1 and copy to destination chroot/initramfs root $2:
[ "$2" = "" ] && echo "Please specify a target chroot as a second argument. Exiting" && exit 1
-binarygrab $1 $2
+[ ! -e $2/bin ] && run "install -d $2/bin"
+[ ! -e $2/lib ] && run "install -d $2/lib"
+dynagrab $1 $2/bin $2/lib

0 comments on commit a4e5bc5

Please sign in to comment.