| 1 |
#!/bin/bash |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
# |
| 4 |
# Copyright © 2009 Germán Póo-Caamaño <gpoo@gnome.org> |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License as published by |
| 8 |
# the Free Software Foundation; either version 2 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# This program is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU Library General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU General Public License |
| 17 |
# along with this program; if not, write to the Free Software |
| 18 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
| 19 |
|
| 20 |
|
| 21 |
BASE=gnome.git/mirror |
| 22 |
REPO=$(dirname $BASE)/repositories.txt |
| 23 |
# Get the minor version (Y) from 'git version x.Y.z' |
| 24 |
GIT_VERSION=$(git version | cut -f2 -d.) |
| 25 |
|
| 26 |
|
| 27 |
if [ ! -d $BASE ]; then |
| 28 |
mkdir -p $BASE |
| 29 |
fi |
| 30 |
|
| 31 |
wget -O $REPO http://git.gnome.org/repositories.txt |
| 32 |
|
| 33 |
for i in $(cat $REPO) |
| 34 |
do |
| 35 |
if [ -d $BASE/$i ]; then |
| 36 |
echo "Fetching $i" |
| 37 |
(cd $BASE/$i && git fetch) |
| 38 |
else |
| 39 |
echo "Getting $i" |
| 40 |
URL="git://git.gnome.org/$i" |
| 41 |
|
| 42 |
# git >= 1.6 supports the --mirror shorthand |
| 43 |
if [ $GIT_VERSION -gt 5 ]; then |
| 44 |
git clone --mirror $URL $BASE/$i |
| 45 |
else |
| 46 |
# Workaround for git < 1.6 |
| 47 |
git clone --bare $URL $BASE/$i |
| 48 |
(cd $BASE/$i && git remote add --mirror origin $URL) |
| 49 |
fi |
| 50 |
fi |
| 51 |
done |