From 7f78dc3a2f09dafebe06f775c5611f1b7554115b Mon Sep 17 00:00:00 2001
From: Luke Shumaker <LukeShu@sbcglobal.net>
Date: Sun, 22 Sep 2013 16:39:58 -0400
Subject: work on xbs-abs

---
 src/xbs-abs/helper-abs   | 86 +++++++++++++++++++++++++++++++++++-------------
 src/xbs-abs/xbs-abs.conf |  5 +--
 2 files changed, 67 insertions(+), 24 deletions(-)

(limited to 'src')

diff --git a/src/xbs-abs/helper-abs b/src/xbs-abs/helper-abs
index 0471c81..f1f4937 100755
--- a/src/xbs-abs/helper-abs
+++ b/src/xbs-abs/helper-abs
@@ -31,7 +31,8 @@
 load_config() {
 	. $(librelib conf.sh)
 	load_files xbs-abs
-	check_vars SVNURL SVNREPO ARCHES || exit 1
+	# SVNUSER is optional
+	check_vars SVNDIR SVNREPOS ARCHES || exit 1
 }
 
 # This is taken from dbscripts:db-fuctions
@@ -43,6 +44,25 @@ arch_svn() {
 	fi
 }
 
+pac2svn() {
+	local pacrepo=$1
+
+	# Figure out which svn repo we need
+	local svnrepoStr
+	for svnrepoStr in "${SVNREPOS[@]}"; do
+		local svnrepoAry=($svnrepoStr)
+		local svnrepo=${svnrepoAry[0]}
+		local svnurl=${svnrepoAry[1]}
+		local pacrepos=("${svnrepoAry[@]:2}")
+
+		if in_array "$pacrepo" "${pacrepos[@]}"; then
+			echo "$svnrepo"
+			return 0
+		fi
+	done
+	return 1
+}
+
 status() {
 	load_config
 	[[ -z $(arch_svn status -q) ]]
@@ -50,21 +70,41 @@ status() {
 
 download() {
 	load_config
-	if [[ -d "$SVNREPO/.svn" ]]; then
-		arch_svn -q up "$SVNREPO"/*
-	else
-		# checkout non-recursive, then lazy load
-		# nescessary because:
-		#  > DO NOT CHECK OUT THE ENTIRE SVN REPO. Your address may be blocked.
-		arch_svn -q checkout -N "$SVNURL" "$SVNREPO"
-	fi
+
+	local svnrepoStr
+	for svnrepoStr in "${SVNREPOS[@]}"; do
+		local svnrepoAry=($svnrepoStr)
+		local svnrepo=${svnrepoAry[0]}
+		local svnurl=${svnrepoAry[1]}
+		local pacrepos=("${svnrepoAry[@]:2}")
+
+		if [[ -d "$SVNDIR/$svnrepo/.svn" ]]; then
+			arch_svn -q up "$SVNDIR/$svnrepo"/*
+		else
+			# checkout non-recursive, then lazy load
+			# nescessary because:
+			#  > DO NOT CHECK OUT THE ENTIRE SVN REPO. Your address
+			#  > may be blocked.
+			arch_svn -q checkout -N "$svnurl" "$SVNDIR/$svnrepo"
+		fi
+	done
 }
 
 release() {
 	local repo=$1
 	local arch=$2
 
-	"${0}.d/archrelease" -f "${repo}-${arch}"
+	local tmpdir="$(mktemp -dt "xbs-abs-release.XXXXXXXXXX")"
+	trap "$(printf 'rm -rf -- %q' "$tmpdir")" EXIT
+
+	printf '%s\n' \
+		'#!/bin/bash' \
+		"$(declare -f arch_svn)" \
+		'arch_svn "$@"' \
+		> "$tmpdir/svn"
+	chmod 755 "$tmpdir/svn"
+
+	PATH="$tmpdir:$PATH" "${0}.d/archrelease" -f "${repo}-${arch}"
 }
 
 unrelease() {
@@ -72,15 +112,15 @@ unrelease() {
 	local repo=$2
 	local arch=$3
 
-	local svnrepo="$repo-$arch"
-	load_config
+	local tag="$repo-$arch"
 
-	arch_svn up -q "${SVNREPO}/${pkgbase}"
+	load_config
+	local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+	arch_svn up -q "$svndir"
 
 	# This is based off code from dbscripts:db-remove
-	remove_pkgs=$(. "${SVNREPO}/$pkgbase/repos/$svnrepo/PKGBUILD"; echo ${pkgname[@]})
-	arch_svn rm --force -q "${SVNREPO}/$pkgbase/repos/$svnrepo"
-	arch_svn commit -q "${SVNREPO}/$pkgbase" -m "${0##*/}: $pkgbase removed by $(id -un)"
+	arch_svn rm --force -q "${svndir}/repos/${tag}"
+	arch_svn commit -q "${svndir}" -m "${0##*/}: $pkgbase removed by $(id -un)"
 }
 
 move() {
@@ -89,15 +129,16 @@ move() {
 	local pkgbase=$3
 
 	load_config
-	arch_svn up -q "${SVNREPO}/${pkgbase}"
+	local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+	arch_svn up -q "$svndir"
 
 	local tag_list=""
 	local pkgarch
 	local arches=()
 	# this is based off code from dbscripts:db-move
 	for pkgarch in "${ARCHES[@]}" 'any'; do
-		dir_from="${SVNREPO}/${pkgbase}/repos/${repo_from}-${pkgarch}"
-		dir_to="${SVNREPO}/${pkgbase}/repos/${repo_to}-${pkgarch}"
+		dir_from="${svndir}/repos/${repo_from}-${pkgarch}"
+		dir_to="${svndir}/repos/${repo_to}-${pkgarch}"
 
 		if [ -f "${dir_from}/PKGBUILD" ]; then
 			if [ -d "${dir_to}" ]; then
@@ -118,7 +159,7 @@ move() {
 		fi
 	done
 	tag_list="${tag_list#, }"
-	arch_svn commit -q "${SVNREPO}/${pkgbase}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})"
+	arch_svn commit -q "${svndir}" -m "${0##*/}: moved ${pkgbase} from [${repo_from}] to [${repo_to}] (${tag_list})"
 	echo "${arches[*]}"
 }
 
@@ -128,8 +169,9 @@ releasepath() {
 	local arch=$3
 
 	load_config
-	arch_svn up -q "${SVNREPO}/${pkgbase}"
-	echo "${SVNREPO}/${pkgbase}/repos/${repo}-${arch}"
+	local svndir="${SVNDIR}/$(pac2svn "$repo")/${pkgbase}"
+	arch_svn up -q "${svndir}"
+	echo "${svndir}/repos/${repo}-${arch}"
 }
 
 case "$1" in
diff --git a/src/xbs-abs/xbs-abs.conf b/src/xbs-abs/xbs-abs.conf
index be5b756..3ceba6a 100644
--- a/src/xbs-abs/xbs-abs.conf
+++ b/src/xbs-abs/xbs-abs.conf
@@ -1,5 +1,5 @@
-SVNDIR=
-ARCHES=(i686 x86_64)
+SVNDIR=/var/lib/xbs-abs
+#SVNUSER=
 
 # name url repos...
 SVNREPOS=(
@@ -7,3 +7,4 @@ SVNREPOS=(
   'commuity svn://svn.archlinux.org/community community community-testing multilib multilib-testing'
 )
 
+ARCHES=(i686 x86_64)
-- 
cgit v1.2.3-2-g168b