HomePage » VC » SVNLinux


SVN onlinux

Subtopics

Install SVN

On debian, just do aptitude install svn

Building SVN rpm

Get apr, apr-utils, sqlite, neon, subversion, httpd source
On centos 4, install the followings
yum -y install db4-devel sqlite-devel expat-devel


Build apr rpm with rpmbuild -tb apr-1.3.3.tar.gz. Install the produced rpms. Edit apr-utils.spec,
to configure options:
+ --with-dbm=db42 --with-berkeley-db=/usr --disable-util-dso
- testall -v || exit 1


then proceed to rpmbuild -tb apr-util-1.3.4.tar.gz

apache is required for building of dav and svn apache modules. Assuming you want apache-2.2 which is not available from your repo, build apache rpm with rpmbuild -tb httpd-2.2.11.tar.gz then install the httpd and mod_ssl rpms.


Create an initial repository

For me, I'll create the repo in /home/svnrepo and the Linux group developers will have access to this repo:

mkdir -p /home/svnrepo
svnadmin create /home/svnrepo
chgrp -R developers /home/svnrepo
chmod -R g+w /home/svnrepo


Now create an initial directory in the repository.
$ mkdir -p /tmp/r/trunk /tmp/r/branches /tmp/r/tags
$ cd /tmp/r
$ svn import . file:///home/svnrepo -m "Initial directory structure"


To make sub directories, you can do that with the previous import, or add them later on:
$ mkdir scripts
$ svn import . file:///home/svnrepo/trunk -m "scripts go here"


Check out trunk/scripts
$ svn co file:///home/svnrepo/trunk/scripts my_scripts
$ ls
my_scripts


Add files and commit:
cd my_scripts
cp /some/path/mysqldump.sh .
svn add mysqldump.sh
svn commit .
<You will be prompted for entering comments>


Checking out files again
$ rm -Rf ./my_scripts
$ svn co file:///home/svnrepo/trunk/scripts my_scripts
<you will find mysqldump.sh in my_scripts, so svn ci/co has been verified>


Ignoring directories
>  cd WORKING_COPY
> svn propset svn:ignore ignore-this-dir .
property 'svn:ignore' set on '.'


Subversion commands:
co/checkout	Check out a copy of the source code to a working copy.
ci/commit	Commit your local changes to the repository
up/update	Update your working copy to reflect changes to the repository since your last update
status	New in Subversion - summarise your local changes, without talking to the repository, or summarise resources that are out of date without updating.
add, remove/rm	Add or remove files to/from version control.
copy/cp, move/mv	New in Subversion - copy/move a file or directory to another file, keeping old version history.
merge	Equivalent to cvs update -j - merge changes from another location into the working copy.
switch	Change your working copy to use another branch
diff	Get differences between your working copy and the last updated sources (new to Subversion), or the current repository
log	Show log entries for resource
propadd, proplist, propdel, propviewi	New to Subversion - manipulate metadata on a file. You can associate arbitrary data to any file or directory. A certain number of metadata keys have a special meaning (for example, svn:mime-type).


SVN web access (via DAV)

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

NameVirtualHost 1.2.3.4:80
<VirtualHost 1.2.3.4:80>
ServerName svn2.limelightcrm.com
DocumentRoot /var/www/html
ErrorLog logs/svn2.err
CustomLog logs/svn2.log combined

# It is important that the following Location is not defined in DocumentRoot or Alias. Or else you will get a 301 error - http://subversion.tigris.org/faq.html#301-error
<Location /repos>
	  DAV svn
	  #SVNParentPath /home/svn-repos
	  SVNPath /home/svn-repos/project1

	  AuthType Basic
	  AuthName "Authorization Realm"
	  AuthUserFile /home/svn-repos/project1/conf/htpasswd
		Order deny,allow
		require valid-user
# Limit write permission to list of valid users.
#   <LimitExcept GET PROPFIND OPTIONS REPORT>
#     Require valid-user
#   </LimitExcept>
</Location>
</VirtualHost>


Other examples


Showing version comments on a file
$ cd my_scripts
$ svn log --verbose mysqldump.sh


Tag a project in trunk - tag is a snapshot of a project
$ svn copy file:///home/svnrepo/trunk/scripts file:///home/svnrepo/tags/scripts/release-1.0 -m "Tagging release 1.0 of scripts"


Create a new branch from the trunk
$ svn copy file:///home/svnrepo/trunk/scripts file:///home/svnrepo/branches/scripts/unix -m "Create a UNIX branch"
$ svn copy file:///home/svnrepo/trunk/scripts file:///home/svnrepo/branches/scripts/linux -m "Create a Linux branch"


Look for updates from the repo
$ svn status -u


Diff working copy with repo
$ svn diff -rXXX <filename>


Give up changes on working copy
$ svn revert filename


Subversion and trac

This is a little tricker. Personally, I think it's because of poor quality of trac.

Install subversion from source

Prereq:
Install swig from source

Next, install subversion. Now I only managed to get subversion 1.5.7 to with trac. No luck with 1.5.5 and 1.6.5.

extract sqlite-3.x into subversion source, rename it to sqlite-amalgamation
./configure  --with-ssl --prefix=/opt/subversion \
--with-apr-util=/usr/bin/apu-1-config \
--without-berkeley-db --with-apxs=/usr/sbin/apxs \
--disable-mod-activation --with-swig=/opt/swig
make 
make install


Build python bindings

From the subversion source, do

make swig-py
make check-swig-py
make install-swig-py


Edit LD path and apache init script

Add this into apache's init script:
export PYTHONPATH=/opt/subverson/lib/svn-python:$PYTHONPATH


Add this into ld.so.conf and run ldconfig
/opt/subverson/lib/svn-python


Most impoprtant of all, tell python to use the newly build bindings instead of whatever that comes with your distribution:
echo /opt/subverson/lib/svn-python >
/usr/lib/python2.4/site-packages/subversion.pth


Create a trac root

trac-admin /var/trac/root initenv
mkdir -p /var/trac/root/.egg-cache
chown apache:apache /var/trac/root/.egg-cache
chown -R apache:apache /var/trac/root/db


Edit TRAC_ROOT/conf/trac.ini and enable logging. Make this file writable by apache
log_type = file
log_file = trac.log


Create the apache directives

One can access trac with mod_python or perl. The following example uses python:

# trac.conf
<Location "/trac">
	SetHandler mod_python
	PythonHandler trac.web.modpython_frontend
	PythonOption TracEnv /var/trac/root
	PythonOption TracUriRoot /trac
	AuthType Basic
	AuthName "My Development"
	AuthUserFile /etc/subversion/passwd
	Require valid-user
</Location>


On access, trac will try to synchronize with your subversion repository. Be patient if you have a large number of revisions
Comments [Hide comments/form]
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki