diff options
author | Eli Schwartz <eschwartz@archlinux.org> | 2018-05-23 10:53:45 -0400 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2018-06-27 00:20:01 -0400 |
commit | 01712670c40df875c6ac6e1d5a88063fab0b020f (patch) | |
tree | dfca2cd8426df4d754462838ffe4682ed905475a | |
parent | 05dd9be0db06d7f7cea0eff9f9f6f1993eb6d463 (diff) |
db-move: Don't store filepaths as a string with whitespace splitting
Use arrays via nameref, since makepkg does not support multidimensional
arrays, and assigning to/retrieving from an array variable with an
unknown name requires this.
Requires bash 4.3, requires that architectures never contain chars that
are invalid in a variable name -- which makepkg explicitly requires in
order to support architecture-dependent sources/dependencies, and also
incorporates into linting checks which forbid anything but [[:alnum:]_]
so that's all good.
-rwxr-xr-x | db-move | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -60,8 +60,10 @@ done msg "Moving packages from [%s] to [%s]..." "$repo_from" "$repo_to" -declare -A add_pkgs -declare -A remove_pkgs +for arch in "${ARCHES[@]}"; do + declare -a add_pkgs_$arch + declare -a remove_pkgs_$arch +done for pkgbase in "${args[@]:2}"; do tag_list="" for pkgarch in "${ARCHES[@]}" 'any'; do @@ -95,6 +97,8 @@ for pkgbase in "${args[@]:2}"; do for pkgname in "${pkgnames[@]}"; do for tarch in "${tarches[@]}"; do + declare -n add_pkgs="add_pkgs_${tarch}" + declare -n remove_pkgs="remove_pkgs_${tarch}" pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/${pkgname}-${pkgver}-${pkgarch}"${PKGEXTS}) pkgfile="${pkgpath##*/}" @@ -102,8 +106,8 @@ for pkgbase in "${args[@]:2}"; do 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} " + add_pkgs+=("${FTP_BASE}/${PKGPOOL}/${pkgfile}") + remove_pkgs+=("${pkgname}") done done fi @@ -113,9 +117,11 @@ for pkgbase in "${args[@]:2}"; do done for tarch in "${ARCHES[@]}"; do - if [[ -n ${add_pkgs[${tarch}]} ]]; then - arch_repo_modify add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} - arch_repo_modify remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} + declare -n add_pkgs="add_pkgs_${tarch}" + declare -n remove_pkgs="remove_pkgs_${tarch}" + if [[ -n ${add_pkgs[@]} ]]; then + arch_repo_modify add "${repo_to}" "${tarch}" "${add_pkgs[@]}" + arch_repo_modify remove "${repo_from}" "${tarch}" "${remove_pkgs[@]}" fi done |