From 89afa4179287af307e298f6027dc4eee44bcf481 Mon Sep 17 00:00:00 2001 From: Dubiousjim Date: Fri, 5 Jul 2013 00:21:38 -0400 Subject: apkgrel, functions: refactor calculation of APKBUILD's path --- functions.sh.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'functions.sh.in') 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 -- cgit v1.2.3