Newer
Older
# script to build apk packages (light version of makepkg)
# Copyright (c) 2008 Natanael Copa <natanael.copa@gmail.com>
#
# Distributed under GPL-2
#
# Depends on: busybox utilities, fakeroot,
#
abuild_ver=@VERSION@
sysconfdir=@sysconfdir@
abuildrepo_base=@abuildrepo@
abuild_path=$(readlink -f $0)
BUILD_BASE="build-base"
FAKEROOT=${FAKEROOT:-"fakeroot"}
: ${SUDO_APK:=abuild-apk}
: ${APK:=apk}
: ${ADDUSER:=abuild-adduser}
: ${ADDGROUP:=abuild-addgroup}
apk_opt_wait="--wait 30"
ABUILD_CONF=${ABUILD_CONF:-"$sysconfdir/abuild.conf"}
default_colors() {
NORMAL="\033[1;0m"
STRONG="\033[1;1m"
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"
}
monochrome() {
NORMAL=""
STRONG=""
RED=""
GREEN=""
YELLOW=""
BLUE=""
}
#colors
if [ -n "$USE_COLORS" ]; then
default_colors
local prompt="$GREEN>>>${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
}
msg2() {
[ -n "$quiet" ] && return 0
# ">>> %s"
printf " %s\n" "$1" >&2
}
warning() {
local prompt="${YELLOW}>>> WARNING:${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
}
warning2() {
# ">>> WARNING:
printf " %s\n" "$1" >&2
}
error() {
local prompt="${RED}>>> ERROR:${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${name}${fake}: %s\n" "$1" >&2
}
error2() {
# ">>> ERROR:
printf " %s\n" "$1" >&2
if [ "$TERM" = xterm ] && [ -n "$USE_COLORS" ]; then
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
msg "Uninstalling dependencies..."
$SUDO_APK del --quiet $apk_opt_wait $uninstall_after
if [ -n "$CLEANUP_FILES" ]; then
rm -f $CLEANUP_FILES
fi
# check if apkbuild is basicly sane
msg "Checking sanity of $APKBUILD..."
[ -z "$pkgname" ] && die "Missing pkgname in APKBUILD"
[ -z "${pkgname##* *}" ] && die "pkgname contains spaces"
[ -z "$pkgver" ] && die "Missing pkgver in APKBUILD"
if [ "$pkgver" != "volatile" ] && [ -z "$nodeps" ]; then
$APK version --check -q "$pkgver" ||\
die "$pkgver is not a valid version"
fi
[ -z "$pkgrel" ] && die "Missing pkgrel in APKBUILD"
[ -z "$pkgdesc" ] && die "Missing pkgdesc in APKBUILD"
[ -z "$url" ] && die "Missing url in APKBUILD"
[ -z "$license" ] && die "Missing license in APKBULID"
# check so no package names starts with -
for i in $pkgname $subpackages; do
case $i in
-*) die "${i%:*} is not a valid package name";;
esac
done
# check if CARCH, CBUILD, CHOST and CTARGET is set
if [ -z "$CARCH" ]; then
case "$(uname -m)" in
i[0-9]86) suggestion=" (Suggestion: CARCH=x86)";;
x86_64) suggestion=" (Suggestion: CARCH=x86_64)";;
esac
die "Please set CARCH in /etc/abuild.conf$suggestion"
fi
[ -z "$CHOST" ] && die "Please set CHOST in /etc/abuild.conf"
case "$suff" in
pre-install|post-install|pre-upgrade|post-upgrade|pre-deinstall|post-deinstall);;
*) die "$i: unknown install script suffix"
esac
if ! subpackages_has "$n" && [ "$n" != "$pkgname" ]; then
die "$i: install script does not match pkgname or any subpackage"
[ -e "$startdir/$i" ] || die "install script $i is missing"
for j in chown chmod chgrp; do
if grep -q $j "$startdir"/$i; then
warning "$i: found $j"
warning2 "Permissions should be fixed in APKBUILD package()"
fi
done
for i in $triggers; do
local f=${i%=*}
local p=${f%.trigger}
[ "$f" = "$i" ] && die "$f: triggers must contain '='"
[ "$p" = "$f" ] && die "$f: triggers scripts must have .trigger suffix"
if ! subpackages_has "$p" && [ "$p" != "$pkgname" ]; then
die "$p: trigger script does not match pkgname or any subpackage"
fi
[ -e "$startdir"/$f ] || die "trigger script $f is missing"
done
if [ -n "$source" ]; then
for i in $source; do
if install_has "$i"; then
warning "You should not have \$install in source"
continue
fi
md5sums_has ${i##*/} || die "${i##*/} is missing in md5sums"
https://*) makedepends_has wget && warning "wget no longer need to be in makedepends when source has https://" ;;
done
fi
if [ -n "$md5sums" ]; then
for i in $(echo "$md5sums" | awk '{ print $2 }'); do
source_has $i || die "$i exists in md5sums but is missing in source"
Loading
Loading full blame...