3 MIRROR_GIT="git://git.planet-lab.org"
5 LOCAL_MIRROR_DIR="/git-mirror"
11 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
16 echo "[ERROR] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
23 COMMAND="$1 &> /dev/null"
30 pushd ${REPO} > /dev/null
37 NAME=$(echo ${arg} | sed 's/\/$//')
39 REPO_DIR=${LOCAL_MIRROR_DIR}/${NAME}
40 MIRROR_REPO=${MIRROR_GIT}/${GIT_NAME}
41 MASTER_REPO=${MASTER_GIT}/${GIT_NAME}
45 msg "pulling from ${REPO_NAME}"
46 run "git fetch origin --tags" ${REPO_DIR}
47 run "git fetch origin" ${REPO_DIR}
48 run "git merge --ff origin/master" ${REPO_DIR}
51 error "Can not fetch from ${MASTER_REPO}"
54 msg "mirroring in ${REPO_NAME} for the first time"
55 run "git clone ${MIRROR_REPO}" ${LOCAL_MIRROR_DIR}
56 run "git remote add local_master ${MASTER_REPO}" ${REPO_DIR}
59 msg "pushing ${REPO_NAME} to local master"
60 run "git fetch local_master --tags" ${REPO_DIR}
61 run "git fetch local_master" ${REPO_DIR}
62 run "git merge --ff local_master/master" ${REPO_DIR}
65 error "Can not fetch from ${MIRROR_REPO}"
68 run "git push local_master" ${REPO_DIR}
69 run "git push --tags local_master" ${REPO_DIR}
74 while getopts ":hq" opt
82 echo "USAGE: $0 [-q] REPONAME*"
86 echo "Invalid option: -$OPTARG" >&2