Batch them up using a bash array and then pass them all to a single
invocation of rsync.

Signed-off-by: Dan McGee <[email protected]>
---
Demo of what this should be doing:

$ touch /tmp/foobar /tmp/foobaz '/tmp/file with spaces'
$ uploads+=('/tmp/foobar')
$ uploads+=('/tmp/foobaz')
$ uploads+=('/tmp/file with spaces')
$ echo ${uploads[@]}
/tmp/foobar /tmp/foobaz /tmp/file with spaces
$ rsync -e ssh -p -c -h -L --progress "${uploads[@]}" 
gerolde.archlinux.org:staging/extra/
file with spaces
          0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=2/3)
foobar
          0 100%    0.00kB/s    0:00:00 (xfer#2, to-check=1/3)
foobaz
          0 100%    0.00kB/s    0:00:00 (xfer#3, to-check=0/3)

sent 224 bytes  received 69 bytes  195.33 bytes/sec
total size is 0  speedup is 0.00

 commitpkg |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/commitpkg b/commitpkg
index 413161c..ed2254c 100755
--- a/commitpkg
+++ b/commitpkg
@@ -112,6 +112,8 @@ else
 fi
 echo 'done'
 
+declare -a uploads
+
 for _arch in ${arch[@]}; do
        for _pkgname in ${pkgname[@]}; do
                fullver=$(get_full_version ${epoch:-0} $pkgver $pkgrel)
@@ -126,13 +128,16 @@ for _arch in ${arch[@]}; do
                        echo "skipping ${_arch}"
                        continue 2
                fi
-
-               echo -n 'uploading '
-               rsync $rsyncopts "${pkgfile}" 
"$server:staging/$repo/${pkgfile##*/}" || abort
+               uploads+=("$pkgfile")
        done
        archrelease $repo-${_arch} || abort
 done
 
+if [[ ${#uploads[*]} -gt 0 ]]; then
+       echo 'uploading all package files'
+       rsync $rsyncopts "${uploads[@]}" "$server:staging/$repo/" || abort
+fi
+
 if [ "${arch[*]}" == 'any' ]; then
        if [ -d ../repos/$repo-i686 -a -d ../repos/$repo-x86_64 ]; then
                pushd ../repos/ >/dev/null
-- 
1.7.4.2

Reply via email to