abump.in 1.03 KB
Newer Older
1 2
#!/bin/sh

3 4
program=${0##*/}

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
die() {
	echo "$@" >&2
	exit 1
}

# version bump a pkg

do_bump() {
	pkgname=${1%-[0-9]*}
	pkgver=${1#${pkgname}-}

	APORTS=$HOME/aports

	set -e

20
	cd $APORTS/*/$pkgname || return 1
21 22 23 24 25 26 27 28 29 30 31 32
	section=${PWD%/*}
	section=${section##*/}

	msg="$section/$pkgname: upgrade to $pkgver"
	echo "$msg"
	
	( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
		
	sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
		-e "s/^pkgrel=.*/pkgrel=0/" \
		APKBUILD

33
	abuild $abuild_opts checksum all || exit 1
34 35 36 37 38

	git add APKBUILD
	git commit -m"$msg"
}

39 40 41 42 43 44
usage() {
	echo "$program - utility to bump pkgver in APKBUILDs"
	echo "usage: $program [-hR]"
	echo ""
	echo "  -h  show this help"
	echo "  -R  run abuild with -R for recursive building"
45
	echo "  -k  keep existing packages"
46 47 48
	exit 0
}

49 50 51
keep=
recursive="-r"
while getopts "hkR" opt; do
52 53
	case $opt in
	h) usage;;
54 55
	k) keep="-k";;
	R) recursive="-R";;
56 57 58 59
	esac
done
shift $(( $OPTIND - 1))

60 61
abuild_opts="$recursive $keep"

62 63 64 65
while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done
66