summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-05 23:54:25 +0200
committerDave Reisner <dreisner@archlinux.org>2012-05-06 00:19:12 +0200
commit0a3fd7d5f00913e08f452ca9dae0926f7124bb4d (patch)
treed38247449bb487781f4ca3658dad668ef3d74e01
parent9a1971d9521c3b835a6860c5d04911e6d14b9bf0 (diff)
downloadrepo-tools-0a3fd7d5f00913e08f452ca9dae0926f7124bb4d.tar.gz
repo-tools-0a3fd7d5f00913e08f452ca9dae0926f7124bb4d.tar.xz
createlinks: avoid for loop in parsing shared libs
readelf can take multiple targets, so parse everything at once since we only care about the complete set of dependencies rather than deps per ELF object.
-rwxr-xr-xcreatelinks9
1 files changed, 5 insertions, 4 deletions
diff --git a/createlinks b/createlinks
index 52ade34..cf8fa3d 100755
--- a/createlinks
+++ b/createlinks
@@ -7,6 +7,8 @@ arches=('i686' 'x86_64')
lock='/tmp/mirrorsync.lck'
tmp="$(mktemp -d)"
+extractinc=(--include={opt,{,usr/}{lib{,32},{s,}bin}}'/*')
+
[ -f "${lock}" ] && exit 1
touch "${lock}"
trap "rm -rf '${lock}' '${tmp}'" EXIT INT TERM
@@ -48,10 +50,9 @@ for repo in ${repos[@]}; do
else
echo "$repo/$arch: $pkgname"
mkdir -p ${tmppkgdir}/pkg
- bsdtar -xof $pkg -C ${tmppkgdir}/pkg --include={opt,{,usr/}{lib{,32},{s,}bin}}'/*' 2>/dev/null
- for f in $(find ${tmppkgdir}/pkg -type f); do
- readelf -d "$f" 2> /dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p'
- done | sort -u > ${tmppkgdir}/links
+ bsdtar -xof "$pkg" -C "$tmppkgdir/pkg" "${extractinc[@]}" 2>/dev/null
+ find "$tmppkgdir/pkg" -type f -exec readelf -d {} + 2>/dev/null |
+ sed -nr 's/.*Shared library: \[(.*)\]$/\1/p' | sort -u >"$tmppkgdir/links"
rm -rf ${tmppkgdir}/pkg
cached=false
fi