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