summaryrefslogtreecommitdiff
path: root/find-libdeps.in
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-11-01 15:33:08 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-11-01 15:33:08 +0100
commitaaa68e49e8e5a68950a63b9aa4a8c1f6aed2e2d2 (patch)
treef28082b5951313ca95959c82be1b0ad357e55290 /find-libdeps.in
parent7c78599a61e3652f43fce33826aef7b443590b83 (diff)
downloaddevtools-aaa68e49e8e5a68950a63b9aa4a8c1f6aed2e2d2.tar.xz
Move common functions to a shared file
* common.sh is included on build time * most functions are copied from makepkg
Diffstat (limited to 'find-libdeps.in')
-rw-r--r--find-libdeps.in34
1 files changed, 10 insertions, 24 deletions
diff --git a/find-libdeps.in b/find-libdeps.in
index 8fff939..3f44903 100644
--- a/find-libdeps.in
+++ b/find-libdeps.in
@@ -1,5 +1,7 @@
#!/bin/bash
+m4_include(lib/common.sh)
+
set -e
IGNORE_INTERNAL=0
@@ -13,7 +15,7 @@ script_mode=${0##*/find-lib}
case $script_mode in
deps|provides) true;;
- *) echo "error: unknown mode $script_mode"; exit 1;;
+ *) die "unknown mode $script_mode" ;;
esac
if [[ -z $1 ]]; then
@@ -23,36 +25,19 @@ if [[ -z $1 ]]; then
exit 1
fi
-cleanup() {
- if [[ $tmpdir ]]; then
- rm -rf $tmpdir;
- fi
-}
-
if [[ -d $1 ]]; then
- cd $1
+ pushd $1 >/dev/null
else
- tmpdir=$(mktemp -d /tmp/find-sodeps.XXXXXXX)
- trap "cleanup" EXIT INT TERM
+ setup_workdir
case ${script_mode} in
- deps) bsdtar -C $tmpdir -xf "$1";;
- provides)bsdtar -C $tmpdir -xf "$1" --include="*.so*";;
+ deps) bsdtar -C $WORKDIR -xf "$1";;
+ provides) bsdtar -C $WORKDIR -xf "$1" --include="*.so*";;
esac
- cd $tmpdir
+ pushd $WORKDIR >/dev/null
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"
@@ -68,7 +53,7 @@ process_sofile() {
fi
}
-case $script_mode in
+case $script_mode in
deps) find_args="-perm -u+x";;
provides) find_args="-name *.so*";;
esac
@@ -98,3 +83,4 @@ find . -type f $find_args | while read filename; do
fi
done
+popd >/dev/null