50 lines
839 B
Bash
50 lines
839 B
Bash
set -e
|
|
|
|
check_function () {
|
|
if [ ! "$(type -t "${1}")" = "function" ]; then
|
|
echo ">>> Function '${1}' is not defined!"
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
do_prepare () {
|
|
prepare
|
|
|
|
cd "${wd}"
|
|
}
|
|
|
|
do_build () {
|
|
build
|
|
|
|
cd "${wd}"
|
|
}
|
|
|
|
do_package () {
|
|
package
|
|
|
|
cd "${wd}"
|
|
fakeroot tar -C "${pkgdir}" -cf - . | \
|
|
xz -9 -T 0 -vvv \
|
|
> "${pkgname}-${pkgver}.pkg.tar.xz"
|
|
|
|
}
|
|
|
|
[ -z "${pkgname}" ] && ( echo ">>> pkgname is not defined"; exit 1 );
|
|
[ -z "${pkgver}" ] && ( echo ">>> pkgver is not defined"; exit 1 );
|
|
|
|
check_function prepare || exit 1
|
|
check_function build || exit 1
|
|
check_function package || exit 1
|
|
|
|
wd="$(pwd)"
|
|
srcdir="$(mktemp -d /tmp/buildpkg-src.XXXXXXX)"
|
|
pkgdir="$(mktemp -d /tmp/buildpkg-bin.XXXXXXX)"
|
|
|
|
do_prepare
|
|
do_build
|
|
do_package
|
|
|
|
rm -rf "${srcdir}"
|
|
rm -rf "${pkgdir}"
|