Contents
- Introduction
- Resources
- Installing git On The Voyage SDK VM
- Building cgit On The Voyage SDK VM
- Installing cgit On The Soekris 4501
Introduction
In this tutorial we’ll be building cgit – a web frontend for git repositories. As usual, the build will happen on the Voyage SDK VM, and from there it will be installed to the Soekris 4501 server. The Soekris 4501 is a 486 class machine with 64 MB of RAM and boots from a CF card. It’s an example of a fractional horsepower server.
Although you don’t strictly need git already installed on your build machine, it helps. The reason is that cgit needs the git source, and of course you need to have git installed to retrieve it.
We’ll walk through installing and configuring git on the Voyage SDK VM. After that, we’ll download and build cgit on the Voyage SDK VM, and then install it as a Debian package on the Soekris 4501.
In another tutorial, we’ll install git on the Soekris 4501 so that it can be our own remote git server.
Resources
- The main cgit website.
- The cgit Installation and Build intructions.
Installing git On The Voyage SDK Machine
OK, this one is pretty easy – it’s just a matter of:
|
1 |
apt-get install git |
For now, that’s all we need to do. In another article we’ll discuss setting up the Soekris 4501 as a git host and then we’ll set up the git client.
Building cgit On The Voyage SDK Machine
The cgit Installation and Build instructions are the best reference for what we’re going to do next, so there’s no point duplicating them here, but I’ll give the basic recipe for retrieving the source tree to get us started:
|
1 2 3 4 |
mkdir -p /home/projects cd /home/projects git clone git://hjemli.net/pub/git/cgit cd cgit |
This results in a git directory under projects that is a complete repository of the current cgit development. From there, it’s a simple matter of following the instructions on the cgit site.
When building cgit from source, there are two choices. Either initialize the git module in the cgit repository, or use make get-git to retrieve the latest compatible git source. I prefer the second option because it’s a bit faster.
To retrieve the git source, you’ll need to install the curl package on the Voyage SDK machine, and building cgit requires development versions of some libraries so that we can use the C header files. Here’s the recipe to get the rest of cgit‘s dependencies in place before building:
|
1 2 3 4 5 6 7 8 9 10 11 |
apt-get install curl apt-get install libssl-dev # And now we can build... # make get-git make # Minimize the size of the executable... # strip cgit |
Once that’s done we could install cgit right away, but the destination is actually the Soekris 4501. And unfortunately there’s no easy way to make a Debian package for cgit. But we can easily deal with the few files that cgit actually installs by looking in the Makefile to figure out what the install target does. Here’s the original contents:
|
1 2 3 4 5 6 7 8 |
install: all $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH) $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH) $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png $(INSTALL) -m 0755 -d $(DESTDIR)$(filterdir) $(INSTALL) -m 0755 filters/* $(DESTDIR)$(filterdir) |
Not too bad. It creates three directories, then copies three files and a directory to them.
What we’ll do is copy these files and directories to – you guessed it – an nfs share along with a little shell script to install them in the right places when the script runs on the Soekris 4501. This part assumes you already have an nfs share at /home/nfs/Soekris4501/packages. Just copy the script and paste it into your shell to run it.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# ------------------------------------------------------------------ # Copy the cgit build files to a temporary install directory on # an nfs share, then create the install script that runs on the # Soekris 4501 to actually install cgit. # CGIT_BUILD=/home/projects/cgit CGIT_INSTALL=/home/nfs/Soekris4501/packages/cgit CGIT_DEST=/var/www/htdocs/cgit cd $CGIT_BUILD mkdir -p $CGIT_INSTALL cp cgit $CGIT_INSTALL cp cgit.css $CGIT_INSTALL cp cgit.png $CGIT_INSTALL cp -R filters $CGIT_INSTALL #cat > $CGIT_INSTALL/install.sh cat > $CGIT_INSTALL/install.sh <<EOM install -m 0755 -d $CGIT_DEST install -m 0755 cgit $CGIT_DEST/cgit.cgi install -m 0755 -d $CGIT_DEST/filters install -m 0755 filters/* $CGIT_DEST/filters install -m 0644 cgit.css $CGIT_DEST/cgit.css install -m 0644 cgit.png $CGIT_DEST/cgit.png EOM chmod +x $CGIT_INSTALL/install.sh |
OK, that’s the hard part – next we install and configure cgit and Hiawatha on the Soekris 4501.
Installing cgit On The Soekris4501
From this point forward, we’ll be working as root on the Soekris 4501 – remember to remountrw or you won’t be able to save your changes. The rest of the tutorial assumes that you’ve got an nfs share mounted on the Soekris 4501 at /var/www – that’s the standard place for a Debian web server to keep its files.
In my case, that’s a DLink DNS232 – not the fastest NAS around, but it’s cheap and reliable.
Navigate to the nfs share at /home/nfs/Soekris4501/packages/cgit that we have set up in other tutorials on the Voyage SDK machine. You should see the cgit install files plus the install.sh that was created when we ran the script at the end of the previous section.
|
1 2 |
cd /home/nfs/Soekris4501/packages/cgit ./install.sh |
After a bit of whirring and clicking on the NAS the files should all be in their correct places. Now all we need to do is install the Hiawatha and cgit config files and we’re ready to roll.
Here is a script to write out my current Hiawatha config file (comments stripped out). It will create a backup before overwriting your existing file.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# ------------------------------------------------------------------------ # Create the Hiawatha main configuration file and restart Hiawatha # if [ -f /etc/hiawatha/hiawatha.conf ] then EXT=`date +%y%m%d-%H%M%S` cp -p /etc/hiawatha/hiawatha.conf /etc/hiawatha/hiawatha.conf.${EXT} fi cat > /etc/hiawatha/hiawatha.conf <<EOM # ------------------------------------------------------------------------ # Hiawatha main configuration file # ConnectionsTotal = 150 ConnectionsPerIP = 10 Binding { Port = 80 } CGIextension = cgi Hostname = 127.0.0.1 WebsiteRoot = /var/www/htdocs StartFile = index.html UseToolkit = cgit ExecuteCGI = yes # ------------------------------------------------------------------------ # Settings for cgit Support # UrlToolkit { ToolkitID = cgit RequestURI isfile Return Match ^/cgit/cgit.png Return Match ^/cgit/cgit.css Return Match ^/cgit/([^\?]*)\?*(.*) Rewrite /cgit/cgit.cgi?url=\$1&\$2 } EOM /etc/init.d/hiawatha restart |
Here is a script to write out my current cgitrc config file (comments stripped out). It will create a backup before overwriting your existing file.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# ------------------------------------------------------------------------ # Create the cgitrc configuration file # if [ -f /etc/cgitrc ] then EXT=`date +%y%m%d-%H%M%S` cp -p /etc/cgitrc /etc/cgitrc.${EXT} fi cat > /etc/cgitrc <<EOM virtual-root=/cgit/ scan-path=/var/www/git/repos css=/cgit/cgit.css logo=/cgit/cgit.png snapshots=tar.gz tar.bz2 zip remove-suffix=1 enable-index-links=1 EOM |
That’s it – you should be able to point your browser at the following URL and at least see the cgit logo and a “No repositories found” message. Your IP address might be different:
192.168..xx.yy/cgit
Next, we’ll tackle installing and configuring git repositories on the Soekris 4501, as well as dealing with authentication.