2009-10-24 20:03:06 +00:00
|
|
|
#!/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##*/}
|
|
|
|
|
2010-11-19 09:51:36 +00:00
|
|
|
# source $PACKAGER
|
|
|
|
for i in /etc/abuild.conf $HOME/.abuild/abuild.conf; do
|
|
|
|
if [ -f "$i" ]; then
|
|
|
|
. $i
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2009-10-24 20:03:06 +00:00
|
|
|
error() {
|
|
|
|
echo "$@" >&2
|
|
|
|
}
|
|
|
|
|
2010-05-28 13:52:47 +00:00
|
|
|
is_url() {
|
|
|
|
case "$1" in
|
|
|
|
http://*|ftp://*) return 0;;
|
|
|
|
esac
|
2010-07-07 18:27:09 +00:00
|
|
|
return 1
|
2010-05-28 13:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-24 20:03:06 +00:00
|
|
|
# create new aport from templates
|
|
|
|
newaport() {
|
2010-05-28 13:52:47 +00:00
|
|
|
local newname="${1##*/}"
|
2009-10-24 20:03:06 +00:00
|
|
|
local pn=${newname%-[0-9]*}
|
|
|
|
local pv
|
2010-05-28 13:52:47 +00:00
|
|
|
local source=
|
|
|
|
is_url "$1" && source="$1"
|
|
|
|
|
2009-10-24 20:03:06 +00:00
|
|
|
if [ "$pn" != "$newname" ]; then
|
|
|
|
pv=${newname#$pn-}
|
2010-05-28 13:52:47 +00:00
|
|
|
pv=${pv%.t*} #strip .tar.gz .tgz .tar.bz2 etc
|
2009-10-24 20:03:06 +00:00
|
|
|
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
|
2010-05-28 13:52:47 +00:00
|
|
|
if [ -n "$source" ]; then
|
2010-06-16 14:00:34 +00:00
|
|
|
source=$(echo "$source" | sed "s/$pv/\$pkgver/g")
|
2010-05-28 13:52:47 +00:00
|
|
|
sed -i -e "/^source=/s|=.*|=\"$source\"|" APKBUILD || return 1
|
|
|
|
fi
|
2009-10-24 20:03:06 +00:00
|
|
|
#-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
|
|
|
|
|