tazpkg view modules/find-depends @ rev 822

Add README.devel; introduce libexec for modules; rename modules; support install variables in Makefile.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Jul 25 16:50:18 2015 +0300 (2015-07-25)
parents
children 2f3580bd8c0c
line source
1 #!/bin/sh
2 # /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg.
3 # This file contains the functions that are common to tazpkg and tazpkg-convert,
4 # and sourced by them.
7 # Need by check_depends
8 TMPLOCALSTATE=
11 # Check for ELF file
13 is_elf()
14 {
15 [ "$(dd if="$1" bs=1 skip=1 count=3 2>/dev/null)" == "ELF" ]
16 }
19 # Print shared library dependencies
21 ldd()
22 {
23 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so "$1" 2>/dev/null
24 }
27 # search dependencies for files in $TMP_DIR/$file/fs
29 find_depends()
30 {
31 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
33 [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB
34 [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge >/dev/null
35 for i in $TMPLOCALSTATE/files.list.lzma \
36 $TMPLOCALSTATE/undigest/*/files.list.lzma ; do
37 [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list
38 done
40 echo "Find depends..." 1>&2
41 libs_found=""
42 find ${1:-$TMP_DIR/$file/fs} -type f | \
43 while read chkfile ; do
44 is_elf "$chkfile" || continue
45 case "$chkfile" in
46 *.o|*.ko|*.ko.gz) continue;;
47 esac
49 for lib in $(ldd "$chkfile" | sed '/=>/!d;s/ =>.*//') ; do
50 case " $libs_found " in
51 *\ $lib\ *) continue
52 esac
53 libs_found="$libs_found $lib"
54 case "$lib" in
55 statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
56 esac
57 find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue
59 echo -ne "for $lib \r" 1>&2
60 for dep in $(fgrep $lib files.list | cut -d: -f1); do
61 case " $DEFAULT_DEPENDS " in
62 *\ $dep\ *) continue 2;;
63 esac
64 grep -qs "^$dep$" $TMP_DIR/depends && continue 2
65 done
67 if [ -n "$dep" ]; then
68 echo "$dep" >> $TMP_DIR/depends
69 else
70 grep -qs ^$lib$ $TMP_DIR/unresolved ||
71 echo "$lib" >> $TMP_DIR/unresolved
72 fi
73 done
74 done
76 spc=""
77 [ -s $TMP_DIR/depends ] &&
78 sort < $TMP_DIR/depends 2>/dev/null | uniq | \
79 while read file; do
80 echo -n "$spc$file"
81 spc=" "
82 done
83 }