summaryrefslogtreecommitdiff
path: root/abump.in
blob: 9d310a39650751b4c7cc11a443956ec6855aec12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh

program=${0##*/}

die() {
	echo "$@" >&2
	exit 1
}

# version bump a pkg

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

	APORTS=$HOME/aports

	set -e

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

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

	abuild $abuild_opts checksum all || exit 1

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

usage() {
	echo "$program - utility to bump pkgver in APKBUILDs"
	echo "usage: $program [-hR] [-s CVE-1,CVE-2,...]"
	echo ""
	echo "  -h  show this help"
	echo "  -R  run abuild with -R for recursive building"
	echo "  -k  keep existing packages"
	echo "  -s  security update"
	exit 0
}

keep=
recursive="-r"
while getopts "hkRs:" opt; do
	case $opt in
	h) usage;;
	k) keep="-k";;
	R) recursive="-R";;
	s) cvelist="$OPTARG";;
	esac
done
shift $(( $OPTIND - 1))

abuild_opts="$recursive $keep"

while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done