2008-04-06 03:11:32 +02:00
|
|
|
#!/bin/bash
|
2021-06-10 19:16:22 +02:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2008-04-06 03:11:32 +02:00
|
|
|
|
2022-10-10 00:37:51 +02:00
|
|
|
_DEVTOOLS_LIBRARY_DIR=${_DEVTOOLS_LIBRARY_DIR:-@pkgdatadir@}
|
|
|
|
# shellcheck source=src/lib/common.sh
|
|
|
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/common.sh
|
|
|
|
# shellcheck source=src/lib/valid-tags.sh
|
|
|
|
source "${_DEVTOOLS_LIBRARY_DIR}"/lib/valid-tags.sh
|
|
|
|
|
2010-02-22 08:13:43 +01:00
|
|
|
|
2012-02-09 00:50:15 +01:00
|
|
|
# parse command line options
|
|
|
|
FORCE=
|
|
|
|
while getopts ':f' flag; do
|
|
|
|
case $flag in
|
|
|
|
f) FORCE=1 ;;
|
2013-07-30 21:24:48 +02:00
|
|
|
:) die "Option requires an argument -- '%s'" "$OPTARG" ;;
|
|
|
|
\?) die "Invalid option -- '%s'" "$OPTARG" ;;
|
2012-02-09 00:50:15 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
|
|
|
|
if ! (( $# )); then
|
|
|
|
echo 'Usage: archrelease [-f] <repo>...'
|
2011-11-01 15:33:08 +01:00
|
|
|
exit 1
|
2008-04-06 03:11:32 +02:00
|
|
|
fi
|
|
|
|
|
2012-02-09 00:50:15 +01:00
|
|
|
# validate repo is really repo-arch
|
|
|
|
if [[ -z $FORCE ]]; then
|
|
|
|
for tag in "$@"; do
|
|
|
|
if ! in_array "$tag" "${_tags[@]}"; then
|
2013-07-30 21:24:48 +02:00
|
|
|
die "archrelease: Invalid tag: '%s' (use -f to force release)" "$tag"
|
2012-02-09 00:50:15 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2011-07-25 19:52:09 +02:00
|
|
|
|
2011-08-17 03:36:00 +02:00
|
|
|
if [[ ! -f PKGBUILD ]]; then
|
2011-11-01 15:33:08 +01:00
|
|
|
die 'archrelease: PKGBUILD not found'
|
2008-04-22 04:31:51 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-27 17:48:53 +02:00
|
|
|
. ./PKGBUILD
|
|
|
|
pkgbase=${pkgbase:-$pkgname}
|
|
|
|
pkgver=$(get_full_version "$pkgbase")
|
2022-09-11 12:31:39 +02:00
|
|
|
gittag=$(get_tag_from_pkgver "$pkgver")
|
2010-12-14 15:13:06 +01:00
|
|
|
|
2022-09-11 12:31:39 +02:00
|
|
|
if git rev-parse "$gittag" >/dev/null 2>&1; then
|
|
|
|
die "archrelease: the tag $gittag for version $pkgver already exists in the repository!"
|
2008-04-22 04:31:51 +02:00
|
|
|
fi
|
2011-08-20 22:18:48 +02:00
|
|
|
|
2020-05-30 01:59:58 +02:00
|
|
|
# If the tag exists we check if it's properly signed and that it
|
|
|
|
# matches the working directory PKGBUILD.
|
2022-09-11 12:31:39 +02:00
|
|
|
if git tag --verify "$gittag" &> /dev/null; then
|
2020-05-30 01:59:58 +02:00
|
|
|
cwd_checksum=$(sha256sum PKGBUILD|cut -d' ' -f1)
|
2022-09-11 12:31:39 +02:00
|
|
|
tag_checksum=$(git show "${gittag}:PKGBUILD" | sha256sum |cut -d' ' -f1)
|
2020-05-30 01:59:58 +02:00
|
|
|
if [[ "$cwd_checksum" != "$tag_checksum" ]]; then
|
|
|
|
die "tagged PKGBUILD is not the same as the working dir PKGBUILD"
|
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-11-02 01:38:42 +01:00
|
|
|
stat_busy "Releasing package"
|
2022-09-11 12:31:39 +02:00
|
|
|
git tag --sign --message="Package release ${pkgver}" "$gittag" || abort
|
2022-09-07 23:10:51 +02:00
|
|
|
git push --tags main || abort
|
2011-11-01 15:33:08 +01:00
|
|
|
stat_done
|