Setting up a shared bazaar repository

Bazaar logoI found a lack of articles on the matter, so I put together this small guide that has the goal to show you – in few easy steps – how to set up a machine that acts as a central bazaar repository using bzr+ssh://. This allows a team of people to use it à la Subversion.

By the way: Bazaar is wonderful! Kudos to the devs!

Okay, we’re system administrators, and we have little time, so let’s keep it short and simple:

  1. This one is fairly obvious: install bazaar on your server machine. Please use your distribution packages. For this guide, I’ll assume the main executable lies in /usr/bin/bzr.
  2. Create a new group, say bzrusers.
  3. Add a new user account, say bzruser. Set bzrusers as its main group.
  4. chown -R bzruser:bzrusers /home/bzruser. If, at a later stage, a user complains she/he can’t commit because of permission issues, it’s likely you touched some file herein by hand and now it’s got wrong permissions. Issue this command to fix it.
  5. I like to create a symbolic link from /repo to /home/bzruser, so that users are able to type easy-to-remember URLs later on.
  6. Create a very simple script in /usr/local/bin/bzr (so that it has precedence in the path), and give it executable permissions:
    #!/bin/bash

    HOME=/home/bzruser
    sudo -u bzruser /usr/bin/bzr “$@”

  7. Use visudo to edit /etc/sudoers in order to let any user in bzrusers execute /usr/bin/bzr as bzruser without needing to type a password:
    # /etc/sudoers

    Defaults        env_reset

    # Host alias specification

    # User alias specification

    # Cmnd alias specification

    Cmnd_Alias BAZAAR = /usr/bin/bzr

    # User privilege specification
    root    ALL=(ALL) ALL

    # Uncomment to allow members of group sudo to not need a password
    # (Note that later entries override this, so you might need to move
    # it further down)
    # %sudo ALL=NOPASSWD: ALL

    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL

    # bzr users needs to write in /home/bzrusers with the right permissions
    Defaults>bzrusers always_set_home,umask=002
    %bzrusers  ALL=(bzruser) NOPASSWD: BAZAAR

Everything’s there! Try to push something:

bzr init-repo bzr+ssh://utente@nomehost/repo/projectname

bzr push bzr+ssh://utente@nomehost/repo/projectname/branchname

Advertisements

One Response to Setting up a shared bazaar repository

  1. Russ says:

    Thanks for this! helped me immensely!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: