chiark / gitweb /
0a6cc4c1ef461806d6390eac80ae3d355a493eaf
[dgit-junk.git] / copy-alioth-to-gideon
1 #!/bin/bash
2 set -ex
3
4 d=/srv/dgit.debian.org
5
6 ssh iwj@gideon.debian.org "
7         set -ex
8
9         d=$d"'
10
11         cd $d
12         mkdir -p transfer.tmp
13         cd transfer.tmp
14
15         rsync -rltHxp --delete iwj@git.debian.org:/git/dgit-repos/repos/. .
16
17         find \(         \( ! -type f ! -type d \) \
18                 -o      -perm +5002 -o \! -perm +2555 \
19                 -o      -type d \! -perm +2775 \
20                 -o      -path \*/hooks/\* ! -name \*.sample \
21                 \) -ls \
22                 >$d/transfer.bad
23         if [ -s $d/transfer.bad ]; then
24                 head $d/transfer.bad
25                 echo >&2 " BAD"
26                 exit 1
27         fi
28
29         (
30          cd $d/transfer.tmp
31          mv irker.git irker.arrgh
32          cp -a _template irker.git
33          cd irker.git
34          git fetch -p ../irker.arrgh "+refs/heads/dgit/*:refs/dgit/*"
35         )
36
37         set +x
38         for f in $d/transfer.tmp/*.git; do
39                 cp $d/repos/_template/description $f/description
40                 touch $f/git-daemon-export-ok
41                 (export GIT_DIR=$f
42                  master=`git for-each-ref "[r]efs/heads/master"`
43                  sid=`git for-each-ref "[r]efs/dgit/sid"`
44                  if [ "x$master" = x ] && [ "x$sid" != x ]; then
45                         git update-ref refs/heads/master refs/dgit/sid
46                  fi)
47                 (export GIT_DIR=$f
48                  git for-each-ref --format="%(refname)" | while read r; do
49                         case "$r" in
50                         refs/heads/master)      ;;
51                         refs/tags/debian/*)     ;;
52                         refs/dgit/*)            ;;
53                         *)
54                                 git update-ref -d "$r"
55                                 ;;
56                         esac
57                 done)
58         done
59
60         cat <<END >$d/transfer.run
61                 #!/bin/sh -ex
62                 cd $d/transfer.tmp
63                 rsync -rltHxp --delete *.git $d/repos/
64                 # _template
65                 echo done locally, copying...
66
67                 distrodir=$d/dispatch-dir/distro\=debian
68                 \$distrodir/mirror-hook \$distrodir all
69                 echo done all.
70 END
71         chmod +x $d/transfer.run
72 '
73
74 : "on gideon
75         sudo -u dgit bash
76         $d/transfer.run
77 "