2009-01-06 15:43:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
program=${0##*/}
|
|
|
|
|
|
|
|
aportsdir=${APORTSDIR:-$HOME/aports}
|
|
|
|
repodir=${REPODIR:-$HOME/packages}
|
|
|
|
|
|
|
|
|
|
|
|
usage() {
|
2009-01-17 10:00:55 +00:00
|
|
|
echo "usage: $program [-a APORTSDIR] [-d REPODIR] [-hp] [-l LOGPREFIX ]"
|
|
|
|
echo " [-r DEPREPO] REPOSITORY..."
|
|
|
|
|
2009-01-06 15:43:53 +00:00
|
|
|
echo "options:"
|
|
|
|
echo " -a Set the aports base dir to APORTSDIR instead of $aportsdir"
|
|
|
|
echo " -d Set destination repository base dir to REPODIR instead of $repodir"
|
|
|
|
echo " -h Show this help and exit"
|
|
|
|
echo " -l Send build to logfile, prefixed by LOGPREFIX"
|
|
|
|
echo " -p Purge obsolete packages from REPODIR after build"
|
2009-01-17 10:00:55 +00:00
|
|
|
echo " -r Dependencies are found in DEPREPO"
|
2009-01-06 15:43:53 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
listpackages() {
|
|
|
|
cd "$aportsdir/$1"
|
|
|
|
for i in */APKBUILD; do
|
|
|
|
APKBUILD=$i abuild listpkg
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# purge obsolete packages
|
|
|
|
purge() {
|
|
|
|
[ -z "$dopurge" ] && return 0
|
|
|
|
local tmp=$(mktemp /tmp/$program-XXXXXX)
|
|
|
|
cd "$repodir/$1" || return 1
|
|
|
|
trap 'rm -f "$tmp"; exit 1' INT
|
|
|
|
( listpackages "$1") >$tmp
|
|
|
|
ls *.apk 2>/dev/null | grep -v -w -f $tmp | xargs rm 2>/dev/null
|
2009-01-22 09:08:50 +00:00
|
|
|
return 0
|
2009-01-06 15:43:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
local repo="$1" i
|
|
|
|
|
|
|
|
cd "$aportsdir/$repo" || return 1
|
|
|
|
mkdir -p "$repodir/$repo"
|
|
|
|
|
|
|
|
for i in */APKBUILD; do
|
|
|
|
( cd ${i%/*} || return 1
|
2009-01-22 09:08:50 +00:00
|
|
|
REPODEST="$repodir" abuild -k -r || return 1
|
2009-01-06 15:43:53 +00:00
|
|
|
) || return 1
|
|
|
|
done
|
|
|
|
cd "$repodir/$repo"
|
2009-01-17 10:00:55 +00:00
|
|
|
echo ">>> Generating Index..."
|
2009-01-06 15:43:53 +00:00
|
|
|
md5sum *.apk | gzip -9 > INDEX.md5.gz
|
|
|
|
if which apk >/dev/null; then
|
2009-01-17 10:00:55 +00:00
|
|
|
local deps
|
|
|
|
for i in $deprepo; do
|
|
|
|
deps="--repo $repodir/$i"
|
|
|
|
done
|
|
|
|
apk $deps index *.apk | gzip -9 > APK_INDEX.gz
|
2009-01-06 15:43:53 +00:00
|
|
|
fi
|
|
|
|
purge "$repo"
|
|
|
|
}
|
|
|
|
|
2009-01-17 10:00:55 +00:00
|
|
|
while getopts "a:d:hl:pr:" opt; do
|
2009-01-06 15:43:53 +00:00
|
|
|
case "$opt" in
|
|
|
|
a) aportsdir=$OPTARG;;
|
|
|
|
d) repodir=$OPTARG;;
|
|
|
|
h) usage >&2;;
|
|
|
|
l) logprefix=$OPTARG;;
|
|
|
|
p) dopurge=1;;
|
2009-01-17 10:00:55 +00:00
|
|
|
r) deprepo="$deprepo $OPTARG";;
|
2009-01-06 15:43:53 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
|
|
|
|
[ $# -eq 0 ] && usage >&2
|
|
|
|
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
if [ -n "$logprefix" ]; then
|
|
|
|
build $1 >$logprefix.$1.log 2>&1 || exit 1
|
|
|
|
else
|
|
|
|
build $1 || exit 1
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|