diff options
| author | Jonathan Bauer | 2013-02-27 17:14:48 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2013-02-27 17:14:48 +0100 |
| commit | 1b22cbdd92048d2bf3621f29c021b6b54c718afd (patch) | |
| tree | c2614f1c4cf6e743967f5c08ccc41a23b9fff393 | |
| parent | fix tarcopy call for base (diff) | |
| download | tm-scripts-1b22cbdd92048d2bf3621f29c021b6b54c718afd.tar.gz tm-scripts-1b22cbdd92048d2bf3621f29c021b6b54c718afd.tar.xz tm-scripts-1b22cbdd92048d2bf3621f29c021b6b54c718afd.zip | |
binutil.inc fixed functionality, see comments
| -rw-r--r-- | helper/binutil.inc | 79 |
1 files changed, 58 insertions, 21 deletions
diff --git a/helper/binutil.inc b/helper/binutil.inc index b97ab0f8..35e35015 100644 --- a/helper/binutil.inc +++ b/helper/binutil.inc @@ -4,8 +4,10 @@ # ############################################################ # -# Usage: get_dynamic_dependencies <binary_list> -# (the list must be seperated by spaces) +# Usage: get_dynamic_dependencies [-l <searchdir>] <binary_list> +# * the list must be seperated by spaces +# * the search for lib needed by a binary can be done locally, +# using the -l <searchdir> option # # Ouput: # Will simply echo list of required libraries @@ -31,7 +33,7 @@ get_dynamic_dependencies() { local BINARY=$1 shift - pdebug "Processing ${BINARY} ..." + pdebug "Processing $BINARY ..." local LDD_OUT="ldd_output" if ldd $BINARY > $LDD_OUT; then @@ -41,20 +43,20 @@ get_dynamic_dependencies() { # libm.so.6 => /lib/libm.so.6 would be split into: # liblink[0] liblink[1] local liblink=(${LIB//=>/ }) - pdebug " Searching for ${liblink[0]}..." lib_search done + rm $LDD_OUT else # Case 2: not a dynamic pdebug "$BINARY not a dynamic, skipping." continue fi - rm $LDD_OUT done } lib_search(){ + pdebug "\tSearching for ${liblink[0]}..." # if activated, start by searching the lib locally if [ "x$LOCALSEARCH" == "x1" ]; then cd $LOCALSEARCHDIR @@ -62,46 +64,70 @@ lib_search(){ cd - &>/dev/null if [ "x${LOCAL_MATCHES}" != "x" ]; then for llib in ${LOCAL_MATCHES}; do - pdebug "\tFound locally, copying ${LOCALSEARCHDIR}/${llib}" - get_link_chain "${LOCALSEARCHDIR}"/"${llib}" + pdebug "\t\tFound locally, copying ${LOCALSEARCHDIR}/${llib}" + get_link_chain "${LOCALSEARCHDIR}"/"${llib}" "${LOCALSEARCHDIR}" done # found the libs, we are done return fi # mark local search as done - LOCALSEARCH=0 fi # search the lib on the system since it was not found earlier if [ ! -z ${liblink[1]} ] && [ "x${liblink[1]}" != "xnot" ]; then - pdebug "\tNot found locally but in system, copying ${liblink[1]}" + pdebug "\t\tNot found locally but in system, copying ${liblink[1]}" # get chain of symlink for that lib get_link_chain ${liblink[1]} else - pwarning "Lib '${liblink[0]}' from required dir '$ENTRY' neither found in build directory nor on this system." - pwarning "If this lib is not supplied by another module, this module will probably fail in your final system" + pwarning "\t\tLib '${liblink[0]}' from required dir '$ENTRY' neither found in build directory nor on this system." + pwarning "\t\tIf this lib is not supplied by another module, this module will probably fail in your final system" fi } ############################################################ # -# Usage: get_link_chain <link> +# Usage: get_link_chain <link> [prefix] # -# <link> must be in absolute form +# <link> must be in absolute form- +# [prefix] is the prefix to strip from the ouput. # # Output: # Lists the symlink chain until a hardlink is found. get_link_chain() { - # the first parameter must be absolute - [[ "$1" == /* ]] || perror "get_link_chain() requires absolute paths." + # sanity checks + if [[ "$1" == /* ]]; then + [ -e $1 ] || perror "get_link_chain: no such file: $1" + else + perror "get_link_chain() requires absolute paths, given: $1" + fi + if [ $# == 2 ] ; then + [ ! -d $2 ] && perror "get_link_chain: $2 is not a directory." + # got a prefix + local PREFIX=$2 + else + # mark prefix as not set + local PREFIX="notset" + fi # canonalize local LINK=$(canonicalize $1) + local CHAIN="$LINK" + # write the first link in the chain - # we strip the LOCALSEARCHDIR if it was found locally - [ "x$LOCALSEARCH" == "x1" ] && echo "./${LINK#$LOCALSEARCHDIR}" || echo ${LINK} + if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then + if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then + # prefix was not in the link + echo "$LINK" + else + # prefix was in the link + echo ./"${LINK#$PREFIX}" + fi + else + # no prefix, copy like it is + echo "$LINK" + fi # now we check for symlinks local TRY=0 @@ -112,11 +138,22 @@ get_link_chain() { CURRENTDIR=$(dirname ${LINK}) # first follow the link LINK=$(readlink $LINK) - - pdebug "Processing $LINK" + CHAIN+=" -> $LINK" # $LINK can be absolute or relative, check cases [[ "$LINK" == /* ]] || LINK=$(canonicalize "$CURRENTDIR"/"${LINK}") - [ "x$LOCALSEARCH" == "x1" ] && echo "./${LINK#$LOCALSEARCHDIR}" || echo ${LINK} + # write the first link in the chain + if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then + if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then + # prefix was not in the link + echo "$LINK" + else + # prefix was in the link + echo ./"${LINK#$PREFIX}" + fi + else + # no prefix, copy like it is + echo "$LINK" + fi done - + pdebug "\t\tCHAIN: $CHAIN" } |
