#!/bin/bash SOURCE="$1" if [[ $2 = --references ]] || [[ $2 = -r ]] then shift;shift for i in $1 do REFERENCES="${REFERENCES} $(< ${i})" done fi COLRED="\033[1;6m\033[31m" COLDEFAULT="\033[0m" not_in_list() { local deplist="$1" local dep="$2" local i for i in ${deplist} do [[ ${i} = ${dep} ]] && return 1 done return 0 } echo -n "resolving linking lib ... " # first binaries: for bin in $(find ${SOURCE} | xargs file | grep "executable" | grep ELF | cut -f 1 -d :) \ $(find ${SOURCE} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d :) do while read lib do dep=$(echo "${lib}" | cut -d'>' -f2 | cut -d'(' -f1 | sed "s:\ ::g") if [[ ${X11HACK} = true ]] then dep=$(echo ${dep} | sed "s:/usr/X11R6/:/usr/:g") fi if [[ -z $(echo ${dep} | grep "notfound") ]] then if not_in_list "${ALL_DEPS}" "${dep}" then ALL_DEPS="${ALL_DEPS} ${dep}" fi fi done << EOF $(ldd ${bin}) EOF done echo "done" if [[ ${DEBUG} = true ]] then echo for i in $(echo ${ALL_DEPS} | sort ) do echo ${i} done echo fi echo -n "resolving packages ... " for i in ${ALL_DEPS} do pkg=$(/sbin/magequery -f "${i}") if [[ -z ${pkg} ]] then NO_PACKAGE_FOUND="${NO_PACKAGE_FOUND}:${i} -> no pkg found." continue fi for z in ${pkg} do if not_in_list "${ALL_PACKAGES}" "${z}" then ALL_PACKAGES="${ALL_PACKAGES} ${z}" [[ ${DEBUG} = true ]] && echo "DEBUG: ${z} ${i}" fi done done echo "done" echo for i in ${ALL_PACKAGES} do if not_in_list "${REFERENCES}" "${i}" then echo "${i}" else echo -e "${COLRED}${i}${COLDEFAULT}" fi done | sort echo if [[ ${PRINT_NOT_FOUND} = true ]] then echo echo "Non resolved libs:" OLDIFS="${IFS}" IFS=: for i in ${NO_PACKAGE_FOUND} do echo ${i} done | sort IFS="${OLDIFS}" echo fi