tazpkg diff tazpkg-find-depends @ rev 695
Separate convert functions to tazpkg-convert; functions that are common to the tazpkg and tazpkg-convert moved to libs.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Dec 02 02:22:09 2014 +0200 (2014-12-02) |
parents | |
children | 1d7f3c9ce99c |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tazpkg-find-depends Tue Dec 02 02:22:09 2014 +0200 1.3 @@ -0,0 +1,77 @@ 1.4 +# /usr/lib/tazpkg-find-depends: this program is a part of TazPkg. 1.5 +# This file contains the functions that are common to tazpkg and tazpkg-convert, 1.6 +# and sourced by them. 1.7 + 1.8 + 1.9 +# Need by check_depends 1.10 +TMPLOCALSTATE= 1.11 + 1.12 + 1.13 +# Check for ELF file 1.14 + 1.15 +is_elf() 1.16 +{ 1.17 + [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] 1.18 +} 1.19 + 1.20 + 1.21 +# Print shared library dependencies 1.22 + 1.23 +ldd() 1.24 +{ 1.25 + LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null 1.26 +} 1.27 + 1.28 + 1.29 +# search dependencies for files in $TMP_DIR/$file/fs 1.30 + 1.31 +find_depends() 1.32 +{ 1.33 + DEFAULT_DEPENDS="glibc-base gcc-lib-base" 1.34 + 1.35 + [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$LOCALSTATE 1.36 + [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null 1.37 + for i in $TMPLOCALSTATE/files.list.lzma \ 1.38 + $TMPLOCALSTATE/undigest/*/files.list.lzma ; do 1.39 + [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list 1.40 + done 1.41 + 1.42 + find ${1:-$TMP_DIR/$file/fs} -type f | \ 1.43 + while read chkfile ; do 1.44 + is_elf $chkfile || continue 1.45 + case "$chkfile" in 1.46 + *.o|*.ko|*.ko.gz) continue;; 1.47 + esac 1.48 + 1.49 + ldd $chkfile | \ 1.50 + while read lib rem; do 1.51 + case "$lib" in 1.52 + statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;; 1.53 + esac 1.54 + find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue 1.55 + 1.56 + for dep in $(fgrep $lib files.list | cut -d: -f1); do 1.57 + case " $DEFAULT_DEPENDS " in 1.58 + *\ $dep\ *) continue 2;; 1.59 + esac 1.60 + grep -qs "^$dep$" $TMP_DIR/depends && continue 2 1.61 + done 1.62 + 1.63 + if [ -n "$dep" ]; then 1.64 + echo "$dep" >> $TMP_DIR/depends 1.65 + else 1.66 + grep -qs ^$lib$ $TMP_DIR/unresolved || 1.67 + echo "$lib" >> $TMP_DIR/unresolved 1.68 + fi 1.69 + done 1.70 + done 1.71 + 1.72 + spc="" 1.73 + sort < $TMP_DIR/depends 2> /dev/null | uniq | \ 1.74 + while read file; do 1.75 + echo -n "$spc$file" 1.76 + spc=" " 1.77 + done 1.78 +} 1.79 + 1.80 +