From 6ed09bc542cd09e984b1da6b5b7a9cd90bdc23e8 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Thu, 9 Sep 2010 18:05:23 +0000 Subject: [PATCH] Add sync.sh file. --- bin/sync.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 bin/sync.sh diff --git a/bin/sync.sh b/bin/sync.sh new file mode 100755 index 0000000..4f0d4e6 --- /dev/null +++ b/bin/sync.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +set -eE +LANG=C + +if [ -z "$1" ] +then + echo "Usage: $0 archive" + echo "e.g. $0 debian" + exit 1 +fi + +# START OF OPTIONS ###################################################### + +TARGET_BASE=/org/wanna-build/tmp/archive +TARGET="$TARGET_BASE/$1" + +PASSWORD_BASE=/org/wanna-build/etc +PASSWORD_FILE="$PASSWORD_BASE/$1.rsync-password" + +RSYNC_OPTIONS="--delete --delete-excluded -av" + +MIRROR_EXCLUDES="--exclude=**/*.changes --exclude=**/installer-* --exclude=**/Packages.diff --exclude=**/Sources.diff --exclude=ChangeLog --exclude=**/Contents-* --exclude=**/Translation-* --exclude=**/*.bz2 --exclude=Packages --exclude=Sources" # the latter two because we only accept gziped files +MIRROR_OPTIONS="$MIRROR_EXCLUDES $RSYNC_OPTIONS" + +# END OF OPTIONS ######################################################## + +mkdir -p "$TARGET" + +if [ ! "$2" = "nolock" ] +then + # Do locking to avoid destroying other's views on an archive. + LOCKFILE="$TARGET/lock" + + cleanup() { + rm -rf "$LOCKFILE" + } + + if lockfile -! -r 10 $LOCKFILE + then + echo "Sync failed: cannot lock $LOCKFILE, aborting." + exit 1 + fi + trap cleanup 0 +fi + +# Handle the syncing. +case $1 in +debian) + USER=cimarosa + BUILDD_QUEUE_OPTIONS="--include=Packages.gz --include=Sources.gz --include=**Release* --exclude=* $RSYNC_OPTIONS" + rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/dists/ "$TARGET/archive" + rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@ftp-master.debian.org::buildd-unstable/ "$TARGET/buildd-unstable" + rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@ftp-master.debian.org::buildd-experimental/ "$TARGET/buildd-experimental" + # Also sync the Maintainers and Uploaders files for consumption through the web interface. + rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/indices/Maintainers /srv/buildd.debian.org/etc/Maintainers + rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/indices/Uploaders /srv/buildd.debian.org/etc/Uploaders + ;; +debian-security) + chmod 0700 "$TARGET" + USER=cimarosa + BUILDD_QUEUE_OPTIONS="--include=Packages.gz --include=Sources.gz --include=**Release* --exclude=* $RSYNC_OPTIONS" + rsync $MIRROR_OPTIONS $USER@security-master.debian.org::debian-security/dists/ "$TARGET/archive" + rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-squeeze/ "$TARGET/buildd-squeeze" + rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-lenny/ "$TARGET/buildd-lenny" + rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-etch/ "$TARGET/buildd-etch" + [ -h "$TARGET/buildd-testing" ] || ln -sf buildd-squeeze "$TARGET/buildd-testing" + [ -h "$TARGET/buildd-stable" ] || ln -sf buildd-lenny "$TARGET/buildd-stable" + [ -h "$TARGET/buildd-oldstable" ] || ln -sf buildd-etch "$TARGET/buildd-oldstable" + ;; +debian-volatile) + rsync $MIRROR_OPTIONS volatile-master.debian.org::debian-volatile/dists/ "$TARGET/archive" + ;; +backports) + rsync $MIRROR_OPTIONS backports.org::backports.org/dists/ "$TARGET/archive" + ;; +debian-edu) + rsync $MIRROR_OPTIONS --exclude=woody/ ftp.skolelinux.no::skolelinux-dist/dists/ "$TARGET/archive" + ;; +*) + echo "Sync target $1 not supported, aborting." + exit 1 + ;; +esac + -- 2.39.2