diff options
author | Florian Pritz <bluewind@xinu.at> | 2011-11-17 23:31:50 +0100 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2011-11-17 23:31:50 +0100 |
commit | 9726797027faa90ebc02fcc1b1f32e71158e11b0 (patch) | |
tree | 0b32df15d59d6b764a923cd769cdc023a16b444a | |
parent | 647ed2f2f70d91612e99c13e9bc931324c1a60ae (diff) | |
download | bin-9726797027faa90ebc02fcc1b1f32e71158e11b0.tar.gz bin-9726797027faa90ebc02fcc1b1f32e71158e11b0.tar.xz |
find-lib* moved to devtools
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-x | find-libdeps.sh | 67 | ||||
-rwxr-xr-x | find-libprovides.sh | 63 |
2 files changed, 0 insertions, 130 deletions
diff --git a/find-libdeps.sh b/find-libdeps.sh deleted file mode 100755 index 4122c2b..0000000 --- a/find-libdeps.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -set -e - -IGNORE_INTERNAL=0 - -if [[ $1 = "--ignore-internal" ]]; then - IGNORE_INTERNAL=1 - shift -fi - -if [[ -z $1 ]]; then - echo "$(basename "$0") [options] <package file|extracted package dir>" - echo "Options:" - echo " --ignore-internal ignore internal libraries" - exit 1 -fi - - -cleanup() { - if [[ $tmpdir ]]; then - rm -rf $tmpdir; - fi -} - -if [[ -d $1 ]]; then - cd $1 -else - tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) - trap "cleanup" EXIT INT TERM - - bsdtar -C $tmpdir -xf "$1" - - cd $tmpdir -fi - -in_array() { - local needle=$1; shift - [[ -z $1 ]] && return 1 # Not Found - local item - for item in "$@"; do - [[ $item = $needle ]] && return 0 # Found - done - return 1 # Not Found -} - -find . -type f -perm -u+x | while read filename; do - # get architecture of the file; if soarch is empty it's not an ELF binary - soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p') - [ -n "$soarch" ] || continue - # process all libraries needed by the binary - for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p') - do - # extract the library name: libfoo.so - soname="${sofile%%\.so\.*}.so" - # extract the major version: 1 - soversion="${sofile##*\.so\.}" - if [[ "$soversion" = "$sofile" ]] && (($IGNORE_INTERNAL)); then - continue - fi - if ! in_array "${soname}=${soversion}-${soarch}" ${sodepends[@]}; then - # libfoo.so=1-64 - echo "${soname}=${soversion}-${soarch}" - sodepends=(${sodepends[@]} "${soname}=${soversion}-${soarch}") - fi - done -done diff --git a/find-libprovides.sh b/find-libprovides.sh deleted file mode 100755 index cfd6f6c..0000000 --- a/find-libprovides.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash - -set -e - -IGNORE_INTERNAL=0 - -if [[ $1 = "--ignore-internal" ]]; then - IGNORE_INTERNAL=1 - shift -fi - -if [[ -z $1 ]]; then - echo "$(basename "$0") [options] <package file|extracted package dir>" - echo "Options:" - echo " --ignore-internal ignore internal libraries" - exit 1 -fi - -if [[ -d $1 ]]; then - cd $1 -else - tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) - trap "rm -rf '$tmpdir'" EXIT INT TERM - - bsdtar -C $tmpdir -xf "$1" --include="*.so*" - - cd $tmpdir -fi - -in_array() { - local needle=$1; shift - [[ -z $1 ]] && return 1 # Not Found - local item - for item in "$@"; do - [[ $item = $needle ]] && return 0 # Found - done - return 1 # Not Found -} -find . -type f -name \*.so\* | while read filename -do - # check if we really have a shared object - if LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then - # 64 - soarch=$(LC_ALL=C readelf -h "$filename" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p') - # get the string binaries link to: libfoo.so.1.2 -> libfoo.so.1 - sofile=$(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p') - [ -z "$sofile" ] && sofile="${filename##*/}" - - # extract the library name: libfoo.so - soname="${sofile%%\.so\.*}.so" - # extract the major version: 1 - soversion="${sofile##*\.so\.}" - if [[ "$soversion" = "$sofile" ]] && (($IGNORE_INTERNAL)); then - continue - fi - if ! in_array "${soname}=${soversion}-${soarch}" ${soprovides[@]}; then - # libfoo.so=1-64 - echo "${soname}=${soversion}-${soarch}" - soprovides=(${soprovides[@]} "${soname}=${soversion}-${soarch}") - fi - fi -done - |