diff options
Diffstat (limited to 'db-move')
-rwxr-xr-x | db-move | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -8,7 +8,7 @@ if [ $# -lt 3 ]; then exit 1 fi -args=(${@}) +args=("${@}") repo_from="${args[0]}" repo_to="${args[1]}" ftppath_from="${FTP_BASE}/${repo_from}/os/" @@ -19,14 +19,14 @@ if ! check_repo_permission $repo_to || ! check_repo_permission $repo_from; then fi # TODO: this might lock too much (architectures) -for pkgarch in ${ARCHES[@]}; do +for pkgarch in "${ARCHES[@]}"; do repo_lock ${repo_to} ${pkgarch} || exit 1 repo_lock ${repo_from} ${pkgarch} || exit 1 done -# check if packages to be moved exist in xbs and ftp dir -for pkgbase in ${args[@]:2}; do - for pkgarch in ${ARCHES[@]} 'any'; do +# First loop is to check that all necessary files exist +for pkgbase in "${args[@]:2}"; do + for pkgarch in "${ARCHES[@]}" 'any'; do xbsrepo_from="$(xbs releasepath ${pkgbase} ${repo_from} ${pkgarch})" if [ -r "${xbsrepo_from}/PKGBUILD" ]; then pkgnames=($(. "${xbsrepo_from}/PKGBUILD"; echo ${pkgname[@]})) @@ -34,19 +34,18 @@ for pkgbase in ${args[@]:2}; do die "Could not read pkgname" fi - if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi - for pkgname in ${pkgnames[@]}; do + for pkgname in "${pkgnames[@]}"; do pkgver=$(. "${xbsrepo_from}/PKGBUILD"; get_full_version ${pkgname}) if [ -z "${pkgver}" ]; then die "Could not read pkgver" fi - for tarch in ${tarches[@]}; do + for tarch in "${tarches[@]}"; do getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null done done @@ -60,11 +59,11 @@ msg "Moving packages from [${repo_from}] to [${repo_to}]..." declare -A add_pkgs declare -A remove_pkgs -for pkgbase in ${args[@]:2}; do +for pkgbase in "${args[@]:2}"; do # move the package in xbs arches=($(xbs move ${repo_from} ${repo_to} ${pkgbase})) # move the package in ftp - for pkgarch in ${arches[@]}; do + for pkgarch in "${arches[@]}"; do dir_to="$(xbs releasepath $pkgbase $repo_to $pkgarch)" if true; then # to add in indent level to make merging easier if [ "${pkgarch}" == 'any' ]; then @@ -74,9 +73,9 @@ for pkgbase in ${args[@]:2}; do fi pkgnames=($(. "${dir_to}/PKGBUILD"; echo ${pkgname[@]})) - for pkgname in ${pkgnames[@]}; do + for pkgname in "${pkgnames[@]}"; do pkgver=$(. "${dir_to}/PKGBUILD"; get_full_version ${pkgname}) - for tarch in ${tarches[@]}; do + for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) pkgfile="${pkgpath##*/}" @@ -92,14 +91,14 @@ for pkgbase in ${args[@]:2}; do done done -for tarch in ${ARCHES[@]}; do +for tarch in "${ARCHES[@]}"; do if [ -n "${add_pkgs[${tarch}]}" ]; then arch_repo_add "${repo_to}" "${tarch}" ${add_pkgs[${tarch}]} arch_repo_remove "${repo_from}" "${tarch}" ${remove_pkgs[${tarch}]} fi done -for pkgarch in ${ARCHES[@]}; do +for pkgarch in "${ARCHES[@]}"; do repo_unlock ${repo_from} ${pkgarch} repo_unlock ${repo_to} ${pkgarch} done |