[dbscripts,2/5] db-move: Clarify the flow of the preflight check

Message ID 20180619042104.15664-3-lukeshu@lukeshu.com
State New
Headers show
Series
  • Be less tightly coupled with SVN
Related show

Commit Message

Luke Shumaker June 19, 2018, 4:21 a.m. UTC
From: Luke Shumaker <lukeshu@parabola.nu>

This should have the same result, but be a bit less confusing to read.
---
 db-move | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Patch

diff --git a/db-move b/db-move
index 03debfc..5f197b8 100755
--- a/db-move
+++ b/db-move
@@ -29,15 +29,22 @@  arch_svn checkout -q -N "${SVNREPO}" "${WORKDIR}/svn" >/dev/null
 for pkgbase in "${args[@]:2}"; do
 	arch_svn up -q "${WORKDIR}/svn/${pkgbase}" >/dev/null
 	for tarch in "${ARCHES[@]}"; do
+		found=false
 		while read -r pkgarch pkgfile; do
+
 			svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
-			if [[ -r ${svnrepo_from}/PKGBUILD ]]; then
-				getpkgfile "${ftppath_from}/${tarch}/${pkgfile}" >/dev/null
-				continue 3
+			if ! [[ -r ${svnrepo_from}/PKGBUILD ]]; then
+				die "%s not found in %s" "$pkgbase" "$repo_from"
 			fi
+
+			# getpkgfile will `exit` for us if it fails;
+			# no need to check its result
+			getpkgfile "${ftppath_from}/${tarch}/${pkgfile}" >/dev/null
+
+			found=true
 		done < <(getdbinfo "$repo_from" "$tarch" "$pkgbase" ARCH,FILENAME)
+		[[ $found = true ]] || die "%s not found in %s" "$pkgbase" "$repo_from"
 	done
-	die "%s not found in %s" "$pkgbase" "$repo_from"
 done
 
 msg "Moving packages from [%s] to [%s]..." "$repo_from" "$repo_to"