Subversion

Revision 18 as of 2005-10-25 12:57:24

Clear message

TableOfContents([2]) This wiki document explains howto setup SubVersion alias SVN on Ubuntu Linux. The intended audience are experienced Linux users and system administrators.

Introduction

If you are new to SubVersion, this section provides a quick introduction about SubVersion.

SubVersion is an open source version control system. Using SubVersion, you can record the history of source files and documents. It manages files and directories over time. A tree of files is placed into a central repository. The repository is much like an ordinary file server, except that it remembers every change ever made to files and directories.

Assumptions

It is assumed that you are aware of running Linux commands, editting files, starting/stopping services in Ubuntu Linux system. It is also assumed that Ubuntu Linux is running, you have sudo access ([https://wiki.ubuntu.com/RootSudo RootSudo]) and you want to use SubVersion software.

It is assumed that you require to access SVN repository using all access methods. It is also assumed you have internet connection and you have configured your /etc/apt/sources.list.

Scope of this document

To access SVN repository using HTTP protocol, you must install & configure web server. Apache 2 is proven to work with SVN. The installation of Apache 2 Webserver is beyond the scope of this document. The configuration of Apache 2 Webserver for SVN is covered in this document.

To access SVN repository using HTTPS protocol, you must install & configure digital certificate in your Apache 2 web server. The installation and configuration of digital certificate is beyond the scope of this document. You can refer appropriate documents for details.

Installation

SubVersion is already in the main repository. So, to install SubVersion you run:

  $ sudo apt-get install subversion
  $ sudo apt-get install libapache2-svn

If it fails reporting dependencies, please locate the packages and install them. If it reports any other issues, please resolve them. If you cannot resolve the issue, please refer the mailing list archive of those packages.

Server Configuration

This step assumes you have installed above mentioned packages on your system. This section explains how to create SVN repository and access the project.

Create SVN Repository

The SVN repository can be created using the following command:

  $ svnadmin create /path/to/repo/project

Access Methods

SubVersion repositories can be accessed (checkout) through many different methods-on local disk, or through various network protocols. A repository location, however, is always a URL. The table describes how different URL schemas map to the available access methods.

Schema

Access Method

file:///

direct repository access (on local disk)

http://

Access via WebDAV protocol to SubVersion-aware Apache 2 web server

https://

Same as http://, but with SSL encryption

svn://

Access via custom protocol to an svnserve server

svn+ssh://

Same as svn://, but through an SSH tunnel

In this section, we will see howto configure SVN for all these access methods. Here, we cover the basics. For more advanced usage details, you are always recommended to refer the [http://svnbook.red-bean.com/ svn book].

Direct repository access (file://)

This is the simplest of all access methods. It does not require any SVN server process to be running. This access method is used to access SVN from the same machine. The syntax is as follows:

  $ svn co file:///path/to/repo/project
            or
  $ svn co file://localhost/path/to/repo/project

NOTE: Please note, if you do not specify the hostname, you must use three forward slashes (///). If you specify the hostname, you must use two forward slashes (//).

The repository permission is depend on filesystem permission. If the user has read/write permission, he can checkout/commit the changes to the repository.

Access via WebDAV protocol (http://)

To access the SVN repository via WebDAV protocol, you must configure your Apache 2 web server. You must add the following snippet in your /etc/apache2/apache2.conf file:

  <Location /svn>
  DAV svn
  SVNPath /path/to/repo
  AuthType Basic
  AuthName "Your repository name"
  AuthUserFile /etc/subversion/passwd
  <LimitExcept GET PROPFIND OPTIONS REPORT>
  Require valid-user
  </LimitExcept>
  </Location>

Next, you must create /etc/subversion/passwd file. This file contains user authentication details. To add an entry, ie.. to add a user, you can run the following command:

  htpasswd2 /etc/subversion/passwd user_name

It prompts you to enter the password. Once you enter the password, the user is added. Now, to access the repository you can run the following command:

  $ svn co http://hostname/project project --username user_name

It prompts you to enter the password. You must enter the password configured using htpasswd2 command. Once it is authenticated the project is checked out.

WARNING: The password is transmitted as plain text. If you are worried about password snooping, you are advised to use SSL encryption. For details, please refer next section.

Access via WebDAV protocol with SSL encryption (https://)

Accessing SVN repository via WebDAV protocol with SSL encryption (https://) is similar to http:// except you must install and configure the digital certificate in your Apache 2 web server.

You can install a digital certificate issued by Signing authority like Verisign. Alternatively, you can install your own self signed certificate.

This step assumes you have installed and configured digital certificate in your Apache 2 web server. Now to access SVN repository please refer the above section! Yeah, the access methods are exactly the same except the protocl. You must use https:// to access the SVN repository.

=== Access via custom protocol (svn://)===

Once the SVN repository is created, you can configure the access control. You can edit /path/to/repos/project/conf/svnserve.conf file to configure the access control.

For example, to setup authentication you can uncomment the following lines in the configuration file:

  # [general]
  # password-db = passwd

After uncommenting the above lines, you can maintain the user list in passwd file. So, edit the file passwd in the same directory and add new user. The syntax is as follows:

  username = password

For more details, please refer the file.

Now, to access SVN via svn:// custom protocol either from the same machine or different machine, you can run svnserver using svnserve command. The syntax is as follows:

  $ svnserve -d --foreground -r /path/to/repo
    # -d -- daemon mode
    # --foreground -- run in foreground (useful for debugging)
    # -r -- root of directory to serve

  For more usage details, please refer,
  $ svnserve --help

Once you run this command, SVN starts listening on default port (3690). To access the project repository, you must run the following command:

  $ svn co svn://hostname/project project --username user_name

Based on server configuration, it prompts for password. Once it is authenticated, it checks out the code from SVN repository.

To synchronize the project repository with the local copy, you can run update sub-command. The syntax is as follows:

  $ cd project_dir
  $ svn update 

For more details about using each SVN sub-command, you can refer the manual. For example, to learn more about co (checkout) command, please run:

  $ svn co help

Access via custom protocol with SSL encryption (svn+ssh://)

The configuration and server process is same as svn:// method. For details, please refer the above section. This step assumes, you have followed the above step and run SVN server using svnserve command.

It is also assumed that the ssh server is running in that machine and it is allowing incoming connections. To confirm, please try to login to that machine using ssh. If you can login, then everything is perfect. If you cannot login, please address it before continuing further.

svn+ssh:// protocol is used to access SVN repository using SSL encryption. As you know, the data transfer is encrypted. To access the project repository, you must run the following command:

  $ svn co svn+ssh://hostname/path/to/repos/project project --username user_name

NOTE: You must use full path (/path/to/repos/project) to access SVN repository using this access method.

Based on server configuration, it prompts for password. You must enter the password you use to login via ssh. Once it is authenticated, it checks out the code from SVN repository.

You can also refer the SVN book for details about svn+ssh:// protocol.

References

Hope this document is useful. Comments and feedbacks are welcome to bhuvaneswaran at NOSPAM gmail dot com.


CategoryDocumentation