X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 7FEDADC7C26 for ; Fri, 5 Jul 2013 04:21:56 +0000 (UTC) Received: from compute1.internal (compute1.nyi.mail.srv.osa [10.202.2.41]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id E28F820984 for ; Fri, 5 Jul 2013 00:21:54 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 05 Jul 2013 00:21:54 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :in-reply-to:references; s=smtpout; bh=PDObmfIkMfI076OyPhXhfBEu1 ZM=; b=WKewCPRPnUXdxmtKBeku+JFsxI8AXwy8hk1Tqf3igF1oUOb11Dd/jQoVA Q27egZHKlECyLCtJdMxYqckIseMD/LXofZTnQOee0EYzm+fN862mLe7RRXDDYQqI PCoEJ/HImLn/T9gxHVaEZSHI/Gk/WR4YqJBxtKyzoE4GxAvpAk= X-Sasl-enc: 9JDfXKIJge87Mv7MdKtjFDQEU3xU3dpYBSpzrzh4+dX7 1372998114 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id B3E64680204 for ; Fri, 5 Jul 2013 00:21:54 -0400 (EDT) From: Dubiousjim To: alpine-devel@lists.alpinelinux.org Subject: [alpine-devel] [PATCH 29/31] apkgrel, functions: refactor calculation of APKBUILD's path Date: Fri, 5 Jul 2013 00:21:38 -0400 Message-Id: <4a52f1fd2ca56c47342c690142534ce5ae321685.1372997335.git.dubiousjim@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: --- apkgrel.in | 13 ++++++++++--- functions.sh.in | 13 +++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/apkgrel.in b/apkgrel.in index 1d178aa..94acd55 100644 --- a/apkgrel.in +++ b/apkgrel.in @@ -45,9 +45,8 @@ do_add () { local f= old= for f; do [ -n "$only_clean_git" ] \ - && [ -n "$(git diff --name-only "$f")" ] \ + && [ -n "$(git diff --name-only "${f%/*}")" ] \ && continue - [ -d "$f" ] && f="$f/APKBUILD" old=$(show_plain "$f") case $old in [0-9]*) setto=$((old + 1));; @@ -61,7 +60,6 @@ do_verify() { [ -n "$force" ] && return 0 local f= rc=0 for f; do - [ -d "$f" ] && f="$f/APKBUILD" if ! grep -q '^pkgrel=[0-9]' "$f"; then error "no proper \$pkgrel for $f" rc=1 @@ -124,6 +122,15 @@ if [ $# -eq 0 ]; then exit 2 fi +# normalize $@ into paths to APKBUILDs +[ "$(echo "$@" | wc -l)" -eq 1 ] || die "can't handle paths with embedded newlines" +args=$(for a; do p=$(any_buildscript "$a") || die "can't find APKBUILD for $a"; echo "$p"; done) +[ $? -eq 0 ] || exit 1 +oldifs=$IFS +IFS=$'\n' +set -- $args +IFS=$oldifs + do_verify "$@" || exit 1 $cmd "$@" diff --git a/functions.sh.in b/functions.sh.in index a25c39a..ab4dff5 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -30,6 +30,19 @@ aports_buildscript() { fi } +# expects $1 to be a file, or a directory containing an APKBUILD, or a package directory in the aports tree +# outputs APKBUILD's path if successful (doesn't verify that it's a valid APKBUILD) +any_buildscript() { + if [ -f "$1" ]; then + echo "$1" + elif [ -d "$1" ]; then + [ -f "$1/APKBUILD" ] || return 1 + echo "$1/APKBUILD" + else + aports_buildscript "$1" || return 1 + fi +} + # output functions case $prog in -- 1.8.3.1 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---