Even if you work on your own small project, it is very important to keep track of your changes, here comes subversion, i use subversion over others because it is way simple to configure and use, and it has a lot of web browsing services that allow you to browse your repository using a web browser.
Step1: setup your svn repository
first of all you need to install subversion, use your package manager to do this:
Ubuntu: sudo apt-get install subversion
Slackware: slackpkg install subversion
Then create a folder where you want your svn repository to be, make sure you have write permission to the folder, /svn will be used in this example.
sudo mkdir /svn
sudo chown your_user_name:your_user_name /svn (example sudo chown foo:foo /svn)
svnadmin create /svn/projects
Of course you can create the svn folder in your home directory, then you don’t have to change its ownership.
svn co --non-recursive file:///svn/projects projects
svn mkdir new-project
svn commit -m "Initial import"
Once you have done the above step, you can start working on your project, here is some svn command that you will need to use.
/* to create a file */
svn add main.c
/* to see the diff log */
/* information about the repository */
/* status of the current working directory */
To Configure your subversion server your should look in the conf directory created under your svn repository, in this example it is /svn/projects/conf. We need to edit two files, the svnserve.conf for the server configuration and the passwd for adding users with their passwords.
Uncomment and modify the following lines of svnserve.conf as follows:
anon-access = none
auth-access = write
password-db = passwd
Add users to passwd file, example:
foo = password_here
Start your subversion server with the following command:
To autostart the svn server you could put the above command in your rc.local such way the server is automatically started after reboot.
Now you can checkout your subversion repository like:
svn co svn://localhost/svn/projects projects
There is a lot of subversion repository web browsing clients, what we are going to use here is SVN::Web perl, you need to install the SVN-Web, depending on your distro the name might be different, in ubuntu the package name is libsvn-web-perl .
steps here are very simple, we need to created a folder where we put the svn web server files, then we start the server
mkdir web-svn ( make the this directory where you like)
The above command svnweb-install will generate the necessary files for our repository web view, you need to edit the config.yaml configuration file to point to your svn directory example will be as follow:
Instead of RepoName you can put whatever you like, it is just the repository name
Start the svn perl web server:
svnweb-server --root /svn/pojects
To View your the contents of your subversion repository use a web-browser with the following address, localhost:8080, also to start the perl web serving you could add the above command in your rc.local
What about if we want to get better name for our svn web view, something like domain-name.org/svn here are some hints for setting this up.
1)-Go to dyndns.com and register a domain name associated with your ip address.
2)-Enable the dyndns service in your router.
3)-Open and forward the ports 80 and 8080 to your subversion computer.
4)-Add the registered domain name to the subversion computer.
5)-Configure the apache2 web server and enable cgi scripts.
Edit /etc/hosts and add the ip address of the machine as well as your domain name.
sudo apt-get install apache2 libapache2-mod-perl2 libapache2-request-perl
/* Make sure that the following links exist, if not create them */
sudo ln -sv /etc/apache2/mods-available/cgi.load cgi.load
sudo ln -sv /etc/apache2/mods-available/apreq.load apreq.load
sudo ln -sv /etc/apache2/mods-available/perl.load perl.load
Now we need to edit apache2.conf which is in /etc/apache2 configuration file to enable the SVN-Web view.
Add the following lines in apache2.conf, change /svn/web to where you have created your svn-web directory.
Alias /svnweb /svn/web
sudo /etc/init.d/apache2 restart
Now you should be able to connect to your svn web from any machine using the address your_domain_name/svnweb, as an example it could be example-domain.org/svnweb, don’t hesitate to contact me if you have any question.
In principle the above steps should be enough to set up a web view for your svn repository, but that’s in principle, in practice you may run in troubles, two main problems appear to complicate the setup of libsvn-web-perl under Ubuntu 8.10.
1) Missing dependencies for libsvn-web-perl.
2) svnweb-server needs a patch to avoid an assertion failure causing a svnweb-server crash.
For the second problem, this is affecting any Linux system using subversion 1.5.0 with a non patched SVN::Web.
We will start by installing the required packages, we will use dh-make-perl to build the package that is missing from the Ubuntu repositories.
sudo apt-get install libsvn-web-perl libtimedate-perl libnumber-format-perl dh-make-perl
/* Answer yes for all the questions out from this command */
dh-make-perl --build --cpan Template::Plugin::Number::Format
dpkg -i libtemplate-plugin-number-format-perl_1.02-1_all.deb
rm -rf /tmp/deb
Size : 4 Kb
Type : patch
Follow these instructions:
tar -xvf SVN-Web-0.53.tar.gz
patch -Np1 -i ../svn-web-0.53-svn15.patch
/* don't install anything we just need to copy the patched files */
sudo cp Diff.pm Log.pm Revision.pm View.pm action.pm /usr/share/perl5/SVN/Web/.
now rerun svnweb-server and you should be able to surf your repository, still having troubles mail me.
Hopefully you found this small tutorial useful, as usual permission is garanteed to modify or copy the content of this document under the GNU General Public License GPL.