diff options
Diffstat (limited to 'find-sodeps.sh')
-rwxr-xr-x | find-sodeps.sh | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/find-sodeps.sh b/find-sodeps.sh index 8836906..b522cee 100755 --- a/find-sodeps.sh +++ b/find-sodeps.sh @@ -22,17 +22,22 @@ in_array() { return 1 # Not Found } - find . -type f | while read filename do - soarch=$(objdump -a "$filename" 2>/dev/null | sed -rn 's/.* file format (.*)$/\1/p' | tr - _) + # 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 - for sofile in $(readelf -d "$filename" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p') + # 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 - soname=$(sed -rn 's/(.*)\.so.*/\1.so/p' <<< "$sofile") - if ! in_array "${soname}" ${sodepends[@]}; then - echo "${soname}" - sodepends=(${sodepends[@]} "${soname}") - fi + # 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 |