# wants a (list of) dir(s) as the argument(s) # returns a list of libraries on stdout. # NEVER PUT ANYTHING HERE THAT ECHOS TO STDOUT OR STDERR. ldd_dir() { local BIN_PATH I while :; do [ $# -eq 0 ] && break [ ! -d ${1} ] && continue BIN_PATH=${1} && shift for I in ${BIN_PATH}/* ; do ldd -f "%p\n" ${I} 2>/dev/null || continue done done | sort -u } # this requires a DESTDIR (param 1) # this uses ldd_dir() to scan DESTDIR for libs to copy. # copies libs from the base system to the DESTDIR. libcopy() { local DESTDIR BINDIRS I [ $# -lt "2" ] && return 255 [ -d $1 ] || return 254 DESTDIR=$1 && shift for I in $*; do if [ -z "${BINDIRS}" ] ; then BINDIRS="${DESTDIR}/${I}" else BINDIRS="${BINDIRS} ${DESTDIR}/${I}" fi done shift $# for I in `ldd_dir ${BINDIRS}`; do cp ${VERBOPTS} -Rpf ${I} ${DESTDIR}/${I} liblink ${I} done return 0 } # also this for pam # code to copy over the pam modules in an approptiate way. do_pam_modules() { local _PAM _PAMLIB for _PAM in ${BASEDIR}/usr/lib/*pam*.[0-9] ; do cp ${VERBOPTS} -Rpf ${_PAM} ${WORKDIR}/usr/lib/ liblink ${_PAM} done # This removes fixes the dynamic-dynamic libs. # it ldd's the libs, and finds all the libs (which ohter libs might link in). info "Locating dynamic libs of other libs." for _PAMLIB in `ls ${WORKDIR}/usr/lib/*pam*.[0-9] | xargs ldd -f "%p\n" | sort -u`; do [ -f ${WORKDIR}/${_PAMLIB} ] || { cp ${VERBOPTS} -Rpf ${_PAMLIB} ${WORKDIR}/${_PAMLIB} liblink ${_PAMLIB} continue } done } # more pam crap # when you copy a library file, this function creates the compatibility symlink. # example libpcap.so.2 => libpcap.so liblink() { local _LIB _BASENAME _LINKNAME _LIB=$1 _BASENAME=`basename ${_LIB}` _LINKNAME=`echo ${_BASENAME} | cut -d "." -f 1-2` #echo "(cd ${WORKDIR}`dirname ${_LIB}` ; ln ${VERBOPTS} -s ${_BASENAME} ${_LINKNAME})" (cd ${WORKDIR}`dirname ${_LIB}` ; ln ${VERBOPTS} -s ${_BASENAME} ${_LINKNAME}) }