From 6115aa3769390404c3f03f29b4006fa2be212b66 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 25 Feb 2013 18:07:40 +0100 Subject: [tools] replace locate by find in base.build as it is faster, [setup_tools] treat scripts as binaries too but skip ldd part --- remote/setup_tools | 8 ++++---- remote/tools/base/base.build | 18 ++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/remote/setup_tools b/remote/setup_tools index 76f163f5..2df84a5d 100755 --- a/remote/setup_tools +++ b/remote/setup_tools @@ -47,7 +47,7 @@ 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 '^.ELF') # FIXME: What happens on multiple matches? Maybe add " | head -1" + FILE=$(find . -name "${FILENAME}" -type f -executable | xargs grep -l -E '^(.ELF|#!)' | head -1) if [ -z "$FILE" ]; then pwarning "\tNo Binary found for ${FILENAME}. Skipping." continue @@ -57,8 +57,8 @@ copyfileswithdependencies () # fetch dependencies # quick fix to exclude libc*, else it copies unneeded libs... # workaround for - ldd ${FILE} &>/dev/null - ldd_exit_code=$? + ldd "${FILE}" &>/dev/null + local ldd_exit_code=$? if [ "x$ldd_exit_code" != "x0" ]; then pdebug "\tldd $FILE failed." @@ -67,7 +67,7 @@ copyfileswithdependencies () for i in $(ldd "${FILE}" | awk '{print $1 $2 $3}' | grep -v ld-linux | grep -v libc.so | grep -v linux-gate | grep -v linux-vdso) do arrIN=(${i//=>/ }) - pdebug "* ${arrIN[0]}" + pdebug "Processing lib ${arrIN[0]}" LOCAL_MATCHES=$(find . -name "$(echo ${arrIN[0]} | awk -F '.' '{print $1}')".so\*) if [ "x${LOCAL_MATCHES}" != "x" ]; then diff --git a/remote/tools/base/base.build b/remote/tools/base/base.build index b9d96fd5..98f24047 100644 --- a/remote/tools/base/base.build +++ b/remote/tools/base/base.build @@ -8,11 +8,11 @@ fetch_source() { build() { - BUILDDIR=${TOOL_DIR}/${TOOL}/build - mkdir -p ${BUILDDIR} + BUILDDIR="${TOOL_DIR}/${TOOL}/build" + mkdir -p "${BUILDDIR}" FILELIST="list_binaries_and_files" - [ -e ${FILELIST} ] && rm ${FILELIST} + [ -e "${FILELIST}" ] && rm "${FILELIST}" for BIN in ${REQUIRED_BINARIES} do @@ -31,7 +31,7 @@ build() { for LIB in ${REQUIRED_LIBRARIES} do - for LIB_LOCATION in $(locate ${LIB} | grep ^/lib/) + for LIB_LOCATION in $(find /lib/ -name "${LIB}.so\*") do echo ${LIB_LOCATION} >> "${FILELIST}" done @@ -51,9 +51,7 @@ build() { local NUMFILES=$(cat "${FILELIST}" | wc -l) if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then pinfo "File list generated at ${BUILDDIR}/${FILELIST} ($NUMFILES entries)" - tar -cp $(cat "${FILELIST}") | tar -xp -C "${BUILDDIR}" - local RET=$? - [ $RET -ne 0 ] && perror "tar-copy from '$FILELIST' to '$BUILDDIR' failed." + tarcopy "${FILELIST}" "${BUILDDIR}" fi } @@ -64,14 +62,14 @@ post_copy() { # copy devices from running system cp -a /dev/{console,kmsg,mem,null,shm,tty,tty0,tty1,tty9,fb0,urandom,zero} \ - "${INIT_DIR}"/dev + "${INIT_DIR}"/dev || perror "Copying devices from running system failed." # set /etc/environment to include /openslx/bin and /openslx/sbin echo "PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/openslx/sbin:/openslx/bin\"" \ > "${INIT_DIR}/etc/environment" # copy static files - cp -r "${TOOL_DIR}/${TOOL}"/data/* "${INIT_DIR}" + cp -r "${TOOL_DIR}/${TOOL}"/data/* "${INIT_DIR}" || perror "Copying static files from data/* failed." # better: dirname $(ldd $SHELL|grep libc | awk -F " " '{print $3}') # copy pam modules, TODO: better way to find arch-dependant interfix... @@ -92,7 +90,7 @@ post_copy() { # setup root accoun USER=root PASSWORD='!r00t' add_user - [ ! -d ${INIT_DIR}/root ] && mkdir ${INIT_DIR}/root + mkdir -p ${INIT_DIR}/root echo "minilinux-$(hostname)" > "${INIT_DIR}/etc/hostname" -- cgit v1.2.3-55-g7522