]> git.donarmstrong.com Git - wannabuild.git/blob - bin/sync.sh
Auto-committed schema changes.
[wannabuild.git] / bin / sync.sh
1 #!/bin/bash
2
3 set -eE
4 LANG=C
5
6 if [ -z "$1" ]
7 then
8         echo "Usage: $0 archive"
9         echo "e.g. $0 debian"
10         exit 1
11 fi
12
13 # START OF OPTIONS ######################################################
14
15 TARGET_BASE=/org/wanna-build/tmp/archive
16 TARGET="$TARGET_BASE/$1"
17
18 PASSWORD_BASE=/org/wanna-build/etc
19 PASSWORD_FILE="$PASSWORD_BASE/$1.rsync-password"
20
21 RSYNC_OPTIONS="--delete --delete-excluded -av"
22
23 MIRROR_EXCLUDES="--exclude=**/*.changes --exclude=**/installer-* --exclude=**/Packages.diff --exclude=**/Sources.diff --exclude=ChangeLog --exclude=**/Contents-* --exclude=**/Translation-* --exclude=**/*.bz2 --exclude=Packages --exclude=Sources --exclude=**/*.new" # the latter two because we only accept gziped files
24 MIRROR_OPTIONS="$MIRROR_EXCLUDES $RSYNC_OPTIONS"
25
26 # END OF OPTIONS ########################################################
27
28 mkdir -p "$TARGET"
29
30 if [ ! "$2" = "nolock" ]
31 then
32         # Do locking to avoid destroying other's views on an archive.
33         LOCKFILE="$TARGET/lock"
34
35         cleanup() {
36                 rm -rf "$LOCKFILE"
37         }
38
39         if lockfile -! -r 10 $LOCKFILE
40         then
41                 echo "Sync failed: cannot lock $LOCKFILE, aborting."
42                 exit 1
43         fi
44         trap cleanup 0
45 fi
46
47 # Handle the syncing.
48 case $1 in
49 debian)
50         USER=cimarosa
51         BUILDD_QUEUE_OPTIONS="--include=Packages.gz --include=Sources.gz --include=**Release* --exclude=* $RSYNC_OPTIONS"
52         rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/dists/ "$TARGET/archive"
53         rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@ftp-master.debian.org::buildd-sid/ "$TARGET/buildd-sid"
54         rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@ftp-master.debian.org::buildd-experimental/ "$TARGET/buildd-experimental"
55         # Also sync the Maintainers and Uploaders files for consumption through the web interface.
56         rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/indices/Maintainers /srv/buildd.debian.org/etc/Maintainers
57         rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS $USER@ftp-master.debian.org::debian/indices/Uploaders /srv/buildd.debian.org/etc/Uploaders
58         ;;
59 debian-security)
60         chmod 0700 "$TARGET"
61         USER=cimarosa
62         BUILDD_QUEUE_OPTIONS="--include=Packages.gz --include=Sources.gz --include=**Release* --exclude=* $RSYNC_OPTIONS"
63         rsync $MIRROR_OPTIONS $USER@security-master.debian.org::debian-security/dists/ "$TARGET/archive"
64         rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-wheezy/ "$TARGET/buildd-wheezy"
65         rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-squeeze/ "$TARGET/buildd-squeeze"
66         rsync --password-file "$PASSWORD_BASE/$1-buildd.rsync-password" $BUILDD_QUEUE_OPTIONS $USER@security-master.debian.org::buildd-lenny/ "$TARGET/buildd-lenny"
67         ;;
68 debian-volatile)
69         rsync $MIRROR_OPTIONS volatile-master.debian.org::debian-volatile/dists/ "$TARGET/archive"
70         ;;
71 backports)
72         rsync --password-file "$PASSWORD_FILE" $MIRROR_OPTIONS wbadm@backports-master.debian.org::debian-backports/dists/ "$TARGET/archive"
73         ;;
74 debian-edu)
75         rsync $MIRROR_OPTIONS --exclude=woody/ ftp.skolelinux.no::skolelinux-dist/dists/ "$TARGET/archive"
76         ;;
77 *)
78         echo "Sync target $1 not supported, aborting."
79         exit 1
80         ;;
81 esac
82