summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-05-06 00:18:38 +0200
committerDave Reisner <dreisner@archlinux.org>2012-05-06 00:19:55 +0200
commit1b3808e2b940985173675502bba0044c624945ce (patch)
treedb96c6925682fab895e8f966df0bfa392b7e2be1
parent4acd4465d8a69d8fcecb86df9a51fd64d38c7a8c (diff)
downloadrepo-tools-1b3808e2b940985173675502bba0044c624945ce.tar.gz
repo-tools-1b3808e2b940985173675502bba0044c624945ce.tar.xz
createlinks: move links file creation to separate function
-rwxr-xr-xcreatelinks35
1 files changed, 22 insertions, 13 deletions
diff --git a/createlinks b/createlinks
index 4bf7b7f..1295093 100755
--- a/createlinks
+++ b/createlinks
@@ -16,6 +16,26 @@ getpkgname() {
echo ${tmp%-*.pkg.tar.*}
}
+create_file_list() {
+ local pkgname=$(getpkgname "$1")
+
+ tmppkgdir=$tmp/tmp/$repodir/$pkgname
+ mkdir -p "$tmppkgdir"
+ if [[ -f $tmp/cache/$repodir/$pkgname/links ]]; then
+ # reuse the cached file
+ mv "$tmp/cache/$repodir/$pkgname/links" "$tmppkgdir/links"
+ return 0
+ else
+ echo "$repo/$arch: $pkgname"
+ mkdir -p "$tmppkgdir/pkg"
+ 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"
+ return 1
+ fi
+}
+
generate_links() {
for repo in ${repos[@]}; do
for arch in ${arches[@]}; do
@@ -35,19 +55,8 @@ generate_links() {
for pkg in "$target/$repodir"/*.pkg.tar.?z; do
[[ -f $pkg ]] || continue
- pkgname=$(getpkgname $pkg)
- tmppkgdir=${tmp}/tmp/${repodir}/${pkgname}
- mkdir -p $tmppkgdir
- if [ -f "${tmp}/cache/${repodir}/${pkgname}/links" ]; then
- # reuse the cached file
- mv ${tmp}/cache/${repodir}/${pkgname}/links ${tmppkgdir}/links
- else
- echo "$repo/$arch: $pkgname"
- mkdir -p ${tmppkgdir}/pkg
- bsdtar -xvof "$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
+ create_file_list "$pkg"
+ if (( $? != 0 )); then
cached=false
fi
done