summaryrefslogtreecommitdiffstats
path: root/archrelease.in
blob: 2d68376ee20232b7ff13ca18aae27281425ef121 (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
#!/bin/bash

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 -- '$OPTARG'" ;;
		\?) die "Invalid option -- '$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: "'$tag'" (use -f to force release)'
		fi
	done
fi

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

trunk=${PWD##*/}

if [[ $(git status -s | grep -v "^?? ") ]]; then
	die 'archrelease: You have not committed your changes yet!'
fi

# TODO: merge with code from commitpkg
if [[ -z $server ]]; then
	case "$repo" in
		core|extra|testing|staging|kde-unstable|gnome-unstable)
			server='gerolde.archlinux.org' ;;
		community*|multilib*)
			server='aur.archlinux.org' ;;
		*)
			server='gerolde.archlinux.org'
			msg "Non-standard repository $repo in use, defaulting to server $server" ;;
	esac
fi

stat_busy "Releasing package"
printf -v tag_list ", %s" "$@"; tag_list="${tag_list#, }"
ssh $server commit -q -m "archrelease: copy ${trunk} to $tag_list" || abort
stat_done

popd >/dev/null