HowtoForge

Using The Bazaar Version Control System (VCS) On Debian Etch

Using The Bazaar Version Control System (VCS) On Debian Etch

Version 1.0
Author: Falko Timme

Bazaar is a distributed version control system (VCS) available under the GPL; it's similar to Subversion (svn). Bazaar is sponsored by Canonical, Ltd., the company that develops the Ubuntu Linux distribution, and therefore the Ubuntu project is the most prominent user of Bazaar. This article explains how to set up and use Bazaar on a Debian Etch system, and how to configure an SFTP-/HTTP server to host your Bazaar repository.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this tutorial I will use two Debian Etch systems:

I'll use the username falko on both systems.

Most Bazaar usage examples are taken from this guide: http://doc.bazaar-vcs.org/latest/en/mini-tutorial/index.html, but in addition to that this guide explains exactly how to install SFTP and lighttpd on the server and Bazaar on the workstation to make the Bazaar experience a little bit smoother for not-so-experienced Linux users.

 

2 Installing SFTP And Lighttpd On The Server

server:

(All the steps in this chapter have to be done as the root user!)

Let's install SFTP and lighttpd on the server:

apt-get install ssh openssh-server lighttpd

Next we create a user account - falko in this case - that uses the /usr/lib/sftp-server shell instead of /bin/bash or any other shell:

useradd -m -s /usr/lib/sftp-server falko

This creates the user falko with the home directory /home/falko.

Assign a password to falko:

passwd falko

Then make /usr/lib/sftp-server a valid login shell by adding it to /etc/shells:

echo '/usr/lib/sftp-server' >> /etc/shells

Now I create the directory /home/falko/public_html which will be lighttpd's document root and will contain our Bazaar repository:

mkdir /home/falko/public_html
chown falko:falko /home/falko/public_html

To tell lighttpd that the document root has changed to /home/falko/public_html, open /etc/lighttpd/lighttpd.conf and modify the server.document-root line:

vi /etc/lighttpd/lighttpd.conf
[...]
server.document-root       = "/home/falko/public_html"
[...]

Restart lighttpd afterwards:

/etc/init.d/lighttpd restart

 

3 Installing Bazaar On The Workstation

workstation:

Run the following command as root:

apt-get install bzr python-paramiko

If you don't already have a normal user account on the workstation, create one now:

useradd -m -s /bin/bash falko
passwd falko

 

4 Using Bazaar

workstation:

Now log in as the normal user, or, if you are logged in as root, run

su falko

to become the normal user (in this case falko).

Then go to your home directory:

cd ~

The following examples are more or less taken from http://doc.bazaar-vcs.org/latest/en/mini-tutorial/index.html.

First, tell Bazaar who you are:

bzr whoami "Falko Timme <ft@example.com>"

Check that Bazaar has correctly stored your identity:

bzr whoami
falko@server1:~$ bzr whoami
Falko Timme <ft@example.com>
falko@server1:~$

Now let's create a test directory with some test files:

mkdir myproject
cd myproject
mkdir subdirectory
touch test1.txt test2.txt test3.txt subdirectory/test4.txt

The myproject directory is the base folder for our software project that we want to manage with Bazaar. It's important that you run all bzr commands in that directory! If you are not sure in which directory you are, run

pwd

Bazaar must initialize itself in the project directory:

bzr init

This creates some hidden files that Bazaar needs to manage your project. You can see the hidden folder .bzr in the myproject directory when you run

ls -la
falko@server1:~/myproject$ ls -la
total 16
drwxr-xr-x 4 falko falko 4096 2007-12-19 16:14 .
drwxr-xr-x 4 falko falko 4096 2007-12-19 16:13 ..
drwxr-xr-x 6 falko falko 4096 2007-12-19 16:14 .bzr
drwxr-xr-x 2 falko falko 4096 2007-12-19 16:13 subdirectory
-rw-r--r-- 1 falko falko    0 2007-12-19 16:13 test1.txt
-rw-r--r-- 1 falko falko    0 2007-12-19 16:13 test2.txt
-rw-r--r-- 1 falko falko    0 2007-12-19 16:13 test3.txt
falko@server1:~/myproject$

Now run

bzr add

to make all files/directories in the myproject folder versioned. The output is as follows:

falko@server1:~/myproject$ bzr add
added subdirectory
added test1.txt
added test2.txt
added test3.txt
added subdirectory/test4.txt
falko@server1:~/myproject$

Next add the files/directories to your branch (with a small comment so that you know what this commit is about):

bzr commit -m "Initial import"

The output is as follows:

falko@server1:~/myproject$ bzr commit -m "Initial import"
added subdirectory
added subdirectory/test4.txt
added test1.txt
added test2.txt
added test3.txt
Committed revision 1.
falko@server1:~/myproject$

Now let's modify the (yet empty) file test1.txt:

vi test1.txt
some text...

Run

bzr diff

and Bazaar will show you the changes:

falko@server1:~/myproject$ bzr diff
=== modified file 'test1.txt'
--- test1.txt   2007-12-19 15:19:42 +0000
+++ test1.txt   2007-12-19 15:20:39 +0000
@@ -0,0 +1,1 @@
+some text...

falko@server1:~/myproject$

To commit the changes (again with a comment), run

bzr commit -m "Added first line of text"
falko@server1:~/myproject$ bzr commit -m "Added first line of text"
modified test1.txt
Committed revision 2.
falko@server1:~/myproject$

The command

bzr log

displays a history of the latest actions:

falko@server1:~/myproject$ bzr log
------------------------------------------------------------
revno: 2
committer: Falko Timme <ft@example.com>
branch nick: myproject
timestamp: Wed 2007-12-19 16:22:52 +0100
message:
  Added first line of text
------------------------------------------------------------
revno: 1
committer: Falko Timme <ft@example.com>
branch nick: myproject
timestamp: Wed 2007-12-19 16:19:42 +0100
message:
  Initial import
falko@server1:~/myproject$
Using The Bazaar Version Control System (VCS) On Debian Etch