tazpkg annotate tazpkg-find-depends @ rev 708

tazpkg: Return "Done" to right column in tazpanel/tazbox (was in new line)
author Xander Ziiryanoff <psychomaniak@xakep.ru>
date Sat Dec 13 17:15:22 2014 +0000 (2014-12-13)
parents 1d7f3c9ce99c
children
rev   line source
psychomaniak@708 1 # /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg.
al@695 2 # This file contains the functions that are common to tazpkg and tazpkg-convert,
al@695 3 # and sourced by them.
al@695 4
al@695 5
al@695 6 # Need by check_depends
al@695 7 TMPLOCALSTATE=
al@695 8
al@695 9
al@695 10 # Check for ELF file
al@695 11
al@695 12 is_elf()
al@695 13 {
al@695 14 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
al@695 15 }
al@695 16
al@695 17
al@695 18 # Print shared library dependencies
al@695 19
al@695 20 ldd()
al@695 21 {
al@695 22 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
al@695 23 }
al@695 24
al@695 25
al@695 26 # search dependencies for files in $TMP_DIR/$file/fs
al@695 27
al@695 28 find_depends()
al@695 29 {
al@695 30 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
al@695 31
al@700 32 [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB
al@695 33 [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null
al@695 34 for i in $TMPLOCALSTATE/files.list.lzma \
al@695 35 $TMPLOCALSTATE/undigest/*/files.list.lzma ; do
al@695 36 [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
al@695 37 done
al@695 38
al@695 39 find ${1:-$TMP_DIR/$file/fs} -type f | \
al@695 40 while read chkfile ; do
al@695 41 is_elf $chkfile || continue
al@695 42 case "$chkfile" in
al@695 43 *.o|*.ko|*.ko.gz) continue;;
al@695 44 esac
al@695 45
al@695 46 ldd $chkfile | \
al@695 47 while read lib rem; do
al@695 48 case "$lib" in
al@695 49 statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
al@695 50 esac
al@695 51 find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
al@695 52
al@695 53 for dep in $(fgrep $lib files.list | cut -d: -f1); do
al@695 54 case " $DEFAULT_DEPENDS " in
al@695 55 *\ $dep\ *) continue 2;;
al@695 56 esac
al@695 57 grep -qs "^$dep$" $TMP_DIR/depends && continue 2
al@695 58 done
al@695 59
al@695 60 if [ -n "$dep" ]; then
al@695 61 echo "$dep" >> $TMP_DIR/depends
al@695 62 else
al@695 63 grep -qs ^$lib$ $TMP_DIR/unresolved ||
al@695 64 echo "$lib" >> $TMP_DIR/unresolved
al@695 65 fi
al@695 66 done
al@695 67 done
al@695 68
al@695 69 spc=""
al@695 70 sort < $TMP_DIR/depends 2> /dev/null | uniq | \
al@695 71 while read file; do
al@695 72 echo -n "$spc$file"
al@695 73 spc=" "
al@695 74 done
al@695 75 }
al@695 76
al@695 77