diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-06 15:43:53 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-06 15:43:53 +0000 |
commit | a73568f5ff2f080fb3d683fe59d071c01e5785cd (patch) | |
tree | 23159f85e4f434b94a0e23286e87224054ac9448 /buildrepo | |
parent | ff55ae9e1cbd7636ae36ed616d119560d3523942 (diff) | |
download | abuild-a73568f5ff2f080fb3d683fe59d071c01e5785cd.tar.gz abuild-a73568f5ff2f080fb3d683fe59d071c01e5785cd.tar.bz2 abuild-a73568f5ff2f080fb3d683fe59d071c01e5785cd.tar.xz abuild-a73568f5ff2f080fb3d683fe59d071c01e5785cd.zip |
buildrepo: new filev1.1
Diffstat (limited to 'buildrepo')
-rwxr-xr-x | buildrepo | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/buildrepo b/buildrepo new file mode 100755 index 0000000..067629d --- /dev/null +++ b/buildrepo @@ -0,0 +1,80 @@ +#!/bin/sh + +program=${0##*/} + +aportsdir=${APORTSDIR:-$HOME/aports} +repodir=${REPODIR:-$HOME/packages} + + +usage() { + echo "usage: $program [-a APORTSDIR] [-d REPODIR] [-hp] [-l LOGPREFIX ] REPOSITORY..." + 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" + 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 +} + +build() { + local repo="$1" i + + cd "$aportsdir/$repo" || return 1 + mkdir -p "$repodir/$repo" + + for i in */APKBUILD; do + ( cd ${i%/*} || return 1 + build $1 || exit 1 + purge $1 || exit 1 + PKGDEST="$repodir/$repo" abuild -r || return 1 + ) || return 1 + done + cd "$repodir/$repo" + md5sum *.apk | gzip -9 > INDEX.md5.gz + if which apk >/dev/null; then + apk index *.apk | gzip -9 > APK_INDEX.gz + fi + purge "$repo" +} + +while getopts "a:d:hl:p" opt; do + case "$opt" in + a) aportsdir=$OPTARG;; + d) repodir=$OPTARG;; + h) usage >&2;; + l) logprefix=$OPTARG;; + p) dopurge=1;; + 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 + |