2010-04-06 06:56:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-07-05 04:21:12 +00:00
|
|
|
# abump - bump pkgver in APKBUILDs
|
|
|
|
# Copyright (c) 2012 Natanael Copa <ncopa@alpinelinux.org>
|
|
|
|
#
|
|
|
|
# Distributed under GPL-2
|
|
|
|
#
|
|
|
|
|
2013-07-05 04:21:16 +00:00
|
|
|
abuild_ver=@VERSION@
|
|
|
|
datadir=@datadir@
|
2010-11-19 10:25:15 +00:00
|
|
|
|
2013-07-05 04:21:16 +00:00
|
|
|
if ! [ -f "$datadir/functions.sh" ]; then
|
|
|
|
echo "$datadir/functions.sh: not found" >&2
|
2010-04-06 06:56:33 +00:00
|
|
|
exit 1
|
2013-07-05 04:21:16 +00:00
|
|
|
fi
|
|
|
|
. "$datadir/functions.sh"
|
|
|
|
|
2010-04-06 06:56:33 +00:00
|
|
|
|
|
|
|
# version bump a pkg
|
|
|
|
|
|
|
|
do_bump() {
|
2012-02-14 14:53:05 +00:00
|
|
|
local pkgname=${1%-[0-9]*}
|
|
|
|
local pkgver=${1#${pkgname}-}
|
2010-04-06 06:56:33 +00:00
|
|
|
|
|
|
|
APORTS=$HOME/aports
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2010-11-19 10:25:15 +00:00
|
|
|
cd $APORTS/*/$pkgname || return 1
|
2012-02-14 14:53:05 +00:00
|
|
|
local section=${PWD%/*} upgrade="upgrade" cve=
|
2010-04-06 06:56:33 +00:00
|
|
|
section=${section##*/}
|
2012-02-14 14:53:05 +00:00
|
|
|
if [ -n "$cvelist" ]; then
|
|
|
|
upgrade="security upgrade"
|
|
|
|
cve=" ($cvelist)"
|
|
|
|
fi
|
2010-04-06 06:56:33 +00:00
|
|
|
|
2013-07-05 04:21:16 +00:00
|
|
|
message="$section/$pkgname: $upgrade to ${pkgver}${cve}"
|
2013-02-14 09:46:18 +00:00
|
|
|
if [ -n "$fixes" ]; then
|
2013-07-05 04:21:16 +00:00
|
|
|
message="$message
|
2013-02-14 09:46:18 +00:00
|
|
|
|
|
|
|
fixes #${fixes#\#}
|
|
|
|
"
|
|
|
|
fi
|
2013-07-05 04:21:16 +00:00
|
|
|
echo "$message"
|
2013-02-14 09:46:18 +00:00
|
|
|
|
2010-04-06 06:56:33 +00:00
|
|
|
( . ./APKBUILD; type package | grep -q function ) || die "package() missing"
|
2013-02-14 09:46:18 +00:00
|
|
|
|
2010-04-06 06:56:33 +00:00
|
|
|
sed -i -e "s/^pkgver=.*/pkgver=$pkgver/" \
|
|
|
|
-e "s/^pkgrel=.*/pkgrel=0/" \
|
|
|
|
APKBUILD
|
|
|
|
|
2010-11-19 10:25:15 +00:00
|
|
|
abuild $abuild_opts checksum all || exit 1
|
2010-04-06 06:56:33 +00:00
|
|
|
|
|
|
|
git add APKBUILD
|
2013-07-05 04:21:16 +00:00
|
|
|
git commit -m"$message"
|
2010-04-06 06:56:33 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 10:25:15 +00:00
|
|
|
usage() {
|
2013-07-05 04:21:19 +00:00
|
|
|
cat >&2 <<__EOF__
|
|
|
|
$prog $abuild_ver - bump pkgver in APKBUILDs
|
|
|
|
Usage: $prog [-s CVE-1,CVE-2,...] [-f ISSUE] [-R|--recursive] [-k|--keep] PKGNAME-1.2.3 ...
|
|
|
|
Options:
|
|
|
|
-s, --security CVE1,CVE-2,... Security update
|
|
|
|
-f, --fixes ISSUE Fixes ISSUE
|
|
|
|
-R, --recursive Run abuild with -R for recursive building
|
|
|
|
-k, --keep Run abuild with -k to keep existing packages
|
|
|
|
-q, --quiet
|
|
|
|
-h, --help Show this help
|
|
|
|
|
|
|
|
__EOF__
|
2010-11-19 10:25:15 +00:00
|
|
|
}
|
|
|
|
|
2011-09-30 06:43:27 +00:00
|
|
|
keep=
|
|
|
|
recursive="-r"
|
2013-07-05 04:21:19 +00:00
|
|
|
cvelist=
|
|
|
|
fixes=
|
|
|
|
|
|
|
|
args=`getopt -o s:Rkqh --long security:,recursive,keep,quiet,help -n "$prog" -- "$@"`
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
usage
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
eval set -- "$args"
|
|
|
|
while true; do
|
|
|
|
case $1 in
|
|
|
|
-s|--security) cvelist="$2"; shift;;
|
|
|
|
-f|--fixes) fixes="$2"; shift;;
|
|
|
|
-R|--recursive) recursive="-R";;
|
|
|
|
-k|--keep) keep="-k";;
|
|
|
|
-q|--quiet) quiet=1;; # suppresses msg
|
|
|
|
-h|--help) usage; exit;;
|
|
|
|
--) shift; break;;
|
|
|
|
*) exit 1;; # getopt error
|
2010-11-19 10:25:15 +00:00
|
|
|
esac
|
2013-07-05 04:21:19 +00:00
|
|
|
shift
|
2010-11-19 10:25:15 +00:00
|
|
|
done
|
2013-07-05 04:21:19 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
usage
|
|
|
|
exit 2
|
|
|
|
fi
|
2010-11-19 10:25:15 +00:00
|
|
|
|
2011-09-30 06:43:27 +00:00
|
|
|
abuild_opts="$recursive $keep"
|
|
|
|
|
2010-04-06 06:56:33 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
( do_bump "$1" ) || exit 1
|
|
|
|
shift
|
|
|
|
done
|
2010-11-19 10:25:15 +00:00
|
|
|
|