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

3 4 5 6 7 8
# abump - bump pkgver in APKBUILDs
# Copyright (c) 2012 Natanael Copa <ncopa@alpinelinux.org>
#
# Distributed under GPL-2
#

9 10
abuild_ver=@VERSION@
datadir=@datadir@
11

12 13
if ! [ -f "$datadir/functions.sh" ]; then
	echo "$datadir/functions.sh: not found" >&2
14
	exit 1
15 16 17
fi
. "$datadir/functions.sh"

18 19 20 21

# version bump a pkg

do_bump() {
22 23
	local pkgname=${1%-[0-9]*}
	local pkgver=${1#${pkgname}-}
24 25 26 27 28

	APORTS=$HOME/aports

	set -e

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

37
	message="$section/$pkgname: $upgrade to ${pkgver}${cve}"
38
	if [ -n "$fixes" ]; then
39
		message="$message
40 41 42 43

fixes #${fixes#\#}
"
	fi
44
	echo "$message"
45

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

48 49 50 51
	sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
		-e "s/^pkgrel=.*/pkgrel=0/" \
		APKBUILD

52
	abuild $abuild_opts checksum all || exit 1
53 54

	git add APKBUILD
55
	git commit -m"$message"
56 57
}

58
usage() {
59 60
	echo "$prog - utility to bump pkgver in APKBUILDs"
	echo "usage: $prog [-hR] [-s CVE-1,CVE-2,...] [-f ISSUE]"
61 62 63
	echo ""
	echo "  -h  show this help"
	echo "  -R  run abuild with -R for recursive building"
64
	echo "  -k  keep existing packages"
65
	echo "  -s  security update"
66
	echo "  -f  fixes ISSUE"
67 68 69
	exit 0
}

70 71
keep=
recursive="-r"
72
while getopts "f:hkRs:" opt; do
73
	case $opt in
74
	f) fixes="${OPTARG}";;
75
	h) usage;;
76 77
	k) keep="-k";;
	R) recursive="-R";;
78
	s) cvelist="$OPTARG";;
79 80 81 82
	esac
done
shift $(( $OPTIND - 1))

83 84
abuild_opts="$recursive $keep"

85 86 87 88
while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done
89