Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/archrelease.in
blob: 3607d1906823fb436c9a6842cf5a4a8487f582f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
# SPDX-License-Identifier: GPL-3.0-or-later

m4_include(lib/common.sh)
m4_include(lib/valid-tags.sh)

# parse command line options
FORCE=
while getopts ':f' flag; do
	case $flag in
		f) FORCE=1 ;;
		:) die "Option requires an argument -- '%s'" "$OPTARG" ;;
		\?) die "Invalid option -- '%s'" "$OPTARG" ;;
	esac
done
shift $(( OPTIND - 1 ))

if ! (( $# )); then
	echo 'Usage: archrelease [-f] <repo>...'
	exit 1
fi

# validate repo is really repo-arch
if [[ -z $FORCE ]]; then
	for tag in "$@"; do
		if ! in_array "$tag" "${_tags[@]}"; then
			die "archrelease: Invalid tag: '%s' (use -f to force release)" "$tag"
		fi
	done
fi

if [[ ! -f PKGBUILD ]]; then
	die 'archrelease: PKGBUILD not found'
fi

. ./PKGBUILD
pkgbase=${pkgbase:-$pkgname}
pkgver=$(get_full_version "$pkgbase")
tag_pkgver=release-${pkgver/:/-}

if git rev-parse "$tag_pkgver" >/dev/null 2>&1; then
	die "archrelease: the tag $pkgver already exists in the repository!"
fi

# If the tag exists we check if it's properly signed and that it
# matches the working directory PKGBUILD.
if git tag --verify "$tag_pkgver" &> /dev/null; then
	cwd_checksum=$(sha256sum PKGBUILD|cut -d' ' -f1)
	tag_checksum=$(git show $tag_pkgver:PKGBUILD | sha256sum |cut -d' ' -f1)
	if [[ "$cwd_checksum" != "$tag_checksum" ]]; then
		die "tagged PKGBUILD is not the same as the working dir PKGBUILD"
	fi
	exit 0
fi

stat_busy "Releasing package"
printf -v tag_list ", %s" "$@"; tag_list="${tag_list#, }"
git tag -s -m "archrelease: released $pkgbase-$pkgver to $tag_list"  "$tag_pkgver" || abort
git push --tags main || abort
stat_done