diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-29 09:06:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-29 09:06:43 +0000 |
commit | 21cd6680eee14cb6ab89ff95d8ca2413833800c7 (patch) | |
tree | fc0888eb5323e41fa09a05d71ce11bb150de7f9e /abuild | |
parent | 81f8737a6aa13c1d6944f061a1f21e5549ff4003 (diff) | |
download | abuild-21cd6680eee14cb6ab89ff95d8ca2413833800c7.tar.gz abuild-21cd6680eee14cb6ab89ff95d8ca2413833800c7.tar.bz2 abuild-21cd6680eee14cb6ab89ff95d8ca2413833800c7.tar.xz abuild-21cd6680eee14cb6ab89ff95d8ca2413833800c7.zip |
abuild: support for creation of new APKBUILD from template
abuild [-c] -n PKGNAME[-PKGVER]
creates a directory with new APKBUILD. If -c is specified will sample init.d,
conf.d and install script be copied as well.
Diffstat (limited to 'abuild')
-rwxr-xr-x | abuild | 54 |
1 files changed, 49 insertions, 5 deletions
@@ -34,10 +34,12 @@ if [ -n "$REPODEST" ]; then fi # source functions +datadir=/usr/share/abuild + # if abuild was not run from PATH, then look for func lib at same location if [ -z "$FUNCLIB" ]; then FUNCLIB="${0##/*}/functions.sh" - [ -f "$FUNCLIB" ] || FUNCLIB=/usr/share/abuild/functions.sh + [ -f "$FUNCLIB" ] || FUNCLIB=$datadir/functions.sh fi if ! [ -f "$FUNCLIB" ]; then @@ -558,9 +560,41 @@ 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.install $pn.install + sed -i -e "s/^install=.*/install=\"$pn.install\"/" \ + -e "s/^source=\"\(.*\)\"/source=\"\1\n\t$pn.initd\n\t$pn.confd\n\t\$install\n\t\"/" \ + APKBUILD + + fi +} + usage() { echo "$(basename $0) $abuild_ver" - echo "usage: $0 [options] [-i PKG] [-p PKGDEST] [-s SRCDEST] [cmd] ..." + echo "usage: ${0##*/} [options] [-i PKG] [-p PKGDEST] [-s SRCDEST] [cmd] ..." + echo " ${0##*/} [-c] -n PKGNAME[-PKGVER]" echo "Options:" echo " -f Force specified cmd, even if they are already done" echo " -h Show this help" @@ -572,6 +606,9 @@ usage() { echo " -s Set source package destination directory" echo " -u Recursively build and upgrade 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" @@ -595,12 +632,14 @@ usage() { APKBUILD="${APKBUILD:-./APKBUILD}" unset force unset recursive -while getopts "fhi:kip:qrs:u" opt; do +while getopts "cfhi:kin:p:qrs:u" opt; do case $opt in + 'c') cpinitd=1;; 'f') force=1;; 'h') usage;; 'i') install_after="$install_after $OPTARG";; 'k') keep=1;; + 'n') newname=$OPTARG;; 'p') PKGDEST=$OPTARG;; 'q') quiet=1;; 'r') recursive=1;; @@ -612,8 +651,10 @@ done shift $(( $OPTIND - 1 )) # source the buildfile -[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)" -. "$APKBUILD" +if [ -z "$newname" ]; then + [ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)" + . "$APKBUILD" +fi # If we are handling a sub package then reset subpackages if [ -n "$subpkgname" ]; then @@ -623,6 +664,9 @@ fi trap 'die "Aborted by user"' INT set_xterm_title "abuild: $pkgname" +if [ -z "$1" ] && [ -n "$newname" ]; then + set "newaport" +fi if [ -z "$1" ]; then if up2date && [ -z "$force" ]; then |