tazpkg view modules/find-depends @ rev 846

Remove "busybox" "prefixes" (thanks llev)
We used "busybox wget", etc. to be sure we called Busybox's "wget", not any other "wget". Workaround already done in "getenv" module.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Oct 09 13:14:01 2015 +0300 (2015-10-09)
parents a02e36d44d06
children 3af642cd5e69
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager, hg.slitaz.org/tazpkg
3 # find-depends - TazPkg module
4 # Functions that are common to tazpkg and tazpkg-convert, and sourced by them.
7 # search dependencies for files in $TMP_DIR/$file/fs
9 find_depends() {
10 DEFAULT_DEPENDS='glibc-base gcc-lib-base'
12 [ ! -f "$PKGS_DB/files.list.lzma" ] && tazpkg recharge >/dev/null
14 for i in "$PKGS_DB/files.list.lzma" \
15 "$PKGS_DB/undigest/"*"/files.list.lzma"; do
16 [ -f "$i" ] && lzma d "$i" -so >> "$TMP_DIR/files.list"
17 done
19 _ 'Find depends...' 1>&2
20 libs_found=''
21 find "$1" -type f | \
22 while read chkfile; do
23 [ "$(dd bs=1 skip=1 count=3 < "$chkfile" 2>/dev/null)" != 'ELF' ] && continue
25 case "$chkfile" in
26 *.o|*.ko|*.ko.gz|*.ko.xz) continue;;
27 esac
29 for lib in $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so "$chkfile" 2>/dev/null | sed '/=>/!d;s/ =>.*//'); do
30 case " $libs_found " in
31 *\ $lib\ *) continue;;
32 esac
33 libs_found="$libs_found $lib"
34 case "$lib" in
35 statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;;
36 esac
37 find "${1:-$TMP_DIR/$file/fs}" | grep -q /$lib$ && continue
39 _n 'for %s' "$lib" 1>&2
40 echo -ne ' \r' 1>&2
42 for dep in $(fgrep "$lib" "$TMP_DIR/files.list" | cut -d: -f1); do
43 case " $DEFAULT_DEPENDS " in
44 *\ $dep\ *) continue 2;;
45 esac
46 grep -qs "^$dep$" "$TMP_DIR/depends" && continue 2
47 done
49 if [ -n "$dep" ]; then
50 echo "$dep" >> "$TMP_DIR/depends"
51 else
52 grep -qs ^$lib$ "$TMP_DIR/unresolved" ||
53 echo "$lib" >> "$TMP_DIR/unresolved"
54 fi
55 done
56 done
58 spc=''
59 [ -s "$TMP_DIR/depends" ] &&
60 sort < "$TMP_DIR/depends" 2>/dev/null | uniq | \
61 while read file; do
62 echo -n "$spc$file"
63 spc=' '
64 done
65 }