Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,4 @@ makechrootpkg mkarchroot rebuildpkgs zsh_completion find-libdeps Makefile +4 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ BINPROGS = \ archbuild \ lddd \ finddeps \ rebuildpkgs rebuildpkgs \ find-libdeps SBINPROGS = \ mkarchroot \ Loading Loading @@ -67,6 +68,7 @@ install: install -m0644 ${CONFIGFILES} $(DESTDIR)$(PREFIX)/share/devtools for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides install -Dm0644 bash_completion $(DESTDIR)/etc/bash_completion.d/devtools install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco Loading @@ -80,6 +82,7 @@ uninstall: rm $(DESTDIR)/etc/bash_completion.d/devtools rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides dist: git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz Loading find-libdeps.in 0 → 100644 +100 −0 Original line number Diff line number Diff line #!/bin/bash set -e IGNORE_INTERNAL=0 if [[ $1 = "--ignore-internal" ]]; then IGNORE_INTERNAL=1 shift fi script_mode=${0##*/find-lib} case $script_mode in deps|provides) true;; *) echo "error: unknown mode $script_mode"; exit 1;; esac if [[ -z $1 ]]; then echo "${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 case ${script_mode} in deps) bsdtar -C $tmpdir -xf "$1";; provides)bsdtar -C $tmpdir -xf "$1" --include="*.so*";; esac 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 } process_sofile() { # 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}" ${soobjects[@]}; then # libfoo.so=1-64 echo "${soname}=${soversion}-${soarch}" soobjects=(${soobjects[@]} "${soname}=${soversion}-${soarch}") fi } case $script_mode in deps) find_args="-perm -u+x";; provides) find_args="-name *.so*";; esac find . -type f $find_args | while read filename; do if [[ $script_mode = "provides" ]]; then # ignore if we don't have a shared object if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then continue fi fi # 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 if [[ $script_mode = "provides" ]]; then # 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##*/}" process_sofile elif [[ $script_mode = "deps" ]]; then # 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 process_sofile done fi done Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -13,3 +13,4 @@ makechrootpkg mkarchroot rebuildpkgs zsh_completion find-libdeps
Makefile +4 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,8 @@ BINPROGS = \ archbuild \ lddd \ finddeps \ rebuildpkgs rebuildpkgs \ find-libdeps SBINPROGS = \ mkarchroot \ Loading Loading @@ -67,6 +68,7 @@ install: install -m0644 ${CONFIGFILES} $(DESTDIR)$(PREFIX)/share/devtools for l in ${COMMITPKG_LINKS}; do ln -sf commitpkg $(DESTDIR)$(PREFIX)/bin/$$l; done for l in ${ARCHBUILD_LINKS}; do ln -sf archbuild $(DESTDIR)$(PREFIX)/bin/$$l; done ln -sf find-libdeps $(DESTDIR)$(PREFIX)/bin/find-libprovides install -Dm0644 bash_completion $(DESTDIR)/etc/bash_completion.d/devtools install -Dm0644 zsh_completion $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools ln -sf archco $(DESTDIR)$(PREFIX)/bin/communityco Loading @@ -80,6 +82,7 @@ uninstall: rm $(DESTDIR)/etc/bash_completion.d/devtools rm $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_devtools rm -f $(DESTDIR)$(PREFIX)/bin/communityco rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides dist: git archive --format=tar --prefix=devtools-$(V)/ $(V) | gzip -9 > devtools-$(V).tar.gz Loading
find-libdeps.in 0 → 100644 +100 −0 Original line number Diff line number Diff line #!/bin/bash set -e IGNORE_INTERNAL=0 if [[ $1 = "--ignore-internal" ]]; then IGNORE_INTERNAL=1 shift fi script_mode=${0##*/find-lib} case $script_mode in deps|provides) true;; *) echo "error: unknown mode $script_mode"; exit 1;; esac if [[ -z $1 ]]; then echo "${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 case ${script_mode} in deps) bsdtar -C $tmpdir -xf "$1";; provides)bsdtar -C $tmpdir -xf "$1" --include="*.so*";; esac 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 } process_sofile() { # 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}" ${soobjects[@]}; then # libfoo.so=1-64 echo "${soname}=${soversion}-${soarch}" soobjects=(${soobjects[@]} "${soname}=${soversion}-${soarch}") fi } case $script_mode in deps) find_args="-perm -u+x";; provides) find_args="-name *.so*";; esac find . -type f $find_args | while read filename; do if [[ $script_mode = "provides" ]]; then # ignore if we don't have a shared object if ! LC_ALL=C readelf -h "$filename" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then continue fi fi # 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 if [[ $script_mode = "provides" ]]; then # 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##*/}" process_sofile elif [[ $script_mode = "deps" ]]; then # 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 process_sofile done fi done