Skip to content
commitpkg 3.58 KiB
Newer Older
	echo ${1:-'Cancelled'}
	exit 1
getpkgfile() {
	if [[ ${#} -ne 1 ]]; then
		echo 'ERROR: No canonical package found!' >&2
		exit 1
	elif [ ! -f "${1}" ]; then
		echo "ERROR: Package ${1} not found!" >&2
		exit 1
	fi

	echo ${1}
}
Florian Pritz's avatar
Florian Pritz committed
##
#  usage : get_full_version( $epoch, $pkgver, $pkgrel )
# return : full version spec, including epoch (if necessary), pkgver, pkgrel
##
get_full_version() {
	if [[ $1 -eq 0 ]]; then
		# zero epoch case, don't include it in version
		echo $2-$3
	else
		echo $1:$2-$3
	fi
}

# Source makepkg.conf; fail if it is not found
if [ -r '/etc/makepkg.conf' ]; then
	source '/etc/makepkg.conf'
	abort '/etc/makepkg.conf not found!'
fi

# Source user-specific makepkg.conf overrides
if [ -r ~/.makepkg.conf ]; then
	. ~/.makepkg.conf
if [ ! -f PKGBUILD ]; then
	abort 'No PKGBUILD file'
. PKGBUILD
pkgbase=${pkgbase:-$pkgname}
# set up repo-specific opts depending on how we were called
server='gerolde.archlinux.org'
if [ "$cmd" == 'extrapkg' ]; then
	repo='extra'
elif [ "$cmd" == 'corepkg' ]; then
	repo='core'
elif [ "$cmd" == 'testingpkg' ]; then
	repo='testing'
Pierre Schmitz's avatar
Pierre Schmitz committed
elif [ "$cmd" == 'stagingpkg' ]; then
	repo='staging'
elif [ "$cmd" == 'communitypkg' ]; then
	repo='community'
	server='aur.archlinux.org'
elif [ "$cmd" == 'community-testingpkg' ]; then
	repo='community-testing'
	server='aur.archlinux.org'
elif [ "$cmd" == 'community-stagingpkg' ]; then
	repo='community-staging'
	server='aur.archlinux.org'
elif [ "$cmd" == 'multilibpkg' ]; then
	repo='multilib'
	server='aur.archlinux.org'
elif [ "$cmd" == 'multilib-testingpkg' ]; then
	repo='multilib-testing'
	server='aur.archlinux.org'
	if [ $# -eq 0 ]; then
		abort 'usage: commitpkg <reponame> [-l limit] [commit message]'
	fi
	repo="$1"
	shift
# check if all local source files are under version control
for s in ${source[@]}; do
	echo $s | grep -Fvq '://' && \
	svn status $s | grep -q '^\?' && \
	abort "$s is not under version control"
# check if changelog and install files are under version control
	filelist=$(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
	for file in $filelist; do
		# evaluate any bash variables used
		eval file=${file}
		if svn status ${file} | grep -q '^\?'; then
			abort "${file} is not under version control"
		fi
	done
Pierre Schmitz's avatar
Pierre Schmitz committed
# see if any limit options were passed, we'll send them to rsync
unset rsyncopts
if [ "$1" = '-l' ]; then
	rsyncopts="--bwlimit=$2"
	shift 2
echo -n 'committing changes to trunk...'
if [ -n "$1" ]; then
	svn commit -q -m "upgpkg: $pkgbase $pkgver-$pkgrel
$1" || abort
	svn commit -q || abort
for _arch in ${arch[@]}; do
	for _pkgname in ${pkgname[@]}; do
Florian Pritz's avatar
Florian Pritz committed
		fullver=$(get_full_version ${epoch:-0} $pkgver $pkgrel)
		pkgfile=$(getpkgfile "$_pkgname-$fullver-${_arch}".pkg.tar.?z 2>/dev/null)
		pkgdestfile=$(getpkgfile "$PKGDEST/$_pkgname-$fullver-${_arch}".pkg.tar.?z 2>/dev/null)
		if [ -f "$pkgfile" ]; then
			pkgfile="./$pkgfile"
		elif [ -f "$pkgdestfile" ]; then
			pkgfile="$pkgdestfile"
			echo "skipping ${_arch}"
			continue 2
		fi

		echo -n 'uploading '
		rsync -p --chmod 'ug=rw,o=r' -c -h -L --progress $rsyncopts --partial "${pkgfile}" -e ssh "$server:staging/$repo/${pkgfile##*/}" || abort
	done
	archrelease $repo-${_arch} || abort
if [ "${arch[*]}" == 'any' ]; then
	if [ -d ../repos/$repo-i686 -a -d ../repos/$repo-x86_64 ]; then
		pushd ../repos/ >/dev/null
		echo "removing $repo-i686 and $repo-x86_64..."
		svn rm $repo-i686
		svn rm $repo-x86_64
		svn commit -q -m "removed $repo-i686 and $repo-x86_64 for $pkgname"
		echo 'done'
		popd >/dev/null
	fi