diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-11 14:13:29 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-02-02 16:44:15 -0800 |
commit | 3e50764d5c6d0e05c89857f71d4016f835a93217 (patch) | |
tree | 9e5eb36b74f8f8fd6d2f05f3821992a9b2f5e215 | |
parent | 8966e44f90581477f689e6e6673dec4cd0f44c30 (diff) | |
download | rpm-3e50764d5c6d0e05c89857f71d4016f835a93217.tar.gz rpm-3e50764d5c6d0e05c89857f71d4016f835a93217.tar.bz2 rpm-3e50764d5c6d0e05c89857f71d4016f835a93217.zip |
auto dependencies
-rw-r--r-- | autodeps/linux.prov | 70 | ||||
-rw-r--r-- | autodeps/linux.req | 91 |
2 files changed, 93 insertions, 68 deletions
diff --git a/autodeps/linux.prov b/autodeps/linux.prov index 8547dc3dd..26272d8f5 100644 --- a/autodeps/linux.prov +++ b/autodeps/linux.prov @@ -2,60 +2,72 @@ # This script reads filenames from STDIN and outputs any relevant provides # information that needs to be included in the package. +IFS=$'\n' +filelist=($(cat)) -filelist=`sed "s/['\"]/\\\&/g"` - -solist=$(echo $filelist | grep "\\.so" | grep -v "^/lib/ld.so" | \ - xargs file -L 2>/dev/null | grep "ELF.*shared object" | cut -d: -f1) +solist=($(printf "%s\n" "${filelist[@]}" | grep "\\.so" | grep -v "^/lib/ld.so" | \ + tr '\n' '\0' | xargs -0 -r file -L | grep "ELF.*shared object" | \ + cut -d: -f1)) pythonlist= tcllist= +monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$")) # # --- Alpha does not mark 64bit dependencies case `uname -m` in - alpha*) mark64="" ;; - *) mark64="()(64bit)" ;; + alpha*) mark64=false ;; + *) mark64=true ;; esac # # --- Library sonames and weak symbol versions (from glibc). -for f in $solist; do - soname=$(objdump -p $f | awk '/SONAME/ {print $2}') - - lib64=`if file -L $f 2>/dev/null | \ - grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` - if [ "$soname" != "" ]; then - if [ ! -L $f ]; then - echo $soname$lib64 - objdump -p $f | awk ' - BEGIN { START=0 ; } - /Version definitions:/ { START=1; } - /^[0-9]/ && (START==1) { print $4; } - /^$/ { START=0; } - ' | \ - grep -v $soname | \ - while read symbol ; do - echo "$soname($symbol)`echo $lib64 | sed 's/()//'`" - done - fi +for f in "${solist[@]}"; do + soname=$(objdump -p "$f" | awk '/SONAME/ {print $2}') + [ -n "$soname" -a -L "$f" ] && continue + [ -z "$soname" ] && soname="${f##*/}" + + if $mark64 && file -L "$f" 2>/dev/null | grep "ELF 64-bit" >/dev/null; then + lib64="()(64bit)" slib64="(64bit)" else - echo ${f##*/}$lib64 + lib64= slib64= fi + echo "$soname$lib64" + objdump -p "$f" | awk ' + BEGIN { START=0 ; } + /Version definitions:/ { START=1; } + /^[0-9]/ && (START==1) { print $4; } + /^$/ { START=0; } + ' | \ + while read symbol ; do + echo "$soname($symbol)$slib64" + done done | sort -u # # --- Perl modules. [ -x /usr/lib/rpm/perl.prov ] && - echo $filelist | tr '[:blank:]' \\n | grep '\.pm$' | /usr/lib/rpm/perl.prov | sort -u + printf "%s\n" "${filelist[@]}" | grep '\.pm$' | /usr/lib/rpm/perl.prov | sort -u # # --- Python modules. [ -x /usr/lib/rpm/python.prov -a -n "$pythonlist" ] && - echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.prov | sort -u + printf "%s\n" "${pythonlist[@]}" | /usr/lib/rpm/python.prov | sort -u # # --- Tcl modules. [ -x /usr/lib/rpm/tcl.prov -a -n "$tcllist" ] && - echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.prov | sort -u + printf "%s\n" "${tcllist[@]}" | /usr/lib/rpm/tcl.prov | sort -u + +# +# --- Mono exes/dlls +: ${MONO_PREFIX=/usr} +if [ -x $MONO_PREFIX/bin/mono -a -n "$monolist" ] ; then + printf "%s\n" "${monolist[@]}" | MONO_PATH=$MONO_PREFIX/lib${MONO_PATH:+:$MONO_PATH} prefix=$MONO_PREFIX $MONO_PREFIX/bin/mono-find-provides || echo "WARNING: MONO RPM PROVIDES WERE NOT GENERATED FOR THIS BUILD!!" 1>&2 +fi + +# +# --- Kernel module exported symbols +[ -x /usr/lib/rpm/find-provides.ksyms ] && + printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/find-provides.ksyms "$@" exit 0 diff --git a/autodeps/linux.req b/autodeps/linux.req index b9a8f999c..2f016d04d 100644 --- a/autodeps/linux.req +++ b/autodeps/linux.req @@ -18,20 +18,21 @@ fi # # --- Grab the file manifest and classify files. -#filelist=`sed "s/['\"]/\\\&/g"` -filelist=`sed "s/[]['\"*?{}]/\\\\\&/g"` -exelist=`echo $filelist | xargs -r file | \ +#filelist=`sed "s/[]['\"*?{}]/\\\\\&/g"` +filelist=($(grep -Ev '/usr/doc/|/usr/share/doc/')) +exelist=($(printf "%s\0" "${filelist[@]}" | xargs -0 -r file | \ grep -Ev ":.* (commands|script)[, ]" | \ - grep ":.*executable" | cut -d: -f1` -scriptlist=`echo $filelist | xargs -r file | \ - grep -E ":.* (commands|script)[, ]" | cut -d: -f1` -liblist=`echo $filelist | xargs -r file | \ - grep ":.*shared object" | cut -d : -f1` + grep ":.*executable" | cut -d: -f1)) +scriptlist=($(printf "%s\0" "${filelist[@]}" | xargs -0 -r file | \ + grep -E ":.* (commands|script)[, ]" | cut -d: -f1)) +liblist=($(printf "%s\0" "${filelist[@]}" | xargs -0 -r file | \ + grep ":.*shared object" | cut -d : -f1)) -interplist= -perllist= -pythonlist= -tcllist= +interplist=() +perllist=() +pythonlist=() +tcllist=() +monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)(\\.config)?\$")) # # --- Alpha does not mark 64bit dependencies @@ -43,12 +44,12 @@ esac if [ "$needed" -eq 0 ]; then # # --- Executable dependency sonames. - for f in $exelist; do - [ -r $f -a -x $f ] || continue - lib64=`if file -L $f 2>/dev/null | \ + for f in "${exelist[@]}"; do + [ -r "$f" -a -x "$f" ] || continue + lib64=`if file -L "$f" 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` - ldd $f | awk '/=>/ { - if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { + ldd "$f" | awk '/=>/ { + if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /linux-gate.so/) { gsub(/'\''"/,"\\&",$1); printf "%s'$lib64'\n", $1 } @@ -57,12 +58,12 @@ if [ "$needed" -eq 0 ]; then # # --- Library dependency sonames. - for f in $liblist; do - [ -r $f ] || continue - lib64=`if file -L $f 2>/dev/null | \ + for f in "${liblist[@]}"; do + [ -r "$f" ] || continue + lib64=`if file -L "$f" 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` - ldd $f | awk '/=>/ { - if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /libredhat-kernel.so/) { + ldd "$f" | awk '/=>/ { + if ($1 !~ /libNoVersion.so/ && $1 !~ /4[um]lib.so/ && $1 !~ /linux-gate.so/) { gsub(/'\''"/,"\\&",$1); printf "%s'$lib64'\n", $1 } @@ -72,30 +73,30 @@ fi # # --- Script interpreters. -for f in $scriptlist; do - [ -r $f -a -x $f ] || continue - interp=`head -n 1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1` - interplist="$interplist $interp" +for f in "${scriptlist[@]}"; do + [ -r "$f" -a -x "$f" ] || continue + interp=`head -n 1 "$f" | sed -ne 's/^\#\![ ]*//p' | cut -d" " -f1` + interplist=("${interplist[@]}" "$interp") case $interp in - */perl) perllist="$perllist $f" ;; + */perl) perllist=("${perllist[@]}" "$f") ;; esac done -[ -n "$interplist" ] && { echo "$interplist" | tr '[:blank:]' \\n | sort -u ; } +[ -n "$interplist" ] && { printf "%s\n" "${interplist[@]}" | sort -u ; } # # --- Add perl module files to perllist. -for f in $filelist; do - [ -r $f -a "${f%.pm}" != "${f}" ] && perllist="$perllist $f" +for f in "${filelist[@]}"; do + [ -r "$f" -a "${f%.pm}" != "${f}" ] && perllist=("${perllist[@]}" "$f") done # # --- Weak symbol versions (from glibc). [ -n "$mark64" ] && mark64="(64bit)" -for f in $liblist $exelist ; do - [ -r $f ] || continue - lib64=`if file -L $f 2>/dev/null | \ +for f in "${liblist[@]}" "${exelist[@]}" ; do + [ -r "$f" ] || continue + lib64=`if file -L "$f" 2>/dev/null | \ grep "ELF 64-bit" >/dev/null; then echo "$mark64"; fi` - objdump -p $f | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; } + objdump -p "$f" | awk 'BEGIN { START=0; LIBNAME=""; needed='$needed'; } /^$/ { START=0; } /^Dynamic Section:$/ { START=1; } (START==1) && /NEEDED/ { @@ -112,7 +113,7 @@ for f in $liblist $exelist ; do sub(/:/, "", $3); LIBNAME=$3; } - (START==2) && (LIBNAME!="") && ($4!="") && (($4~/^GLIBC_*/) || ($4~/^GCC_*/)) { + (START==2) && (LIBNAME!="") && ($4!="") { print LIBNAME "(" $4 ")'$lib64'"; } ' @@ -120,17 +121,29 @@ done | sort -u # # --- Perl modules. -[ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \ - echo $perllist | tr '[:blank:]' \\n | /usr/lib/rpm/perl.req | sort -u +#[ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \ +# printf "%s\n" "${perllist[@]}" | /usr/lib/rpm/perl.req | sort -u # # --- Python modules. [ -x /usr/lib/rpm/python.req -a -n "$pythonlist" ] && \ - echo $pythonlist | tr '[:blank:]' \\n | /usr/lib/rpm/python.req | sort -u + printf "%s\n" "${pythonlist[@]}" | /usr/lib/rpm/python.req | sort -u # # --- Tcl modules. [ -x /usr/lib/rpm/tcl.req -a -n "$tcllist" ] && \ - echo $tcllist | tr '[:blank:]' \\n | /usr/lib/rpm/tcl.req | sort -u + printf "%s\n" "${tcllist[@]}" | /usr/lib/rpm/tcl.req | sort -u + +# +# --- Mono exes/dlls +: ${MONO_PREFIX=/usr} +if [ -x $MONO_PREFIX/bin/mono -a -n "$monolist" ] ; then + printf "%s\n" "${monolist[@]}" | MONO_PATH=$MONO_PREFIX/lib${MONO_PATH:+:$MONO_PATH} prefix=$MONO_PREFIX $MONO_PREFIX/bin/mono-find-requires || echo "WARNING: MONO RPM REQUIRES WERE NOT GENERATED FOR THIS BUILD!!" 1>&2 +fi + +# +# --- Kernel module imported symbols +[ -x ${0%/*}/find-requires.ksyms ] && + printf "%s\n" "${filelist[@]}" | ${0%/*}/find-requires.ksyms "$@" exit 0 |