[dbscripts,2/4] Factor out the exporting of files/folders from svn.

Message ID 20181008212230.27793-3-eschwartz@archlinux.org
State Accepted, archived
Headers show
Series Refactoring svn calls | expand

Commit Message

Emil Velikov via arch-projects Oct. 8, 2018, 9:22 p.m. UTC
As of the source_pkgbuild rewrite, this is only ever done once.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---
 cron-jobs/sourceballs |  3 +--
 db-functions-svn      | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

Patch

diff --git a/cron-jobs/sourceballs b/cron-jobs/sourceballs
index 6be28abc..115c5bc0 100755
--- a/cron-jobs/sourceballs
+++ b/cron-jobs/sourceballs
@@ -79,8 +79,7 @@  for repo in "${PKGREPOS[@]}"; do
 
 			# Get the sources from svn
 			mkdir -p -m0770 "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}"
-			arch_svn export -q "${SVNREPO}/${pkgbase}/repos/${repo}-${pkgarch}" \
-				"${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}" >/dev/null 2>&1
+			export_from_vcs "${pkgbase}" "repos/${repo}-${pkgarch}" "" "${WORKDIR}/pkgbuilds/${repo}-${pkgarch}/${pkgbase}"
 			if (( $? >= 1 )); then
 				failedpkgs+=("${pkgbase}-${pkgver}${SRCEXT}")
 				continue
diff --git a/db-functions-svn b/db-functions-svn
index 41a87cc0..deb4e389 100644
--- a/db-functions-svn
+++ b/db-functions-svn
@@ -25,3 +25,18 @@  source_pkgbuild() {
 
 	. <(arch_svn cat "${SVNREPO}/${pkgbase}/${tag}/PKGBUILD" 2>/dev/null || echo "false")
 }
+
+# Export PKGBUILD resource(s) from the package's git/svn/whatever repo.
+# Depending on how the VCS is used the tag might be "trunk" or "repos/$repo-$arch"
+# or the full package version (epoch:pkgver-pkgrel) or any other recognized tag.
+export_from_vcs() {
+	local pkgbase=${1}
+	local tag=${2}
+	local src=${3}
+	local dest=${4}
+
+	if [[ ! -e ${dest} ]]; then
+		mkdir -p "${dest%/?*}"
+		arch_svn export -q "${SVNREPO}/${pkgbase}/${tag}/${src}" "${dest}" 2>/dev/null
+	fi
+}