Trac and SVN

From Wiki

Contents

Trac (interface to Subversion and integrated wiki) and SVN (subversion)

Trac is an enhanced wiki and issue tracking system for software development projects. It provides a Graphical front end to SVN where diffs in files can be obtained. It cannot update the SVN repository. It simply provides a Project Management interface, wiki, ticketing system, and SVN front end.

SVN is a free/open-source Version Control System. Subversion (SVN) manages files and directories over time. Files are placed into a central repository and every change every made to the files or directories are remembered. If you are not familiar with SVN - then the following PDF document is a DEFINATE MUST: http://svnbook.red-bean.com/

Install SVN + Trac Software on Debian Sarge / SID

apt-get install apache2
apt-get install subversion
apt-get install libapache2-svn
apt-get install trac

Get SVN Working

mkdir /var/lib/svn
mkdir /var/lib/svn/projectname
svnadmin create /var/lib/svn/projectname --fs-type fsfs
chown -R www-data /var/lib/svn/projectname 
chgrp -R www-data /var/lib/svn/projectname 

In order to keep all SVN + apache2 configs together the following steps were carried out:

mkdir /etc/apache2/svn
vi /etc/apache2/apache2.conf
                             #Include Configs for Svn:
                             Include /etc/apache2/svn/[^.#]*
vi /etc/apache2/svn/projectname
                             <Location /svn/projectname>
                             DAV svn
                             SVNPath /var/lib/svn/projectname
                             
                             AuthType Basic
                             AuthName "Subversion Repository - Projectname"
                             AuthUserFile /etc/apache2/svn/.htpasswd
                             
                             <LimitExcept GET PROPFIND OPTIONS REPORT>
                                     Require valid-user
                                     SSLRequireSSL
                             </LimitExcept>
                             </Location>
htpasswd2 -c .htpasswd username

SVN should be all working now. If you go to http://host/svn/projectname you should see all there.

Get TRAC Working

It is best if trac is installed into a User's home directory, e.g. /home/user

trac-admin /home/user/projectname initenv
//enter data for the title
//enter data for the sql-lite database (choose defaults)
//enter path to svn info ( /var/lib/svn/projectname )
//enter path to Trac template (choose default)

trac-admin /home/username/projectname/ permission add username MILESTONE_ADMIN REPORT_ADMIN ROADMAP_ADMIN TICKET_ADMIN TRAC_ADMIN
//should work fine.

chmod -R username:group /home/username/projectname
chgrp -R www-data /home/username/projectname/db
chmod -R 775 /home/username/projectname/db

mkdir -p /home/username/public_html/projectname
vi /home/username/public_html/projectname/.htaccess   //not necessary, but useful for images/downloads etc.

vi /etc/apache2/svn/projectname   //add the content below it the end.
                                                     ScriptAlias /~username/projectname /usr/share/trac/cgi-bin/trac.cgi
                                                     <Location "/~username/projectname">
                                                     SetEnv TRAC_ENV "/home/username/projectname"
                                                     </Location>
                                                     
                                                     <Location "/~username/projectname/login">
                                                     SSLRequireSSL                                                      
                                                     AuthType Basic
                                                     AuthName "Trac Login for Projectname Website"
                                                     AuthUserFile /etc/apache2/svn/.htpasswd
                                                     Require valid-user
                                                     </Location>

Delete a TRAC & SVN Account

Things to delete:

rm -R /var/lib/svn/projectname
rm /etc/apache2/svn/projectname
rm -R /home/username/projectname
rm -R /home/username/public_html/projectname //if exists

Add a TRAC & SVN Account

Sorry if this repetitive of above.

svnadmin create /var/lib/svn/projectname --fs-type fsfs
chown -R www-data:www-data /var/lib/svn/projectname 
trac-admin /home/user/projectname initenv
trac-admin /home/username/projectname/ permission add username MILESTONE_ADMIN REPORT_ADMIN ROADMAP_ADMIN TICKET_ADMIN TRAC_ADMIN
chown -R username:group /home/username/projectname
chgrp -R www-data /home/username/projectname/db
chmod -R 775 /home/username/projectname/db
vi /etc/apache2/svn/projectname
<Location /svn/projectname>
DAV svn
SVNPath /var/lib/svn/projectname 

AuthType Basic
AuthName "Subversion Repository - Projectname"
AuthUserFile /etc/apache2/svn/.htpasswd

<LimitExcept GET PROPFIND OPTIONS REPORT>
        Require valid-user
        SSLRequireSSL
</LimitExcept>
</Location>

ScriptAlias /~username/projectname /usr/share/trac/cgi-bin/trac.cgi
<Location "/~username/projectname">
SetEnv TRAC_ENV "/home/username/projectname"
</Location>

<Location "/~username/projectname/login">
SSLRequireSSL                                                      
AuthType Basic
AuthName "Trac Login for Projectname Website"
AuthUserFile /etc/apache2/svn/.htpasswd
Require valid-user
</Location>
/etc/init.d/apache2 restart

Wipe a SVN repo and update Trac

If you want to wipe a svn repo - if it got corrupt or if something happened, AND you want to keep trac etc. you need to do the following:

rm /var/lib/svn/projectname
/var/lib/svn/projectname
//chown and reset permissions as covered previously

Trac then will give the following error: "The 'repository_dir' has changed, a 'trac-admin resync' operation is needed". Here is what to do:

trac-admin /home/username/projectname resync

Hope that works ok for you. Info: http://trac.edgewall.org/ticket/4204

Click here for Using Trac & Svn

Errors and Problems with Trac

After upgrading python2.3 to python2.4 (among other things) on the compsoc server, trac got itself broken. The errors I was getting were: "file is encrypted or is not a database" and "clearsilver not installed etc."

1. Check that:

/usr/bin/python is symlinked to: python2.4

2. Check that sqlite is installed. It is quite possible that only sqlite3 is installed, hence giving the above problems. 3. This might solve some issues. If it doesnt:

cd /project/trac/db
cd  /var/site/nara.ms/project/hoge/trac
mv trac.db trac2.db
sqlite trac2.db  .dump | sqlite3 trac.db
trac-admin trac upgrade
trac-admin trac resync

More info on this error can be found at: http://hidelafoglia.livejournal.com/33118.html


Information Used:

http://www.debianhelp.co.uk/trac.htm

Skynet Configs.