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

Message ID 20180704021532.24446-2-eschwartz@archlinux.org
State New
Headers show
Series
  • [dbscripts,1/2] Preliminary work to break out svn-specific code.
Related show

Commit Message

Eli Schwartz via arch-projects July 4, 2018, 2:15 a.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 aa7952d8..f9e9b6f7 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
+}