From 0811dea8b9c695ed9e67b22d389142956bd1cdd8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 17:40:26 -0500 Subject: Fix quoting on arrays. --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index 010d941..69f24ac 100755 --- a/db-move +++ b/db-move @@ -66,7 +66,7 @@ for pkgbase in ${args[@]:2}; do if [ -f "${svnrepo_from}/PKGBUILD" ]; then if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi -- cgit v1.2.3-2-g168b From b6e8ebd66d22abf5439485985a7851e768c71e8a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:04:43 -0500 Subject: Be very careful about using $0. --- db-move | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index 69f24ac..a3f1532 100755 --- a/db-move +++ b/db-move @@ -1,10 +1,10 @@ #!/bin/bash -. "$(dirname $0)/db-functions" -. "$(dirname $0)/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" +. "$(dirname "$(readlink -e "$0")")/config" if [ $# -lt 3 ]; then - msg "usage: $(basename $0) ..." + msg "usage: ${0##*/} ..." exit 1 fi -- cgit v1.2.3-2-g168b From 62142bcbac5f457b2172c7311741f90fedf0c776 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 15:20:16 -0500 Subject: fix comments, indentation --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index a3f1532..41ef4c1 100755 --- a/db-move +++ b/db-move @@ -24,7 +24,7 @@ for pkgarch in ${ARCHES[@]}; do repo_lock ${repo_from} ${pkgarch} || exit 1 done -# No idea why we loop twice... -- fauno +# First loop is to check that all necessary files exist for pkgbase in ${args[@]:2}; do for pkgarch in ${ARCHES[@]} 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" -- cgit v1.2.3-2-g168b From eefb787983d2608511214bcd682f3d8271bac60c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 16:44:51 -0500 Subject: Normalize to load config then local_config then db-functions --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index 41ef4c1..eed48eb 100755 --- a/db-move +++ b/db-move @@ -1,7 +1,7 @@ #!/bin/bash -. "$(dirname "$(readlink -e "$0")")/db-functions" . "$(dirname "$(readlink -e "$0")")/config" +. "$(dirname "$(readlink -e "$0")")/db-functions" if [ $# -lt 3 ]; then msg "usage: ${0##*/} ..." -- cgit v1.2.3-2-g168b From 9d9116bd23720cf6c5b27aa39e5cc4c71de1fb26 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 21:27:07 -0500 Subject: Fix some array quoting. --- db-move | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'db-move') diff --git a/db-move b/db-move index eed48eb..a6abb8f 100755 --- a/db-move +++ b/db-move @@ -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 # First loop is to check that all necessary files exist -for pkgbase in ${args[@]:2}; do - for pkgarch in ${ARCHES[@]} 'any'; do +for pkgbase in "${args[@]:2}"; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" if [ -r "${svnrepo_from}/PKGBUILD" ]; then pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) @@ -40,13 +40,13 @@ for pkgbase in ${args[@]:2}; do fi if [ "${pkgarch}" == 'any' ]; then - tarches=(${ARCHES[@]}) + tarches=("${ARCHES[@]}") else tarches=("${pkgarch}") fi - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT} >/dev/null done done @@ -60,8 +60,8 @@ msg "Moving packages from [${repo_from}] to [${repo_to}]..." declare -A add_pkgs declare -A remove_pkgs -for pkgbase in ${args[@]:2}; do - for pkgarch in ${ARCHES[@]} 'any'; do +for pkgbase in "${args[@]:2}"; do + for pkgarch in "${ARCHES[@]}" 'any'; do svnrepo_from="${SVNREPO}/${repo_from}/${pkgbase}" if [ -f "${svnrepo_from}/PKGBUILD" ]; then @@ -70,12 +70,12 @@ for pkgbase in ${args[@]:2}; do else tarches=("${pkgarch}") fi - msg2 "${pkgbase} ($(echo ${tarches[@]}))" + msg2 "${pkgbase} (${tarches[*]})" pkgnames=($(. "${svnrepo_from}/PKGBUILD"; echo ${pkgname[@]})) pkgver=$(. "${svnrepo_from}/PKGBUILD"; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) - for pkgname in ${pkgnames[@]}; do - for tarch in ${tarches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) pkgfile=$(basename "${pkgpath}") @@ -96,14 +96,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 -- cgit v1.2.3-2-g168b From d3afe9bb766bbdfaab1474d21fd5e28f0a356039 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 8 Jan 2014 20:49:48 -0500 Subject: Avoid using $(basename $var) , use ${var##*/} instead --- db-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'db-move') diff --git a/db-move b/db-move index a6abb8f..f1c3dea 100755 --- a/db-move +++ b/db-move @@ -77,7 +77,7 @@ for pkgbase in "${args[@]:2}"; do for pkgname in "${pkgnames[@]}"; do for tarch in "${tarches[@]}"; do pkgpath=$(getpkgfile "${ftppath_from}/${tarch}/"${pkgname}-${pkgver}-${pkgarch}${PKGEXT}) - pkgfile=$(basename "${pkgpath}") + pkgfile="${pkgpath##*/}" # copy package to pool if needed # TODO: can be removed once every package has been moved to the package pool -- cgit v1.2.3-2-g168b