summaryrefslogtreecommitdiffstats
path: root/newapkbuild.in
diff options
context:
space:
mode:
Diffstat (limited to 'newapkbuild.in')
-rw-r--r--newapkbuild.in62
1 files changed, 44 insertions, 18 deletions
diff --git a/newapkbuild.in b/newapkbuild.in
index 77d1a8b..b84dd6d 100644
--- a/newapkbuild.in
+++ b/newapkbuild.in
@@ -344,13 +344,14 @@ __EOF__
usage() {
cat >&2 <<-__EOF__
$program $program_version - generate a new APKBUILD
- Usage: $program [-n NAME] [-d DESC] [-l LICENSE] [-u URL]
- [-aCpy] [-s] [-cfh]
- PKGNAME[-PKGVER]|SRCURL
+ Usage: $program [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL]
+ [-a | -C | -m | -p | -y] [-s] [-c] [-f] [-h]
+ PKGNAME[-PKGVER] | SRCURL
Options:
- -n Set package name to NAME
- -d Set package description (pkgdesc) to DESC
- -l Set package license to LICENSE
+ -n Set package name to PKGNAME (only use with SRCURL)
+ -d Set package description to PKGDESC
+ -l Set package license to LICENSE, use identifiers from:
+ <https://spdx.org/licenses/>
-u Set package URL
-a Create autotools package (use ./configure ...)
-C Create CMake package (Assume cmake/ is there)
@@ -358,33 +359,58 @@ usage() {
-p Create perl package (Assume Makefile.PL is there)
-y Create python package (Assume setup.py is there)
-s Use sourceforge source URL
- -c Copy a sample init.d, conf.d, and install script to new directory
- -f Force even if directory already exist
+ -c Copy a sample init.d, conf.d, and install script
+ -f Force even if directory already exists
-h Show this help
-
__EOF__
}
+set_buildtype() {
+ if [ -n "$buildtype" ]; then
+ error "More than one buildtype flag specified ($buildtype and $1)"
+ exit 1
+ fi
+ buildtype="$1"
+}
+
+check_arguments() {
+ if [ $# -eq 0 ]; then
+ error "Missing required argument: PKGNAME[-PKGVER] | SRCURL"
+ exit 1
+ fi
+ if [ $# -gt 1 ]; then
+ shift
+ error "Unrecognized arguments: $*"
+ exit 1
+ fi
+ if ! is_url "$1" && [ -n "$pkgname" ]; then
+ error "-n is only allowed when using SRCURL as last argument"
+ exit 1
+ fi
+ if is_url "$1" && [ -n "$sourceforge" ]; then
+ error "-s is only allowed when using PKGNAME as last argument"
+ exit 1
+ fi
+}
+
while getopts "acCmd:fhl:n:pyu:s" opt; do
case $opt in
- 'a') buildtype="autotools";;
+ 'a') set_buildtype "autotools";;
'c') cpinitd=1;;
- 'C') buildtype="cmake";;
- 'm') buildtype="meson";;
+ 'C') set_buildtype "cmake";;
+ 'm') set_buildtype "meson";;
'd') pkgdesc="$OPTARG";;
'f') force=1;;
'h') usage; exit;;
'l') license="$OPTARG";;
'n') pkgname="$OPTARG";;
- 'p') buildtype="perl";;
- 'y') buildtype="python";;
+ 'p') set_buildtype "perl";;
+ 'y') set_buildtype "python";;
'u') url="$OPTARG";;
's') sourceforge=1;;
esac
done
shift $(( $OPTIND - 1 ))
-while [ $# -gt 0 ]; do
- newaport $1 || exit 1
- shift
-done
+check_arguments "$@"
+newaport $1