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>
|
|
|
|
#
|
2020-10-23 14:39:18 +00:00
|
|
|
# Distributed under GPL-2.0-only
|
2013-07-05 04:21:12 +00:00
|
|
|
#
|
|
|
|
|
2013-10-25 07:26:05 +00:00
|
|
|
program_version=@VERSION@
|
2019-11-07 11:28:37 +00:00
|
|
|
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
|
2010-11-19 10:25:15 +00:00
|
|
|
|
2019-11-07 11:21:32 +00:00
|
|
|
if ! [ -f "$sharedir/functions.sh" ]; then
|
|
|
|
echo "$sharedir/functions.sh: not found" >&2
|
2010-04-06 06:56:33 +00:00
|
|
|
exit 1
|
2013-07-05 04:21:16 +00:00
|
|
|
fi
|
2019-11-07 11:21:32 +00:00
|
|
|
. "$sharedir/functions.sh"
|
2013-07-05 04:21:16 +00:00
|
|
|
|
2015-09-28 12:33:40 +00:00
|
|
|
: ${ABUILD:="abuild"}
|
|
|
|
|
2010-04-06 06:56:33 +00:00
|
|
|
|
2013-07-05 04:21:25 +00:00
|
|
|
# version bump packages
|
2010-04-06 06:56:33 +00:00
|
|
|
do_bump() {
|
2013-07-26 07:31:54 +00:00
|
|
|
local p rc=0 notbumped="" name ver section message
|
2013-07-05 04:21:28 +00:00
|
|
|
local upgrade="${cvelist:+security }upgrade"
|
2013-07-05 04:21:29 +00:00
|
|
|
local a
|
2013-07-05 04:21:25 +00:00
|
|
|
for p; do
|
2013-07-26 07:31:54 +00:00
|
|
|
if [ $rc -gt 0 ]; then
|
|
|
|
notbumped="$notbumped $p"
|
|
|
|
continue
|
|
|
|
fi
|
2013-07-05 04:21:30 +00:00
|
|
|
name=${p%-[0-9]*}
|
|
|
|
ver=${p#${name}-}
|
2014-10-30 08:10:39 +00:00
|
|
|
if [ "$name" = "$ver" ]; then
|
|
|
|
die "version missing for $p"
|
|
|
|
fi
|
2013-07-05 04:21:25 +00:00
|
|
|
|
2013-07-10 07:07:47 +00:00
|
|
|
(
|
|
|
|
set -e
|
|
|
|
|
2021-07-24 11:53:11 +00:00
|
|
|
# calculate APKBUILD's path #vim syntax highlight '
|
2013-07-09 12:57:20 +00:00
|
|
|
if [ "${name#*/}" != "$name" ] && ! [ -d "$APORTSDIR/${name%/*}" ]; then
|
2013-07-10 07:07:47 +00:00
|
|
|
die "'$p' should be of form 'foo-1.2.3' or 'main/foo-1.2.3'"
|
2013-07-05 04:21:29 +00:00
|
|
|
fi
|
2013-07-10 07:07:47 +00:00
|
|
|
a=$(aports_buildscript "$name" ) \
|
|
|
|
|| die "can't find APKBUILD for $name"
|
2013-07-05 04:21:30 +00:00
|
|
|
|
2022-10-15 11:06:53 +00:00
|
|
|
# sourcing APKBUILDs should not affect the environment of abump
|
|
|
|
# so do that in a subshell, along with any checks that need the
|
|
|
|
# information from the APKBUILD.
|
|
|
|
(
|
|
|
|
# verify APKBUILD
|
|
|
|
. "$a" || exit 1
|
|
|
|
name=${name#*/}
|
|
|
|
[ "$pkgname" = "$name" ] \
|
|
|
|
|| die "APKBUILD has different \$pkgname for $name"
|
|
|
|
type package | grep -q function \
|
|
|
|
|| die "missing package() for $name"
|
|
|
|
if [ "$pkgver" = "$ver" ] && git diff-index --quiet HEAD -- "$a"; then
|
|
|
|
die "version is already $ver"
|
|
|
|
fi
|
|
|
|
)
|
2013-07-05 04:21:25 +00:00
|
|
|
|
2013-07-05 04:21:29 +00:00
|
|
|
cd "${a%/*}"
|
2013-07-05 04:21:28 +00:00
|
|
|
section=${PWD%/*}
|
2013-07-05 04:21:25 +00:00
|
|
|
section=${section##*/}
|
|
|
|
|
2013-07-05 04:21:30 +00:00
|
|
|
message="$section/$name: $upgrade to ${ver}${cvelist}"
|
2013-07-05 04:21:25 +00:00
|
|
|
if [ -n "$fixes" ]; then
|
|
|
|
message="$message
|
2013-02-14 09:46:18 +00:00
|
|
|
|
|
|
|
fixes #${fixes#\#}
|
|
|
|
"
|
2013-07-05 04:21:25 +00:00
|
|
|
fi
|
2013-07-05 04:21:37 +00:00
|
|
|
msg "$message"
|
2013-02-14 09:46:18 +00:00
|
|
|
|
2013-07-05 04:21:30 +00:00
|
|
|
sed -i -e "s/^pkgver=.*/pkgver=$ver/" \
|
2013-07-05 04:21:25 +00:00
|
|
|
-e "s/^pkgrel=.*/pkgrel=0/" \
|
|
|
|
APKBUILD
|
2010-04-06 06:56:33 +00:00
|
|
|
|
2015-09-28 12:33:40 +00:00
|
|
|
$ABUILD $abuild_opts checksum all
|
2010-04-06 06:56:33 +00:00
|
|
|
|
2013-07-05 04:21:25 +00:00
|
|
|
git add APKBUILD
|
|
|
|
git commit -m"$message"
|
2013-07-10 07:07:47 +00:00
|
|
|
)
|
2013-07-26 07:31:54 +00:00
|
|
|
rc=$?
|
|
|
|
if [ $rc -gt 0 ]; then
|
|
|
|
error "Failed to build $p"
|
2013-07-22 13:57:14 +00:00
|
|
|
fi
|
2013-07-05 04:21:25 +00:00
|
|
|
done
|
2013-07-26 07:31:54 +00:00
|
|
|
if [ -n "$notbumped" ]; then
|
|
|
|
error "Not bumped: $notbumped"
|
2013-07-22 13:57:14 +00:00
|
|
|
fi
|
2013-07-26 07:31:54 +00:00
|
|
|
return $rc
|
2010-04-06 06:56:33 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 10:25:15 +00:00
|
|
|
usage() {
|
2022-06-20 14:51:43 +00:00
|
|
|
cat <<-__EOF__
|
2016-08-20 13:16:48 +00:00
|
|
|
$program $program_version - bump pkgver in APKBUILDs
|
2023-11-20 05:40:53 +00:00
|
|
|
Usage: $program [-s CVE-1,CVE-2,...] [-f ISSUE] [-k|--keep] PKGNAME-1.2.3 ...
|
2016-08-20 13:16:48 +00:00
|
|
|
Options:
|
|
|
|
-s, --security CVE1,CVE-2,... Security update
|
|
|
|
-f, --fixes ISSUE Fixes ISSUE
|
|
|
|
-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=
|
2013-07-05 04:21:19 +00:00
|
|
|
cvelist=
|
|
|
|
fixes=
|
|
|
|
|
2021-04-29 10:09:47 +00:00
|
|
|
args=$(getopt -o f:s:kqh --long fixes:,security:,keep,quiet,help \
|
2016-08-20 14:11:44 +00:00
|
|
|
-n "$program" -- "$@")
|
2013-07-05 04:21:19 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2022-06-20 14:51:43 +00:00
|
|
|
usage >&2
|
2013-07-05 04:21:19 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
eval set -- "$args"
|
|
|
|
while true; do
|
|
|
|
case $1 in
|
2013-07-05 04:21:28 +00:00
|
|
|
-s|--security) cvelist=" ($2)"; shift;;
|
2013-07-05 04:21:19 +00:00
|
|
|
-f|--fixes) fixes="$2"; shift;;
|
|
|
|
-k|--keep) keep="-k";;
|
|
|
|
-q|--quiet) quiet=1;; # suppresses msg
|
2022-06-20 14:51:43 +00:00
|
|
|
-h|--help) usage; exit 0;;
|
2013-07-05 04:21:19 +00:00
|
|
|
--) 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
|
2022-06-20 14:51:43 +00:00
|
|
|
usage >&2
|
2013-07-05 04:21:19 +00:00
|
|
|
exit 2
|
|
|
|
fi
|
2010-11-19 10:25:15 +00:00
|
|
|
|
2022-06-20 14:51:43 +00:00
|
|
|
[ -n "$APORTSDIR" ] || error "can't locate \$APORTSDIR"
|
|
|
|
git rev-parse 2>/dev/null || die "not in a git tree"
|
|
|
|
|
2021-04-29 10:38:29 +00:00
|
|
|
abuild_opts="${ABUILD_OPTS- -r} $keep"
|
2011-09-30 06:43:27 +00:00
|
|
|
|
2013-07-05 04:21:25 +00:00
|
|
|
do_bump "$@"
|