All pastes #824038 Raw Edit

masta

public shellscript v1 · immutable
·published 2007-12-19 19:13 UTC
rendered paste body
# 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}