abump.in 1.47 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
program=${0##*/}

11 12 13 14 15 16 17 18
die() {
	echo "$@" >&2
	exit 1
}

# version bump a pkg

do_bump() {
19 20
	local pkgname=${1%-[0-9]*}
	local pkgver=${1#${pkgname}-}
21 22 23 24 25

	APORTS=$HOME/aports

	set -e

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

34
	msg="$section/$pkgname: $upgrade to ${pkgver}${cve}"
35 36 37 38 39 40
	if [ -n "$fixes" ]; then
		msg="$msg

fixes #${fixes#\#}
"
	fi
41
	echo "$msg"
42

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

45 46 47 48
	sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
		-e "s/^pkgrel=.*/pkgrel=0/" \
		APKBUILD

49
	abuild $abuild_opts checksum all || exit 1
50 51 52 53 54

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

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

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

80 81
abuild_opts="$recursive $keep"

82 83 84 85
while [ $# -gt 0 ]; do
	( do_bump "$1" ) || exit 1
	shift
done
86