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"}
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 [ -z "$install_after" ] && [ -n "$uninstall_after" ]; then
$SUDO $APK del $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"
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() {
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..."
cd "$srcdir" && echo "$md5sums" | md5sum -c
local d="${uri##*/}" # $(basename $uri)
local opts
[ -n "$quiet" ] && opts="-q"
[ -f "$SRCDEST/$d" ] && return 0
# we need GNU wget for this
case "$uri" in
https://*) opts="--no-check-certificate";;
esac
if [ -f "$SRCDEST/$d.part" ]; then
msg "Partial download found. Trying to resume"
opts="$opts -c"
wget $opts -O "$SRCDEST/$d.part" "$uri" \
&& mv "$SRCDEST/$d.part" "$SRCDEST/$d"
is_remote() {
case "$1" in
return 0;;
esac
return 1
}
# try download from file from mirror first
uri_fetch_mirror() {
local uri="$1"
local d="${uri##*/}" # $(basename $uri)
if [ -n "$DISTFILES_MIRROR" ]; then
if is_remote "$DISTFILES_MIRROR"; then
uri_fetch "$DISTFILES_MIRROR"/$d && return 0
else
Loading
Loading full blame...