From 0f27ed17abb2898ad6ef4398c6647d2875a29197 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 30 Mar 2011 14:20:15 +0000 Subject: [PATCH] abuild: fix for apk-tools-2.0.x apk-tools-2.0's apk index will not show the arch so we need to use tar to find arch if we have old apk. We prefer use apk index since it will only read first block of file, regardless size, while tar will read entire file. Reading entire file is slow if file is big. So we check apk --version and use tar if needed, and apk index if possible. --- abuild.in | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/abuild.in b/abuild.in index 8a62d46..8349653 100755 --- a/abuild.in +++ b/abuild.in @@ -777,6 +777,10 @@ apk_arch_prefix() { apk index -q "$1" | tar -zxO | awk -F: '$1 == "A" { print $2 }' } +apk_arch_prefix_compat() { + tar -zxOf "$1" .PKGINFO | awk -F" = " '$1 == "arch" { print $2 }' +} + clean_abuildrepo() { local apk cd "$abuildrepo" || return 1 @@ -795,13 +799,17 @@ clean_abuildrepo() { } mklinks_abuildrepo() { - local apk + local apk get_prefix=apk_arch_prefix + local version=$($APK --version | awk '{print $2}') + if [ "$($APK version --test $version 2.1)" = '<' ]; then + get_prefix=apk_arch_prefix_compat + fi mkdir -p "$abuildrepo"/$CARCH "$abuildrepo"/noarch cd "$abuildrepo" || return 1 # create links for this package for apk in $(listpkg); do [ -f "$PKGDEST"/$apk ] || continue - local prefix=$(apk_arch_prefix "$PKGDEST"/$apk) + local prefix=$($get_prefix "$PKGDEST"/$apk) mkdir -p "$abuildrepo"/$prefix ln -sf "$PKGDEST"/$apk "$abuildrepo"/$prefix/$apk done