summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rwxr-xr-xabuild.in50
-rwxr-xr-xnewapkbuild.in78
3 files changed, 84 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index 8a833f1..43e5e57 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,8 @@ sysconfdir ?= /etc
datadir ?= $(prefix)/share/$(PACKAGE)
apkcache ?= ~/.cache/apks
-SCRIPTS := abuild devbuild mkalpine buildrepo abuild-keygen abuild-sign
+SCRIPTS := abuild devbuild mkalpine buildrepo abuild-keygen \
+ abuild-sign newapkbuild
USR_BIN_FILES := $(SCRIPTS) abuild-tar
SAMPLES := sample.APKBUILD sample.initd sample.confd \
sample.pre-install sample.post-install
diff --git a/abuild.in b/abuild.in
index cab8f1b..fcfb23b 100755
--- a/abuild.in
+++ b/abuild.in
@@ -934,38 +934,6 @@ post_add() {
$SUDO apk add -u "$pkgf" || die "Failed to install $1"
}
-# create new aport from templates
-newaport() {
- local pn=${newname%-[0-9]*}
- local pv
- if [ "$pn" != "$newname" ]; then
- pv=${newname#$pn-}
- fi
- if [ -e "$pn"/APKBUILD ]; then
- error "$pn/APKBUILD already exist"
- return 1
- fi
- mkdir -p "$pn"
- cd "$pn"
- sed -e '1,/^\#*$/d' \
- -e "s/^\(# Contributor: \).*/\1$PACKAGER/" \
- -e "s/^\(# Maintainer: \).*/\1$PACKAGER/" \
- -e "s/^pkgname=.*/pkgname=$pn/" \
- -e "s/^pkgver=.*/pkgver=$pv/" \
- "$datadir"/sample.APKBUILD > APKBUILD || return 1
- #-e '1,/^\#$/d' \
- if [ -n "$cpinitd" ]; then
- cp "$datadir"/sample.initd $pn.initd
- cp "$datadir"/sample.confd $pn.confd
- cp "$datadir"/sample.pre-install $pn.pre-install
- cp "$datadir"/sample.post-install $pn.post-install
- sed -i -e "s/^install=.*/install=\"\$pkgname.pre-install \$pkgname.post-install\"/" \
- -e "s/^source=\"\(.*\)\"/source=\"\1\n\t$pn.initd\n\t$pn.confd\n\t\$install\n\t\"/" \
- APKBUILD
-
- fi
-}
-
installdeps() {
local deps i
sudo apk add --repository "$apkcache" --virtual .makedepends-$pkgname \
@@ -1003,9 +971,6 @@ usage() {
echo " -s Set source package destination directory"
echo " -u Recursively build and upgrade all dependencies (using sudo)"
echo ""
- echo " -n Create a new APKBUILD in a directory named PKGNAME"
- echo " -c Copy a sample init.d, conf.d and install script to new directory"
- echo ""
echo "Commands:"
echo " checksum Generate checksum to be included in APKBUILD"
echo " fetch Fetch sources to \$SRCDEST and verify checksums"
@@ -1031,15 +996,14 @@ usage() {
APKBUILD="${APKBUILD:-./APKBUILD}"
unset force
unset recursive
-while getopts "cdfhi:kin:p:P:qrRs:u" opt; do
+while getopts "dfhi:kinp:P:qrRs:u" opt; do
case $opt in
- 'c') cpinitd=1;;
'd') nodeps=1;;
'f') force=1;;
'h') usage;;
'i') install_after="$install_after $OPTARG";;
'k') keep=1;;
- 'n') newname=$OPTARG;;
+ 'n') die "Use newapkbuild to create new aports";;
'p') PKGDEST=$OPTARG;;
'P') REPODEST=$OPTARG;;
'q') quiet=1;;
@@ -1058,10 +1022,8 @@ if [ -n "$REPODEST" ]; then
fi
# source the buildfile
-if [ -z "$newname" ]; then
- [ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
- . "$APKBUILD"
-fi
+[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
+. "$APKBUILD"
# If we are handling a sub package then reset subpackages and install
if [ -n "$subpkgname" ]; then
@@ -1075,10 +1037,6 @@ controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}
trap 'die "Aborted by user"' INT
set_xterm_title "abuild: $pkgname"
-if [ -z "$1" ] && [ -n "$newname" ]; then
- set "newaport"
-fi
-
if [ -z "$1" ]; then
set all
fi
diff --git a/newapkbuild.in b/newapkbuild.in
new file mode 100755
index 0000000..3fa0b87
--- /dev/null
+++ b/newapkbuild.in
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# script to generate a new APKBUILD
+# Copyright (c) 2009 Natanael Copa <natanael.copa@gmail.com>
+#
+# Distributed under GPL-2
+#
+# Depends on: busybox utilities, fakeroot,
+#
+
+version=@VERSION@
+sysconfdir=@sysconfdir@
+datadir=@datadir@
+
+prog=${0##*/}
+
+error() {
+ echo "$@" >&2
+}
+
+# create new aport from templates
+newaport() {
+ local newname="$1"
+ local pn=${newname%-[0-9]*}
+ local pv
+ if [ "$pn" != "$newname" ]; then
+ pv=${newname#$pn-}
+ fi
+ if [ -e "$pn"/APKBUILD ] && [ -z "$force" ]; then
+ error "$pn/APKBUILD already exist"
+ return 1
+ fi
+ mkdir -p "$pn"
+ cd "$pn"
+ sed -e '1,/^\#*$/d' \
+ -e "s/^\(# Contributor: \).*/\1$PACKAGER/" \
+ -e "s/^\(# Maintainer: \).*/\1$PACKAGER/" \
+ -e "s/^pkgname=.*/pkgname=$pn/" \
+ -e "s/^pkgver=.*/pkgver=$pv/" \
+ "$datadir"/sample.APKBUILD > APKBUILD || return 1
+ #-e '1,/^\#$/d' \
+ if [ -n "$cpinitd" ]; then
+ cp "$datadir"/sample.initd $pn.initd
+ cp "$datadir"/sample.confd $pn.confd
+ cp "$datadir"/sample.pre-install $pn.pre-install
+ cp "$datadir"/sample.post-install $pn.post-install
+ sed -i -e "s/^install=.*/install=\"\$pkgname.pre-install \$pkgname.post-install\"/" \
+ -e "s/^source=\"\(.*\)\"/source=\"\1\n\t$pn.initd\n\t$pn.confd\n\t\$install\n\t\"/" \
+ APKBUILD
+
+ fi
+}
+
+usage() {
+ echo "$prog $version"
+ echo "usage: $prog [-cfh] PKGNAME[-PKGVER]"
+ echo "Options:"
+ echo " -c Copy a sample init.d, conf.d and install script to new directory"
+ echo " -f Force even if directory already exist"
+ echo " -h Show this help"
+ echo ""
+ exit 0
+}
+
+while getopts "cfh" opt; do
+ case $opt in
+ 'c') cpinitd=1;;
+ 'f') force=1;;
+ 'h') usage;;
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+while [ $# -gt 0 ]; do
+ newaport $1 || exit 1
+ shift
+done
+