simplify and optimize upload process

Use rsync instead of scp to be able to continue uploads and get upload
verification for free.

We also try to commit to svn trunk first to avoid useless uploads (FS#18088).
This commit is contained in:
Pierre Schmitz 2010-02-11 13:53:30 +01:00
parent 0e43db65b2
commit 106a0cddfe
1 changed files with 16 additions and 36 deletions

View File

@ -5,17 +5,6 @@ abort() {
exit 1 exit 1
} }
# Verify that a remote file exists and is identical to a local one
# Usage: package_verify <local path> <remote host> <remote path>
package_verify() {
local remote_checksum=$(ssh $2 openssl sha1 "'$3'" 2>/dev/null |
grep -o '[0-9a-f]\{40\}$')
local local_checksum=$(openssl sha1 "$1" | grep -o '[0-9a-f]\{40\}$')
if [ -n "$remote_checksum" -a "$remote_checksum" == "$local_checksum" ]; then
return 0
fi
return 1
}
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
if [ -r "/etc/makepkg.conf" ]; then if [ -r "/etc/makepkg.conf" ]; then
@ -61,14 +50,26 @@ else
fi fi
# see if any limit options were passed, we'll send them to SCP # see if any limit options were passed, we'll send them to SCP
unset scpopts unset rsyncopts
if [ "$1" = "-l" ]; then if [ "$1" = "-l" ]; then
scpopts="-l $2" rsyncopts="--bwlimit=$2"
shift 2 shift 2
fi fi
if [ -n "$1" ]; then
svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel
$1" >/dev/null || abort
echo "===> Commited with message:
upgpkg: $pkgbase $pkgver-$pkgrel
$1"
else
svn commit || abort
echo "===> Commited"
fi
for _arch in ${arch[@]}; do for _arch in ${arch[@]}; do
echo "===> Uploading to staging/$repo for arch=${_arch}" echo "===> Uploading to staging/$repo for arch=${_arch}"
pkgfiles=''
for _pkgname in ${pkgname[@]}; do for _pkgname in ${pkgname[@]}; do
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
@ -80,30 +81,9 @@ for _arch in ${arch[@]}; do
continue 2 continue 2
fi fi
# combine what we know into a variable pkgfiles="${pkgfiles} ${pkgfile}"
uploadto=staging/$repo/$(basename "$pkgfile")
# don't re-upload the same package (useful for -any sub packages)
if ! package_verify "$pkgfile" $server "$uploadto"; then
scp $scpopts "$pkgfile" $server:"$uploadto" || abort
fi
if ! package_verify "$pkgfile" $server "$uploadto"; then
abort "File got corrupted during upload, cancelled."
else
echo "File integrity okay."
fi
echo "===> Uploaded $pkgfile"
done done
rsync -c -h --progress $rsyncopts "${pkgfiles}" -e ssh $server:staging/$repo || abort "error during upload"
if [ -n "$1" ]; then
svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel
$1" >/dev/null || abort
echo "===> Commited with message:
upgpkg: $pkgbase $pkgver-$pkgrel
$1"
else
svn commit || abort
echo "===> Commited"
fi
archrelease $repo-${_arch} || abort archrelease $repo-${_arch} || abort
done done