Setting up a bazaar server
24 February 2008
So last year I wrote a little tutorial about using bazaar for my own personal projects. Please read that if you have no idea what I am talking about.
This weekend I started working on a project with a small group of friends. Therefore we decided to create a bzr server so we can all track the code that we are writing together.
We could use the free Launchpad service, but some among the group feel that we are not ready to publically share the fledgling project with the world yet.
I will try to remember what we did and tell you about it; however, I am by no means a bzr expert so feel free to point out improvements in the comments section below.
I am assuming that the bzr server will be running on some kind of Linux or BSD/Mac OS X; you will need to make some minor modifications on Windows. This has been tested on only Gentoo, Debian and Ubuntu Linux.
The first thing of course is that one needs to have bzr installed. Bzr is available from its homepage or via your friendly neighbourhood package manager. It is again important to note that if your package manager is offering you both 'bzr' and 'baz' or 'bazaar', it is the former (bzr) you want.
To clear up the confusion, I'll quickly explain this. In the beginning (2001) there was a revision control system called 'GNU Arch'. In 2004, a fork of Arch was called 'bazaar', or 'baz'. In 2005, this was rewritten from scratch as 'bazaar' or 'bzr'. It is this modern maintained version that we are interested in. So make sure that you get that.
To guard yourself from incompatibles with the clients, it is worth having a recent version of bzr, anything older than 1.0 is probably too old at this point and you should consider upgrading, as the clients may have newer incompatible versions.
So we started by checking the bzr version:
bzr --version
We then created a username bzruser, this user will be used to run the server:
sudo useradd -m bzruser
Then we created the file layout
sudo su bzruser
mkdir -p /home/bzruser/repository/group/project/trunk
We then made the trunk directory into a versioned branch:
cd /home/bzruser/repository/group/project/trunk
bzr init
We are finally ready to start up the bzr server.
bzr server --directory=/home/bzruser/repository
The default port is 4155, if you want to use another port, you can use the --port option.
Now go to another terminal on the same machine and run the following command:
bzr check bzr://localhost/group/project/trunk/
It will now tell you that there are zero revisions, zero files and so on. We can also check out this non-existent code.
bzr co bzr://localhost/group/project/trunk/
Obviously, you will need to add some files to your repository! There are also a couple of sys-admin steps required.
Firstly, you will need to use a public URL or IP Address rather than localhost. If there is a filewall such as iptables, then you need to be sure that it allows access to bzr's port.
Secondly, you will need to make the bzr server start up when the machine boots, otherwise your machine will reboot and there will be no access to your repository until some human comes and starts the bzr server.




1 Chris says...
Great write up. It is exactly what I was looking for. Thanks!
Posted at 2:01 p.m. on May 28, 2008