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
}
# 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
if [ -r "/etc/makepkg.conf" ]; then
@ -61,39 +50,12 @@ else
fi
# see if any limit options were passed, we'll send them to SCP
unset scpopts
unset rsyncopts
if [ "$1" = "-l" ]; then
scpopts="-l $2"
rsyncopts="--bwlimit=$2"
shift 2
fi
for _arch in ${arch[@]}; do
echo "===> Uploading to staging/$repo for arch=${_arch}"
for _pkgname in ${pkgname[@]}; do
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
if [ ! -f $pkgfile -a -f "$PKGDEST/$pkgfile" ]; then
pkgfile="$PKGDEST/$pkgfile"
elif [ ! -f $pkgfile ]; then
echo "File $pkgfile doesn't exist"
# skip to next architecture
continue 2
fi
# combine what we know into a variable
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
if [ -n "$1" ]; then
svn commit -m "upgpkg: $pkgbase $pkgver-$pkgrel
$1" >/dev/null || abort
@ -105,6 +67,24 @@ for _arch in ${arch[@]}; do
echo "===> Commited"
fi
for _arch in ${arch[@]}; do
echo "===> Uploading to staging/$repo for arch=${_arch}"
pkgfiles=''
for _pkgname in ${pkgname[@]}; do
pkgfile=$_pkgname-$pkgver-$pkgrel-${_arch}$PKGEXT
if [ ! -f $pkgfile -a -f "$PKGDEST/$pkgfile" ]; then
pkgfile="$PKGDEST/$pkgfile"
elif [ ! -f $pkgfile ]; then
echo "File $pkgfile doesn't exist"
# skip to next architecture
continue 2
fi
pkgfiles="${pkgfiles} ${pkgfile}"
done
rsync -c -h --progress $rsyncopts "${pkgfiles}" -e ssh $server:staging/$repo || abort "error during upload"
archrelease $repo-${_arch} || abort
done