tazpkg view modules/tazpkg-find-depends @ rev 730

pkgs.cgi: html: remove "$SCRIPT_NAME" and replace "&" with "&".
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Dec 28 05:10:28 2014 +0200 (2014-12-28)
parents e19ff346ea9a
children 721c57a2f5f1
line source
1 # /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg.
2 # This file contains the functions that are common to tazpkg and tazpkg-convert,
3 # and sourced by them.
6 # Need by check_depends
7 TMPLOCALSTATE=
10 # Check for ELF file
12 is_elf()
13 {
14 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
15 }
18 # Print shared library dependencies
20 ldd()
21 {
22 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
23 }
26 # search dependencies for files in $TMP_DIR/$file/fs
28 find_depends()
29 {
30 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
32 [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB
33 [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null
34 for i in $TMPLOCALSTATE/files.list.lzma \
35 $TMPLOCALSTATE/undigest/*/files.list.lzma ; do
36 [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
37 done
39 find ${1:-$TMP_DIR/$file/fs} -type f | \
40 while read chkfile ; do
41 is_elf $chkfile || continue
42 case "$chkfile" in
43 *.o|*.ko|*.ko.gz) continue;;
44 esac
46 ldd $chkfile | \
47 while read lib rem; do
48 case "$lib" in
49 statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
50 esac
51 find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
53 for dep in $(fgrep $lib files.list | cut -d: -f1); do
54 case " $DEFAULT_DEPENDS " in
55 *\ $dep\ *) continue 2;;
56 esac
57 grep -qs "^$dep$" $TMP_DIR/depends && continue 2
58 done
60 if [ -n "$dep" ]; then
61 echo "$dep" >> $TMP_DIR/depends
62 else
63 grep -qs ^$lib$ $TMP_DIR/unresolved ||
64 echo "$lib" >> $TMP_DIR/unresolved
65 fi
66 done
67 done
69 spc=""
70 sort < $TMP_DIR/depends 2> /dev/null | uniq | \
71 while read file; do
72 echo -n "$spc$file"
73 spc=" "
74 done
75 }