How to mirror DragonFly with Git
This guide will outline the basics of running a git mirror of DragonFlyBSD. You should be somewhat familiar with git.
Choose a directory
I tend to choose /srv/git, other typical places could include /usr/local/git, /home/git or /var/lib/git. The location isn't important, find a place that fits your preference or OS recommendations, but make sure you have a couple of GB free (as of 2009). It is a good idea to use a top-level git-folder, so you can mirror multiple DragonFly sub-projects in hierarchy. This is a pre-requisite for running the update-repo shell-script (more about that in a bit).
This is my configuration:
/srv/git /dragonfly.git /update-repo.git /df-webtool run supervise
As you can see df-webtool is not named with ".git"-extention, this is because the update-repo script mirrors /srv/git/*.git, and I do not want to mirror df-webtool, because it has no origin. The run and supervise files are special files that are created by daemon-tools. Daemon-tools (and many others like it), keeps the git-daemon running, and is not necessary for running a git mirror.
Clone the DragonFly source
After creating a git-user to run the git mirror (I use 'gitlog', which came with the git-package under Debian), login as this user, and perform a checkout. To find a suitable git-server to clone from ( $MASTER_GIT_SERVER ), look at the list of mirrors. This system should be a system user, and does not need to have a homedirectory or valid shell.
NOTE: You must use a version of git that supports clone --mirror.
# REPODIR=/srv/git # cd $REPODIR && git clone --mirror $MASTER_GIT_SERVER
Make sure this is done using the git-user.
Setup the update-repo script
# cd $REPODIR && git clone git://leaf.dragonflybsd.org/~corecode/update-repo.git
You might want to use root, or a different user, so the git-user doesn't have permission to modify the update-repo script.
As the user running the git daemon, run:
# repodir=/srv/git /srv/git/update-repo.git/update-git.sh
If this fails, you need to diagnose the problem and fix it before proceeding. Feel free to ask the community for help or advice.
Add entry to crontab
Run every 20 minutes:
0,20,40 * * * * repodir=/srv/git /srv/git/update-repo.git/update-git.sh
Make sure you forward the mails from the git-user, to detect potential problems. This is usually done in /etc/aliases.
Start the git-daemon
A startup script should be provided via package-manager, or you can use a service-tool like daemon-tools (or others). This is an example run-file:
#!/bin/sh exec setuidgid gitlog git-daemon --export-all --verbose --base-path=/srv/git /srv/git
Notes for Linux users
The update-repo script uses lockf(1), I've created a version that supports Linux too (uses flock(1)): git://koan.bondconsult.net/update-repo.git.
0,20,40 * * * * repodir=/srv/git locktype=flock /srv/git/update-repo.git/update-git.sh