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@
abuild_path=$(readlink -f $0)
BUILD_BASE="build-base"
SUDO=${SUDO:-"sudo"}
FAKEROOT=${FAKEROOT:-"fakeroot"}
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
fi
# functions
msg() {
local prompt="$GREEN>>>${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
[ -z "$quiet" ] && printf "${prompt} ${name}${fake}: $@\n" >&2
}
warning() {
local prompt="${YELLOW}>>> WARNING:${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${name}${fake}: $@\n" >&2
}
error() {
local prompt="${RED}>>> ERROR:${NORMAL}"
local fake="${FAKEROOTKEY:+${BLUE}*${NORMAL}}"
local name="${STRONG}${subpkgname:-$pkgname}${NORMAL}"
printf "${prompt} ${name}${fake}: $@\n" >&2
}
if [ "$TERM" = xterm ] && [ -n "$USE_COLORS" ]; then
if [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
$SUDO $APK del $apk_opt_wait $uninstall_after
# check if apkbuild is basicly sane
sanitycheck() {
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 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"
for i in $install; do
[ -e "$startdir/$i" ] || die "install script $startdir/$i is missing"
done
[ -n "${triggers%%:*}" ] && [ ! -e "$startdir"/${triggers%%:*} ] \
&& die "trigger script $startdir/${triggers%%:*} is missing"
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"
case "$i" in
https://*) makedepends_has wget || die "wget must be in makedepends when source has https://" ;;
esac
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"
done
fi
# common spelling errors
[ -n "$depend" ] && die "APKBUILD contains 'depend'. It should be depends"
[ -n "$makedepend" ] && die "APKBUILD contains 'makedepend'. It should be makedepends"
grep '^# Maintainer:' $APKBUILD >/dev/null || warning "No maintainer"
makedepends_has 'g++' && warning "g++ should not be in makedepends"
return 0
}
md5check() {
local dummy f endreturnval originalparams origin file
if [ -z "$source" ]; then
return 0
fi
if [ -z "$md5sums" ]; then
die "Use 'abuild checksum' to generate/update the checksum(s)"
if [ "$(echo $source | wc -l)" -ne "$(echo $md5sums | wc -l)" ]; then
die "Number of md5sums does not correspond to number of sources"
fi
msg "Checking md5sums..."
IFS=$'\n'
endreturnval=0
originalparams=$@
set -- $source
for src in $md5sums; do
origin=$1; shift
echo "$src" | md5sum -c
if [ $? -ne 0 ]; then
is_remote $origin || continue
echo "Because the remote file above failed the md5sum check it will be deleted."
echo "Rebuilding will cause it to re-download which in some cases may fix the problem."
file=`echo "$src" | sed 's/.*[ \t\n]\(.*\)/\1/'`
echo "Deleting: $file"
rm $file
endreturnval=1
fi
done
unset IFS
set -- $originalparams
return $endreturnval
# verify upstream sources
sourcecheck() {
local uri
for uri in $source; do
is_remote $uri || continue
case "$uri" in
saveas-*://*)
Loading
Loading full blame...