[arch-projects] [dbscripts] [PATCH 5/5] db-move, db-abs: Simplify the abs_move_* functions
Luke Shumaker
lukeshu at lukeshu.com
Tue Jun 19 04:21:04 UTC 2018
From: Luke Shumaker <lukeshu at parabola.nu>
Currently, abs_move_preflight_check and abs_move_arch require the
exact pkgarch (i.e. "any" or "x86_64"). Modify them so that they take
the tarch (i.e. "x86_64") and figure out themselves if it needs to set
pkgarch=$tarch or pkgarch=any.
abs_export could probably stand to be modified to do something
similar, but it's more work to adjust its callers.
"Ignore space change" might be useful when viewing this diff.
---
db-abs | 56 ++++++++++++++++++++++++++++++++------------------------
db-move | 20 +++++++++-----------
2 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/db-abs b/db-abs
index 5a34b84..c510bad 100644
--- a/db-abs
+++ b/db-abs
@@ -20,12 +20,12 @@ _abs_checkout() {
abs_move_preflight_check() {
local repo_from=$1
- local pkgarch=$2
+ local tarch=$2
local pkgbase=$3
_abs_checkout "$pkgbase"
- local svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
- [[ -r ${svnrepo_from}/PKGBUILD ]]
+ local reposdir="${WORKDIR}/svn/${pkgbase}/repos"
+ [[ -r ${reposdir}/${repo_from}-${tarch}/PKGBUILD || -r ${reposdir}/${repo_from}-any/PKGBUILD ]]
}
abs_move_start() {
@@ -37,37 +37,45 @@ abs_move_start() {
}
# If the "from" PKGBUILD doesn't exist, this is a no-op (not an
-# error), so that it can be run for each arch, and the invoker doesn't
-# need to worry about hoisting it out of the loop if arch=(any). If
-# the nonexistence is such that it should be an error, we count on
-# abs_move_preflight_check having already caught that.
+# error). This is because we expect to be called exactly once for
+# each tarch (eg: x86_64, i686), but if arch=(any) then we only need
+# do the work once; on the subsequent calls the "from" PKGBUILD won't
+# exist anymore. If the source PKGBUILD never existed, we expect that
+# to have already been caught by abs_move_preflight_check.
abs_move_arch() {
- local pkgarch=$1
+ local tarch=$1
local repo_from=$abs_move_repo_from
local repo_to=$abs_move_repo_to
local pkgbase=$abs_move_pkgbase
+ local pkgarch
+ if [[ -r "${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${tarch}/PKGBUILD" ]]; then
+ pkgarch=$tarch
+ elif [[ -r "${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-any/PKGBUILD" ]]; then
+ pkgarch=any
+ else
+ return 0
+ fi
+
local svnrepo_from="${WORKDIR}/svn/${pkgbase}/repos/${repo_from}-${pkgarch}"
local svnrepo_to="${WORKDIR}/svn/${pkgbase}/repos/${repo_to}-${pkgarch}"
- if [[ -f ${svnrepo_from}/PKGBUILD ]]; then
- msg2 "%s (%s)" "$pkgbase" "$pkgarch"
-
- if [[ -d ${svnrepo_to} ]]; then
- for file in $(arch_svn ls "${svnrepo_to}"); do
- arch_svn rm -q "${svnrepo_to}/$file@"
- done
- else
- mkdir "${svnrepo_to}"
- arch_svn add -q "${svnrepo_to}"
- fi
-
- for file in $(arch_svn ls "${svnrepo_from}"); do
- arch_svn mv -q -r HEAD "${svnrepo_from}/$file@" "${svnrepo_to}/"
+ msg2 "%s (%s)" "$pkgbase" "$pkgarch"
+
+ if [[ -d ${svnrepo_to} ]]; then
+ for file in $(arch_svn ls "${svnrepo_to}"); do
+ arch_svn rm -q "${svnrepo_to}/$file@"
done
- arch_svn rm --force -q "${svnrepo_from}"
- abs_move_tag_list+=", $pkgarch"
+ else
+ mkdir "${svnrepo_to}"
+ arch_svn add -q "${svnrepo_to}"
fi
+
+ for file in $(arch_svn ls "${svnrepo_from}"); do
+ arch_svn mv -q -r HEAD "${svnrepo_from}/$file@" "${svnrepo_to}/"
+ done
+ arch_svn rm --force -q "${svnrepo_from}"
+ abs_move_tag_list+=", $pkgarch"
}
abs_move_finish() {
diff --git a/db-move b/db-move
index 8a1c24d..7fc0041 100755
--- a/db-move
+++ b/db-move
@@ -27,19 +27,18 @@ done
# check if packages to be moved exist in svn and ftp dir
for pkgbase in "${args[@]:2}"; do
for tarch in "${ARCHES[@]}"; do
- found=false
- while read -r pkgarch pkgfile; do
-
- if ! abs_move_preflight_check "$repo_from" "$pkgarch" "$pkgbase"; then
- die "%s not found in %s" "$pkgbase" "$repo_from"
- fi
+ if ! abs_move_preflight_check "$repo_from" "$tarch" "$pkgbase"; then
+ die "%s not found in %s" "$pkgbase" "$repo_from"
+ fi
+ found=false
+ while read -r pkgfile; do
# 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)
+ done < <(getdbinfo "$repo_from" "$tarch" "$pkgbase" FILENAME)
[[ $found = true ]] || die "%s not found in %s" "$pkgbase" "$repo_from"
done
done
@@ -51,16 +50,15 @@ declare -A remove_pkgs
for pkgbase in "${args[@]:2}"; do
abs_move_start "$repo_from" "$repo_to" "$pkgbase"
for tarch in "${ARCHES[@]}"; do
- while read -r pkgname pkgver pkgarch pkgfile; do
- abs_move_arch "$pkgarch"
-
+ abs_move_arch "$tarch"
+ while read -r pkgname pkgver pkgfile; do
ln -s "../../../${PKGPOOL}/${pkgfile}" "${ftppath_to}/${tarch}/"
if [[ -f ${FTP_BASE}/${PKGPOOL}/${pkgfile}.sig ]]; then
ln -s "../../../${PKGPOOL}/${pkgfile}.sig" "${ftppath_to}/${tarch}/"
fi
add_pkgs[${tarch}]+="${FTP_BASE}/${PKGPOOL}/${pkgfile} "
remove_pkgs[${tarch}]+="${pkgname} "
- done < <(getdbinfo "$repo_from" "$tarch" "$pkgbase" NAME,VERSION,ARCH,FILENAME)
+ done < <(getdbinfo "$repo_from" "$tarch" "$pkgbase" NAME,VERSION,FILENAME)
done
abs_move_finish
done
--
2.17.1
More information about the arch-projects
mailing list