diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2018-06-17 13:22:45 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2018-10-07 18:15:03 -0400 |
commit | e70149dd1be45a412cd3a1c5e9bc66741e4823ea (patch) | |
tree | 4cc4027229c8f07f9211ef796fe56ddf5128385d | |
parent | a85281eeed42e5ffa37ce6ab8f57dd9b5d9dc8b9 (diff) |
db-move, db-functions-svn: Simplify calling the vcs_move_* functions
Currently, vcs_move_preflight_check and vcs_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.
vcs_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.
-rw-r--r-- | db-functions-svn | 58 | ||||
-rwxr-xr-x | db-move | 15 |
2 files changed, 40 insertions, 33 deletions
diff --git a/db-functions-svn b/db-functions-svn index e7c0830..49f2d07 100644 --- a/db-functions-svn +++ b/db-functions-svn @@ -34,12 +34,12 @@ _svn_checkout() { # move it to a different repo. vcs_move_preflight_check() { local repo_from=$1 - local pkgarch=$2 + local tarch=$2 local pkgbase=$3 _svn_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 ]] } # usage: vcs_move_start repo_from repo_to pkgbase @@ -56,42 +56,50 @@ vcs_move_start() { svn_move_tag_list="" } -# usage: vcs_move_arch pkgarch +# usage: vcs_move_arch tarch # # Add an architecture to a VCS transaction started by vcs_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 -# vcs_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 vcs_move_preflight_check. vcs_move_arch() { - local pkgarch=$1 + local tarch=$1 local repo_from=$svn_move_repo_from local repo_to=$svn_move_repo_to local pkgbase=$svn_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}" - svn_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}" + svn_move_tag_list+=", $pkgarch" } # usage: vcs_move_finish @@ -28,10 +28,10 @@ done for pkgbase in "${args[@]:2}"; do found=false for tarch in "${ARCHES[@]}"; do - while read -r pkgarch pkgfile; do + while read -r pkgfile; do - if ! vcs_move_preflight_check "$repo_from" "$pkgarch" "$pkgbase"; then - die "%s not found in %s-%s" "$pkgbase" "$repo_from" "$pkgarch" + if ! vcs_move_preflight_check "$repo_from" "$tarch" "$pkgbase"; then + die "%s not found in %s-%s" "$pkgbase" "$repo_from" "$tarch" fi # getpkgfile will `exit` for us if it fails; @@ -39,7 +39,7 @@ for pkgbase in "${args[@]:2}"; do getpkgfile "${ftppath_from}/${tarch}/${pkgfile}" >/dev/null found=true - done < <(arch_expac_pkgbase "$repo_from" "$tarch" '%a %f' "$pkgbase") + done < <(arch_expac_pkgbase "$repo_from" "$tarch" '%f' "$pkgbase") done [[ $found = true ]] || die "%s not found in %s" "$pkgbase" "$repo_from" done @@ -53,9 +53,8 @@ done for pkgbase in "${args[@]:2}"; do vcs_move_start "$repo_from" "$repo_to" "$pkgbase" for tarch in "${ARCHES[@]}"; do - while read -r pkgname pkgver pkgarch pkgfile; do - vcs_move_arch "$pkgarch" - + vcs_move_arch "$tarch" + while read -r pkgname pkgver pkgfile; do declare -n add_pkgs="add_pkgs_${tarch}" declare -n remove_pkgs="remove_pkgs_${tarch}" @@ -65,7 +64,7 @@ for pkgbase in "${args[@]:2}"; do fi add_pkgs+=("${FTP_BASE}/${PKGPOOL}/${pkgfile}") remove_pkgs+=("${pkgname}") - done < <(arch_expac_pkgbase "$repo_from" "$tarch" '%n %v %a %f' "$pkgbase") + done < <(arch_expac_pkgbase "$repo_from" "$tarch" '%n %v %f' "$pkgbase") done vcs_move_finish done |