tazpkg annotate modules/tazpkg-find-depends @ rev 749

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