tazpkg diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/find-depends Sat Jul 25 16:50:18 2015 +0300 1.3 @@ -0,0 +1,85 @@ 1.4 +#!/bin/sh 1.5 +# /usr/lib/tazpkg/tazpkg-find-depends: this program is a part of TazPkg. 1.6 +# This file contains the functions that are common to tazpkg and tazpkg-convert, 1.7 +# and sourced by them. 1.8 + 1.9 + 1.10 +# Need by check_depends 1.11 +TMPLOCALSTATE= 1.12 + 1.13 + 1.14 +# Check for ELF file 1.15 + 1.16 +is_elf() 1.17 +{ 1.18 + [ "$(dd if="$1" bs=1 skip=1 count=3 2>/dev/null)" == "ELF" ] 1.19 +} 1.20 + 1.21 + 1.22 +# Print shared library dependencies 1.23 + 1.24 +ldd() 1.25 +{ 1.26 + LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so "$1" 2>/dev/null 1.27 +} 1.28 + 1.29 + 1.30 +# search dependencies for files in $TMP_DIR/$file/fs 1.31 + 1.32 +find_depends() 1.33 +{ 1.34 + DEFAULT_DEPENDS="glibc-base gcc-lib-base" 1.35 + 1.36 + [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB 1.37 + [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge >/dev/null 1.38 + for i in $TMPLOCALSTATE/files.list.lzma \ 1.39 + $TMPLOCALSTATE/undigest/*/files.list.lzma ; do 1.40 + [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list 1.41 + done 1.42 + 1.43 + echo "Find depends..." 1>&2 1.44 + libs_found="" 1.45 + find ${1:-$TMP_DIR/$file/fs} -type f | \ 1.46 + while read chkfile ; do 1.47 + is_elf "$chkfile" || continue 1.48 + case "$chkfile" in 1.49 + *.o|*.ko|*.ko.gz) continue;; 1.50 + esac 1.51 + 1.52 + for lib in $(ldd "$chkfile" | sed '/=>/!d;s/ =>.*//') ; do 1.53 + case " $libs_found " in 1.54 + *\ $lib\ *) continue 1.55 + esac 1.56 + libs_found="$libs_found $lib" 1.57 + case "$lib" in 1.58 + statically|linux-gate.so*|ld-*.so|*/ld-*.so) continue;; 1.59 + esac 1.60 + find ${1:-$TMP_DIR/$file/fs} | grep -q /$lib$ && continue 1.61 + 1.62 + echo -ne "for $lib \r" 1>&2 1.63 + for dep in $(fgrep $lib files.list | cut -d: -f1); do 1.64 + case " $DEFAULT_DEPENDS " in 1.65 + *\ $dep\ *) continue 2;; 1.66 + esac 1.67 + grep -qs "^$dep$" $TMP_DIR/depends && continue 2 1.68 + done 1.69 + 1.70 + if [ -n "$dep" ]; then 1.71 + echo "$dep" >> $TMP_DIR/depends 1.72 + else 1.73 + grep -qs ^$lib$ $TMP_DIR/unresolved || 1.74 + echo "$lib" >> $TMP_DIR/unresolved 1.75 + fi 1.76 + done 1.77 + done 1.78 + 1.79 + spc="" 1.80 + [ -s $TMP_DIR/depends ] && 1.81 + sort < $TMP_DIR/depends 2>/dev/null | uniq | \ 1.82 + while read file; do 1.83 + echo -n "$spc$file" 1.84 + spc=" " 1.85 + done 1.86 +} 1.87 + 1.88 +