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

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

5 6 7 8 9 10 11 12
die() {
	echo "$@" >&2
	exit 1
}

# version bump a pkg

do_bump() {
13 14
	local pkgname=${1%-[0-9]*}
	local pkgver=${1#${pkgname}-}
15 16 17 18 19

	APORTS=$HOME/aports

	set -e

20
	cd $APORTS/*/$pkgname || return 1
21
	local section=${PWD%/*} upgrade="upgrade" cve=
22
	section=${section##*/}
23 24 25 26
	if [ -n "$cvelist" ]; then
		upgrade="security upgrade"
		cve=" ($cvelist)"
	fi
27

28
	msg="$section/$pkgname: $upgrade to ${pkgver}${cve}"
29 30 31 32 33 34
	if [ -n "$fixes" ]; then
		msg="$msg

fixes #${fixes#\#}
"
	fi
35
	echo "$msg"
36

37
	( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
38

39 40 41 42
	sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
		-e "s/^pkgrel=.*/pkgrel=0/" \
		APKBUILD

43
	abuild $abuild_opts checksum all || exit 1
44 45 46 47 48

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

49 50
usage() {
	echo "$program - utility to bump pkgver in APKBUILDs"
51
	echo "usage: $program [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]"
52 53 54
	echo ""
	echo "  -h  show this help"
	echo "  -R  run abuild with -R for recursive building"
55
	echo "  -k  keep existing packages"
56
	echo "  -s  security update"
57
	echo "  -f  fixes ISSUE"
58 59 60
	exit 0
}

61 62
keep=
recursive="-r"
63
while getopts "f:hkRs:" opt; do
64
	case $opt in
65
	f) fixes="${OPTARG}";;
66
	h) usage;;
67 68
	k) keep="-k";;
	R) recursive="-R";;
69
	s) cvelist="$OPTARG";;
70 71 72 73
	esac
done
shift $(( $OPTIND - 1))

74 75
abuild_opts="$recursive $keep"

76 77 78 79
while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done
80