tazpkg view modules/tazpkg-find-depends @ rev 764
pkgs.cgi: non root support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Apr 06 18:21:06 2015 +0200 (2015-04-06) |
parents | 721c57a2f5f1 |
children | c389814e4f9a |
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 echo "Find depends..." 1>&2
40 libs_found=""
41 find ${1:-$TMP_DIR/$file/fs} -type f | \
42 while read chkfile ; do
43 is_elf $chkfile || continue
44 case "$chkfile" in
45 *.o|*.ko|*.ko.gz) continue;;
46 esac
48 for lib in $(ldd $chkfile | sed '/=>/!d;s/ =>.*//') ; do
49 case " $libs_found " in
50 *\ $lib\ *) continue
51 esac
52 libs_found="$libs_found $lib"
53 case "$lib" in
54 statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
55 esac
56 find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
58 echo -ne "for $lib \r" 1>&2
59 for dep in $(fgrep $lib files.list | cut -d: -f1); do
60 case " $DEFAULT_DEPENDS " in
61 *\ $dep\ *) continue 2;;
62 esac
63 grep -qs "^$dep$" $TMP_DIR/depends && continue 2
64 done
66 if [ -n "$dep" ]; then
67 echo "$dep" >> $TMP_DIR/depends
68 else
69 grep -qs ^$lib$ $TMP_DIR/unresolved ||
70 echo "$lib" >> $TMP_DIR/unresolved
71 fi
72 done
73 done
75 spc=""
76 [ -s $TMP_DIR/depends ] &&
77 sort < $TMP_DIR/depends 2> /dev/null | uniq | \
78 while read file; do
79 echo -n "$spc$file"
80 spc=" "
81 done
82 }