diff options
| author | Simon Rettberg | 2015-09-14 23:03:07 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-09-14 23:03:07 +0200 |
| commit | 0711aea3659175fb88ddf1004108c588e338bcd8 (patch) | |
| tree | cb1d0f60a53b1c0f9d0bd71cdf53e6c7061255c2 | |
| parent | [vmware] ethernet0.addressType = "static" added (parse_vmx.inc) (diff) | |
| download | tm-scripts-0711aea3659175fb88ddf1004108c588e338bcd8.tar.gz tm-scripts-0711aea3659175fb88ddf1004108c588e338bcd8.tar.xz tm-scripts-0711aea3659175fb88ddf1004108c588e338bcd8.zip | |
[binutil] Try harder not to be stupid (whats broken this time?)
| -rw-r--r-- | remote/includes/binutil.inc | 52 | ||||
| -rwxr-xr-x | remote/setup_target | 2 |
2 files changed, 30 insertions, 24 deletions
diff --git a/remote/includes/binutil.inc b/remote/includes/binutil.inc index 92ab8d87..b9867a90 100644 --- a/remote/includes/binutil.inc +++ b/remote/includes/binutil.inc @@ -20,12 +20,16 @@ # This improves runtime quite a bit... declare -rg BLACKLIST="ld-linux linux-gate linux-vdso libc.so" + +# replace ' ' by '|' in the blacklist, so grep can use it directly. +CURRENT_BLACKLIST=$(echo ${BLACKLIST} | sed 's/ /\\|/g') + # Initialise flag and path for local search LOCALSEARCH=0 LOCALSEARCHDIR="" -# replace ' ' by '|' in the blacklist, so grep can use it directly. -CURRENT_BLACKLIST=$(echo ${BLACKLIST} | sed 's/ /\\|/g') +DONEDONE=$(mktemp) +echo "-----------------------" > "$DONEDONE" ############################################################ # @@ -42,10 +46,10 @@ get_dynamic_dependencies() { # check if local search is activated by the '-l' switch # if so the following argument is the path. if [ "x$1" == "x-l" ]; then - LOCALSEARCH=1 + local LOCALSEARCH=1 shift [ ! -d "$1" ] && perror "Directory '$1' does not exist, exiting." - LOCALSEARCHDIR="$1" + local LOCALSEARCHDIR="$1" shift fi @@ -53,6 +57,7 @@ get_dynamic_dependencies() { while [ $# != 0 ]; do local BINARY="$1" shift + [ -f "$BINARY" ] || continue # now run ldd on it and save the output in $LDD_OUT local LDD_OUT="ldd_output" @@ -70,8 +75,6 @@ get_dynamic_dependencies() { else # Case 2: not a dynamic, do nothing pdebug "\t\t\t(Not a dynamic.)" - rm -f "$LDD_OUT" - continue fi rm -f -- "$LDD_OUT" done @@ -101,9 +104,10 @@ lib_search() { cd - >/dev/null if [ "x${LOCAL_MATCHES}" != "x" ]; then for LOCALLIB in ${LOCAL_MATCHES}; do + grep -q "^${LOCALLIB}\$" "$DONEDONE" && continue + echo "${LOCALLIB}" >> "$DONEDONE" get_link_chain "${LOCALSEARCHDIR}/${LOCALLIB}" "${LOCALSEARCHDIR}" get_dynamic_dependencies -l "${LOCALSEARCHDIR}" "${LOCALLIB}" - CURRENT_BLACKLIST+="\|${LOCALLIB:1}" done # found the libs, we are done return @@ -112,10 +116,11 @@ lib_search() { fi # search the lib on the system since it was not found earlier - if [ ! -z ${LIBLINK[1]} ] && [ "x${LIBLINK[1]}" != "xnot" ]; then + if [ -n "${LIBLINK[1]}" ] && [ "x${LIBLINK[1]}" != "xnot" ]; then + grep -q "^${LIBLINK[1]}\$" "$DONEDONE" && return + echo "${LIBLINK[1]}" >> "$DONEDONE" # get chain of symlink for that lib get_link_chain "${LIBLINK[1]}" - CURRENT_BLACKLIST+="\|${LIBLINK[1]}" else 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" @@ -134,29 +139,26 @@ lib_search() { get_link_chain() { # sanity checks - if [[ "$1" == /* ]]; then - if [ ! -e $1 -a ! -L $1 ]; then - perror "'$1' is a link but its target '$LINK_TARGET' is not in '${LOCALSEARCHDIR}'" - fi - else - perror "get_link_chain() requires absolute paths, given: $1" + [[ "$1" == /* ]] || perror "get_link_chain() requires absolute paths, given: $1" + if [ ! -e $1 -a ! -L $1 ]; then + perror "'$1' is a link but its target '$LINK_TARGET' is not in '${LOCALSEARCHDIR}'" fi + local PREFIX= if [ $# == 2 ] ; then - [ ! -d $2 ] && perror "get_link_chain: '$2' is not a directory. Local search can't work..." + [ -d "$2" ] || perror "get_link_chain: '$2' is not a directory. Local search can't work..." # got a prefix - local PREFIX=$(readlink -f $2) - else - # mark prefix as not set - local PREFIX="notset" + local PREFIX=$(dirname "$(canonicalize "$2/foo")") + [ -d "$PREFIX" ] || perror "Could not canonicalize $2" + [[ "$PREFIX" == */ ]] || PREFIX="$PREFIX/" fi # canonalize - local LINK=$(canonicalize $1) + local LINK=$(canonicalize "$1") local CHAIN="$LINK" # write the first link in the chain - if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then + if [ "x$PREFIX" != "x" ]; then if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then # prefix was not in the link echo "$LINK" @@ -177,12 +179,14 @@ get_link_chain() { # save the directory prefix CURRENTDIR=$(dirname "${LINK}") # first follow the link - LINK=$(readlink "$LINK") + local NEWLINK=$(readlink "$LINK") + [ -z "$NEWLINK" -o "$NEWLINK" = "$LINK" ] && break + LINK=$NEWLINK CHAIN+=" -> $LINK" # $LINK can be absolute or relative, check cases [[ "$LINK" == /* ]] || LINK=$(canonicalize "$CURRENTDIR"/"${LINK}") # write the first link in the chain - if [ "x$PREFIX" != "x" -a "x$PREFIX" != "xnotset" ]; then + if [ "x$PREFIX" != "x" ]; then if [ "x${LINK#$PREFIX}" == "x${LINK}" ]; then # prefix was not in the link if [ ! -e "$LINK" ]; then diff --git a/remote/setup_target b/remote/setup_target index 91e657e0..63869979 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -211,10 +211,12 @@ copy_files_with_deps () { local ENTRY="" for ENTRY in ${REQUIRED_DIRECTORIES}; do [[ "$ENTRY" == /* ]] || perror "All entries in REQUIRED_DIRECTORIES have to start with a slash '/', but $ENTRY does not!" + [ -e "$ENTRY" -a ! -d "$ENTRY" ] && perror "$ENTRY is not a directory" pdebug "* $ENTRY" ENTRY=".${ENTRY}" echo "${ENTRY}" >> "${COPYFILES_LIST}" for BIN in $(find "${ENTRY}" -type f -a \( -executable -o -name '*.so*' \) -a -not -name '*.a'); do + [ -f "$BIN" ] || continue #pdebug "\tSearching libs for ${BIN}..." get_link_chain "${MODULE_BUILD_DIR}/${BIN}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}" get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${BIN}" >> "${COPYFILES_LIST}" |
