From b2952784db9995ecc21d3a770530a19394234d3b Mon Sep 17 00:00:00 2001
From: Pierre Schmitz <pierre@archlinux.de>
Date: Sat, 27 Oct 2012 14:32:39 +0200
Subject: Add the possibility to run all svn commands with a different user

* A SVNUSER can be configured in the config file
* This user needs to be able to call svn without a password
---
 db-functions | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

(limited to 'db-functions')

diff --git a/db-functions b/db-functions
index e3485d3..b9d0d2f 100644
--- a/db-functions
+++ b/db-functions
@@ -347,7 +347,7 @@ check_pkgsvn() {
 
 	if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
 		mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
-		svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
+		arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
 			"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null
 		[ $? -ge 1 ] && return 1
 	fi
@@ -382,7 +382,7 @@ check_splitpkgs() {
 
 		if [ ! -f "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" ]; then
 			mkdir -p "${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}"
-			svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
+			arch_svn export -q "${SVNREPO}/${_pkgbase}/repos/${repo}-${_pkgarch}/PKGBUILD" \
 				"${WORKDIR}/pkgbuilds/${repo}-${_pkgarch}/${_pkgbase}" >/dev/null
 			[ $? -ge 1 ] && return 1
 		fi
@@ -504,3 +504,11 @@ arch_repo_remove() {
 		|| error "repo-remove ${filesfile} ${pkgs[@]}"
 	set_repo_permission "${repo}" "${arch}"
 }
+
+arch_svn() {
+	if [ -z "${SVNUSER}" ]; then
+		/usr/bin/svn "${@}"
+	else
+		sudo -u "${SVNUSER}" -- /usr/bin/svn "${@}"
+	fi
+}
-- 
cgit v1.2.3-2-g168b