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.
This commit is contained in:
parent
81f8737a6a
commit
21cd6680ee
7
Makefile
7
Makefile
|
@ -2,7 +2,8 @@
|
||||||
PACKAGE=abuild
|
PACKAGE=abuild
|
||||||
VERSION:=$(shell awk -F= '$$1 == "abuild_ver" {print $$2}' abuild)
|
VERSION:=$(shell awk -F= '$$1 == "abuild_ver" {print $$2}' abuild)
|
||||||
USR_BIN_FILES=abuild devbuild mkalpine buildrepo
|
USR_BIN_FILES=abuild devbuild mkalpine buildrepo
|
||||||
DISTFILES=$(USR_BIN_FILES) Makefile abuild.conf APKBUILD.proto
|
SAMPLES=sample.APKBUILD sample.initd sample.confd sample.install
|
||||||
|
DISTFILES=$(USR_BIN_FILES) $(SAMPLES) Makefile abuild.conf \
|
||||||
|
|
||||||
|
|
||||||
prefix ?= /usr
|
prefix ?= /usr
|
||||||
|
@ -16,7 +17,7 @@ help:
|
||||||
@echo "usage: make install [ DESTDIR=<path> ]"
|
@echo "usage: make install [ DESTDIR=<path> ]"
|
||||||
@echo " make dist"
|
@echo " make dist"
|
||||||
|
|
||||||
install: $(USR_BIN_FILES) abuild.conf APKBUILD.proto functions.sh
|
install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
|
||||||
mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
|
mkdir -p $(DESTDIR)/$(prefix)/bin $(DESTDIR)/$(sysconfdir) \
|
||||||
$(DESTDIR)/$(datadir)
|
$(DESTDIR)/$(datadir)
|
||||||
for i in $(USR_BIN_FILES); do\
|
for i in $(USR_BIN_FILES); do\
|
||||||
|
@ -25,7 +26,7 @@ install: $(USR_BIN_FILES) abuild.conf APKBUILD.proto functions.sh
|
||||||
if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
|
if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
|
||||||
cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
|
cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
|
||||||
fi
|
fi
|
||||||
cp APKBUILD.proto $(DESTDIR)/$(prefix)/share/abuild
|
cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild
|
||||||
cp functions.sh $(DESTDIR)/$(datadir)/
|
cp functions.sh $(DESTDIR)/$(datadir)/
|
||||||
|
|
||||||
dist: $(P).tar.bz2
|
dist: $(P).tar.bz2
|
||||||
|
|
54
abuild
54
abuild
|
@ -34,10 +34,12 @@ if [ -n "$REPODEST" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# source functions
|
# source functions
|
||||||
|
datadir=/usr/share/abuild
|
||||||
|
|
||||||
# if abuild was not run from PATH, then look for func lib at same location
|
# if abuild was not run from PATH, then look for func lib at same location
|
||||||
if [ -z "$FUNCLIB" ]; then
|
if [ -z "$FUNCLIB" ]; then
|
||||||
FUNCLIB="${0##/*}/functions.sh"
|
FUNCLIB="${0##/*}/functions.sh"
|
||||||
[ -f "$FUNCLIB" ] || FUNCLIB=/usr/share/abuild/functions.sh
|
[ -f "$FUNCLIB" ] || FUNCLIB=$datadir/functions.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -f "$FUNCLIB" ]; then
|
if ! [ -f "$FUNCLIB" ]; then
|
||||||
|
@ -558,9 +560,41 @@ post_add() {
|
||||||
sudo apk add -u "$pkgf" || die "Failed to install $1"
|
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() {
|
usage() {
|
||||||
echo "$(basename $0) $abuild_ver"
|
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 "Options:"
|
||||||
echo " -f Force specified cmd, even if they are already done"
|
echo " -f Force specified cmd, even if they are already done"
|
||||||
echo " -h Show this help"
|
echo " -h Show this help"
|
||||||
|
@ -572,6 +606,9 @@ usage() {
|
||||||
echo " -s Set source package destination directory"
|
echo " -s Set source package destination directory"
|
||||||
echo " -u Recursively build and upgrade dependencies (using sudo)"
|
echo " -u Recursively build and upgrade dependencies (using sudo)"
|
||||||
echo ""
|
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 "Commands:"
|
||||||
echo " checksum Generate checksum to be included in APKBUILD"
|
echo " checksum Generate checksum to be included in APKBUILD"
|
||||||
echo " fetch Fetch sources to \$SRCDEST and verify checksums"
|
echo " fetch Fetch sources to \$SRCDEST and verify checksums"
|
||||||
|
@ -595,12 +632,14 @@ usage() {
|
||||||
APKBUILD="${APKBUILD:-./APKBUILD}"
|
APKBUILD="${APKBUILD:-./APKBUILD}"
|
||||||
unset force
|
unset force
|
||||||
unset recursive
|
unset recursive
|
||||||
while getopts "fhi:kip:qrs:u" opt; do
|
while getopts "cfhi:kin:p:qrs:u" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
|
'c') cpinitd=1;;
|
||||||
'f') force=1;;
|
'f') force=1;;
|
||||||
'h') usage;;
|
'h') usage;;
|
||||||
'i') install_after="$install_after $OPTARG";;
|
'i') install_after="$install_after $OPTARG";;
|
||||||
'k') keep=1;;
|
'k') keep=1;;
|
||||||
|
'n') newname=$OPTARG;;
|
||||||
'p') PKGDEST=$OPTARG;;
|
'p') PKGDEST=$OPTARG;;
|
||||||
'q') quiet=1;;
|
'q') quiet=1;;
|
||||||
'r') recursive=1;;
|
'r') recursive=1;;
|
||||||
|
@ -612,8 +651,10 @@ done
|
||||||
shift $(( $OPTIND - 1 ))
|
shift $(( $OPTIND - 1 ))
|
||||||
|
|
||||||
# source the buildfile
|
# source the buildfile
|
||||||
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
|
if [ -z "$newname" ]; then
|
||||||
. "$APKBUILD"
|
[ -f "$APKBUILD" ] || die "Could not find $APKBUILD (PWD=$PWD)"
|
||||||
|
. "$APKBUILD"
|
||||||
|
fi
|
||||||
|
|
||||||
# If we are handling a sub package then reset subpackages
|
# If we are handling a sub package then reset subpackages
|
||||||
if [ -n "$subpkgname" ]; then
|
if [ -n "$subpkgname" ]; then
|
||||||
|
@ -623,6 +664,9 @@ fi
|
||||||
trap 'die "Aborted by user"' INT
|
trap 'die "Aborted by user"' INT
|
||||||
set_xterm_title "abuild: $pkgname"
|
set_xterm_title "abuild: $pkgname"
|
||||||
|
|
||||||
|
if [ -z "$1" ] && [ -n "$newname" ]; then
|
||||||
|
set "newaport"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
if up2date && [ -z "$force" ]; then
|
if up2date && [ -z "$force" ]; then
|
||||||
|
|
|
@ -9,7 +9,6 @@ pkgname=NAME
|
||||||
pkgver=VERSION
|
pkgver=VERSION
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc=""
|
pkgdesc=""
|
||||||
arch=""
|
|
||||||
url=""
|
url=""
|
||||||
license="GPL"
|
license="GPL"
|
||||||
depends=""
|
depends=""
|
||||||
|
@ -27,6 +26,9 @@ build() {
|
||||||
--infodir=/usr/share/info
|
--infodir=/usr/share/info
|
||||||
make || return 1
|
make || return 1
|
||||||
make DESTDIR="$pkgdir" install
|
make DESTDIR="$pkgdir" install
|
||||||
|
|
||||||
|
# install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
|
||||||
|
# install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
|
||||||
}
|
}
|
||||||
|
|
||||||
md5sums="" #generate with 'abuild checksum'
|
md5sums="" #generate with 'abuild checksum'
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Sample conf.d file for alpine linux
|
||||||
|
|
||||||
|
#
|
||||||
|
# Specify daemon $OPTS here.
|
||||||
|
#
|
||||||
|
|
||||||
|
OPTS=""
|
||||||
|
USER="nobody"
|
||||||
|
GROUP="nobody"
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/sbin/runscript
|
||||||
|
|
||||||
|
# Sample init.d file for alpine linux.
|
||||||
|
|
||||||
|
NAME=
|
||||||
|
DAEMON=/usr/sbin/$NAME
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
ebegin "Starting ${NAME}"
|
||||||
|
start-stop-daemon --start --quiet --background \
|
||||||
|
--make-pidfile --pidfile /var/run/${NAME}.pid \
|
||||||
|
--chuid ${USER}:${GROUP} \
|
||||||
|
--exec ${DAEMON} -- ${OPTS}
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "Stopping ${NAME}"
|
||||||
|
start-stop-daemon --stop --quiet \
|
||||||
|
--exec ${DAEMON} \
|
||||||
|
--pidfile /var/run/${NAME}.pid \
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
ebegin "Reloading ${NAME}"
|
||||||
|
if ! service_started "${NAME}" ; then
|
||||||
|
eend 1 "${NAME} is not started"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
start-stop-daemon --stop --oknodo --signal HUP \
|
||||||
|
--exec ${DAEMON} --pidfile /var/run/${NAME}.pid
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
pre_install)
|
||||||
|
# add something which happends before install
|
||||||
|
# $2 contains package version
|
||||||
|
;;
|
||||||
|
post_install)
|
||||||
|
# add something which happends after install
|
||||||
|
# $2 contains package version
|
||||||
|
;;
|
||||||
|
pre_upgrade)
|
||||||
|
# add something which happends before update
|
||||||
|
# $2 contains new package version
|
||||||
|
# $3 contains old package version
|
||||||
|
;;
|
||||||
|
post_upgrade)
|
||||||
|
# add something which happends after update
|
||||||
|
# $2 contains new package version
|
||||||
|
# $3 contains old package version
|
||||||
|
;;
|
||||||
|
pre_deinstall)
|
||||||
|
# add something which happends before delete
|
||||||
|
# $2 contains package version
|
||||||
|
;;
|
||||||
|
post_deinstall)
|
||||||
|
# add something which happends after delete
|
||||||
|
# $2 contains package version
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue