From 810395db5953543e0b829a73c47c85d4447791ac Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 28 May 2011 16:33:29 +0200 Subject: rename sodeps->libdeps Signed-off-by: Florian Pritz --- find-libdeps.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ find-libprovides.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ find-sodeps.sh | 42 ------------------------------------------ find-soprovides.sh | 45 --------------------------------------------- 4 files changed, 87 insertions(+), 87 deletions(-) create mode 100755 find-libdeps.sh create mode 100755 find-libprovides.sh delete mode 100755 find-sodeps.sh delete mode 100755 find-soprovides.sh diff --git a/find-libdeps.sh b/find-libdeps.sh new file mode 100755 index 0000000..0c93548 --- /dev/null +++ b/find-libdeps.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +if [[ -z $1 ]]; then + echo "$(basename "$0") " + exit 1 +fi + +tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) +trap "rm -rf '$tmpdir'" EXIT INT TERM + +tar -C $tmpdir -xf "$1" + +cd $tmpdir + +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 -executable | 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 ! 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 new file mode 100755 index 0000000..452af1a --- /dev/null +++ b/find-libprovides.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +if [[ -z $1 ]]; then + echo "$(basename "$0") " + exit 1 +fi + +tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) +trap "rm -rf '$tmpdir'" EXIT INT TERM + +tar -C $tmpdir -xf "$1" + +cd $tmpdir + +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 ! in_array "${soname}=${soversion}-${soarch}" ${soprovides[@]}; then + # libfoo.so=1-64 + echo "${soname}=${soversion}-${soarch}" + soprovides=(${soprovides[@]} "${soname}=${soversion}-${soarch}") + fi + fi +done + diff --git a/find-sodeps.sh b/find-sodeps.sh deleted file mode 100755 index 0c93548..0000000 --- a/find-sodeps.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -if [[ -z $1 ]]; then - echo "$(basename "$0") " - exit 1 -fi - -tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) -trap "rm -rf '$tmpdir'" EXIT INT TERM - -tar -C $tmpdir -xf "$1" - -cd $tmpdir - -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 -executable | 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 ! 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-soprovides.sh b/find-soprovides.sh deleted file mode 100755 index 452af1a..0000000 --- a/find-soprovides.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -if [[ -z $1 ]]; then - echo "$(basename "$0") " - exit 1 -fi - -tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX) -trap "rm -rf '$tmpdir'" EXIT INT TERM - -tar -C $tmpdir -xf "$1" - -cd $tmpdir - -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 ! in_array "${soname}=${soversion}-${soarch}" ${soprovides[@]}; then - # libfoo.so=1-64 - echo "${soname}=${soversion}-${soarch}" - soprovides=(${soprovides[@]} "${soname}=${soversion}-${soarch}") - fi - fi -done - -- cgit v1.2.3-24-g4f1b