diff options
author | Simon Rettberg | 2013-02-27 18:41:16 +0100 |
---|---|---|
committer | Simon Rettberg | 2013-02-27 18:41:16 +0100 |
commit | 9d559dd9c8a92e4f46b29a6e1bd30227b476209b (patch) | |
tree | 121d6d5c54f0f7ec0f67a6592a9355ed25b08988 /remote/setup_tools | |
parent | Only one target can be chosen when invoking mltk to make command line format ... (diff) | |
download | tm-scripts-9d559dd9c8a92e4f46b29a6e1bd30227b476209b.tar.gz tm-scripts-9d559dd9c8a92e4f46b29a6e1bd30227b476209b.tar.xz tm-scripts-9d559dd9c8a92e4f46b29a6e1bd30227b476209b.zip |
Handle required binaries that are symlinks properly
Diffstat (limited to 'remote/setup_tools')
-rwxr-xr-x | remote/setup_tools | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/remote/setup_tools b/remote/setup_tools index e0c092a4..24f2a291 100755 --- a/remote/setup_tools +++ b/remote/setup_tools @@ -56,15 +56,29 @@ copyfileswithdependencies () [ ! -z "${REQUIRED_BINARIES}" ] && pinfo "Gathering required binaries from config file..." for FILENAME in ${REQUIRED_BINARIES} do - FILE=$(find . -name "${FILENAME}" -type f -executable | xargs grep -l -E '^(.ELF|#!)' | head -1) - if [ -z "$FILE" ]; then + local FILE_CANDIDATES=$( find . -name "${FILENAME}" -a \( -type f -o -type l \) ) + pdebug "Candidates for $FILENAME are: $FILE_CANDIDATES" + local FINAL_LIST="" + for FILE in $FILE_CANDIDATES; do + local TESTFILE="$(readlink -f "$FILE")" + pdebug " $FILE leads to $TESTFILE" + [ -f "$TESTFILE" -a -x "$TESTFILE" ] && [ "x$(grep -l -E '^(.ELF|#!)' "$TESTFILE")" != "x" ] && FINAL_LIST="$FINAL_LIST $FILE" + done + FINAL_LIST=$(trim "$FINAL_LIST") + pdebug " Final list is $FINAL_LIST" + if [ -z "$FINAL_LIST" ]; then pwarning "\tNo Binary found for ${FILENAME}. Skipping." continue fi - - pdebug "\tFound ${FILENAME} at ${FILE}" - get_link_chain "${TOOL_DIR}/${TOOL}/build/${FILE}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" - get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${FILE}" >> "${COPYFILES_LIST}" + if [[ "$FINAL_LIST" == *" "* ]]; then + pwarning "Found more than one match for required file '$FILENAME': $FINAL_LIST" + else + pdebug "\tFound ${FILENAME} at ${FILE}" + fi + for FILE in $FINAL_LIST; do + get_link_chain "${TOOL_DIR}/${TOOL}/build/${FILE}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" + get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${FILE}" >> "${COPYFILES_LIST}" + done done [ ! -z "${REQUIRED_LIBRARIES}" ] && pinfo "Gathering required libraries from config file..." |