By Rupert
subversion
Subversion
Nov 1st
This post will contain a summary of information regarding subversion scattered from old posts.
Installation on Debian
1. Packages
#apt-get install subversion #apt-get install libapache2-svn
2. Login as root then create the repository.
#cd /data #svnadmin create /repos --fs-type fsfs
3. Set the permissions
#groupadd subversion #addgroup rupert subversion #addgroup www-data subversion #chown -Rf www-data:subversion /data/repos #chmod -Rf 770 repos
It’s better to set the necessary users and groups that would use subversion now. Later on, if we need to checkout using svn+ssh and setup a passwordless svn, then we won’t get permission issues.
4. In /etc/apache2/sites-available/2rmobile, add this to the configuration.
<Location /repos>
DAV svn
SVNPath /data/repos
SVNAutoversioning on
AuthType Basic
AuthName "SVN - Your Project"
AuthUserFile /data/svn-auth-file
Require valid-user
</Location>5. Enable the webdav module then restart apache.
#a2enmod dav #a2enmod dav_svn #/etc/init.d/apache2 restart
Passwordless SVN
On your local macbook pro (mbp), we need to generate the ssh keys from the local machine, upload it to the remote machine and append it in the authorized_keys.
On the local machine:
#ssh-keygen -t rsa ... #cd /Users/rupert/.ssh #scp -r id_rsa.pub rupert@2rmobile.com:/home/rupert/.ssh/id_rsa_mbp.pub
On the remote machine:
#cd ~/.ssh #touch authorized_keys #cat id_rsa_mbp.pub >> authorized_keys
Test on the local machine by doing
ssh rupert@2rmobile.com
. In my mbp, a dialog box from keychain is asking for the password. To circumvent this, we can add the passphrase to our identities.
#ssh-add -K ... enter the passphrase twice... #ssh-add -k (adds it to the identities) #ssh-add -l (lists the identities)
Now the benefits of having a passwordless svn:
- ofcourse it saves us a lot of time
- rails capistrano deployment
References:
http://www.howtoforge.com/debian_subversion_websvn
Subversion Tips and Tricks
http://subversion.tigris.org/faq.html#ssh-authorized-keys-trick
1. Checking out using svn+ssh and having passwordless ssh authentication. My personal favorite when working with personal projects since I have full control.
svn co svn+ssh://www.2rmobile.com/data/repos/web/rails/halalan2010 halalan2010
But for work projects, I normally use webdav
svn co "http://www.2rmobile.com/repos/web/halalan2010" halalan2010
2. svn+ssh on a custom or different port other than 22. I have my ssh on 2210, so we need to tell svn+ssh to use 2210
vim ~/.subversion/config 41 [tunnels] 42 ### Configure svn protocol tunnel schemes here. By default, only .... 53 ### built-in ssh scheme were not predefined, it could be defined 54 ### as: 55 ssh = $SVN_SSH ssh -p 2210
http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/
3. svn diff – shows you the changes in a directory. This is useful for creating patches.
svn diff -r HEAD svn st -q
3. svn switch oldURL to newURL - very useful when I’m working at home or in the office, since the svn server has a public/private IP.
4. svn log – shows you who committed and why (from the messages)
5. ignoring specific files in a directory. i.e rails directories
svn propset svn:ignore "*.log" log
SVN CheatSheet
Mar 16th
Just a list of svn commands that I find useful everyday…
1. svn diff – shows you the changes in a directory. This is useful for creating patches.
svn diff -r HEAD svn st -q
2. svn switch oldURL to newURL - very useful when I’m working at home or in the office, since the svn server has a public/private IP.
3. svn log – shows you who committed and why (from the messages)
4. ignoring specific files in a directory
svn propset svn:ignore “*.log” log
Excluding Subversion directories/files when using GREP
Feb 9th
I’ve been searching this from big-o-Goog from a long time now (two months?). During development, instead of searching the keyword from Eclipse, I still feel very much in control when I am using the commandline–using grep. Courtesy of this blog post, a big time and eye strain saver when doing a grep in a directory full with svn base files and directories is using WCGREP.
Installing Subversion on Debian
Jan 27th
I was greeted with “No space left on device” on my cron log. Turns out that my svn server obviously ran out of disk space. The old svn server was running on CentOS4.3, Subversion 1.3.2, Trac-0.11.devxxx. I decided to migrate the svn data to a new server, so I installed Debian4.01 on a small server with 72 GB HD, no partitions (just / and swap, so the svn have room to grow…). Here are the steps I took for the migration:
A. A fresh start…
1. Installed Debian. Fixed network and ssh.
2. apt-get install apache2
3. apt-get install subversion
4. apt-get install python python-setuptools python-mysqldb python-subversion
5. apt-get install libapache2-svn libapache2-mod-python
B. Making SVN work…
1. svnadmin create /repos –fs-type fsfs
2. Since I have a fresh apache configuration, I edited it accordingly from /etc/apache2/mods-available/dav_svn.conf:
#SVN dir <location> DAV svn SVNPath /repos SVNAutoversioning on AuthType Basic AuthName "SVN - Your Project" AuthUserFile /repos/svn-auth-file Require valid-user </location>
3. Restart apache
4. To test if svn is running, import a project inside the repository.
svn import -m "initial import" /tmp/project http://127.0.0.1/repos/project
C. Migrating the data
After I got my fresh debian svn machine, I need to move the svn data and trac to the new server. http://svnbook.red-bean.com/nightly/en/svn.reposadmin.html
1. Transfer /repos/svn-auth-file and /repos/svn-authorization-file to the new server
2. Transferred trac.tar.gz (/var/www/trac) to the new server
To move the svn data from one server to another, I tried the ff choices…
1. svnadmin dump /repos /reposbak. Will work if disk space is not an issue. My /repos is 25 GB, and my other 30 GB partition was wiped out, even though the dump was not finished yet.
2. svnadmin hotcopy --clean-logs /repos /repos2. Accdg to the docs, this is exactly the same repository without the BdB logs. I then transferred the hotcopy from choice 2 above to the new server and works flawlessly to my surprise. So now, I still have all my revisions
http://bealers.com/2008/01/01/installing-trac-on-debian-etch/
http://trac.edgewall.org/wiki/TracOnDebianSarge
http://trac.edgewall.org/wiki/TracUpgrade
http://trac.edgewall.org/wiki/TracInstall
http://trac.edgewall.org/wiki/TracModPython
Installing Trac on CentOS4
Jun 27th
There is a problem with clearsilver on CentOS systems. I get neo_cgi.so module not found. Don’t force yourself, it would simply not work (Trac0.10.4 on CentOS, not unless we try the DAG repositories).
So, I have to use Trac 0.11, setuptools and Genshi.
Prerequisites:
- Must have python 2.3+
- Must have mod_python-3.3.1.tgz
- Must have httpd2.0.x+ or httpd2.2.x
A. Core Trac Installation
1. Install setuptools-0.6c6-py2.3.egg. Download the setuptools according to your python distribution and simply run:
sh setuptools-0.6c4-py2.3.egg
2. Install Genshi. There are numerous ways of installing Genshi.
easy_install Genshi
or
#wget http://ftp.edgewall.com/pub/genshi/Genshi-0.4.2-py2.3.egg
#chmod +x Genshi-0.4.2-py2.3.egg
#easy_install Genshi-0.4.2-py2.3.egg
3. Install Trac 0.11. We need to install trac from svn
#svn co http://svn.edgewall.org/repos/trac/trunk trac
#python ./setup.py install
This would install trac-admin and tracd in /usr/bin.
Trac Post Intall
#mkdir -p /var/www/trac
#cd /var/www/trac
#trac-admin /var/www/trac/poimgr initenv
#chown -Rf nobody:root /var/www
#chmod -Rf 755 /var/www
Just accept the defaults for now, we can change it later on /var/www/trac/poimgr/conf/trac.ini.
C. Apache Configuration
LoadModule python_module /usr/local/apache2/modules/mod_python.so <location> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv /var/www/trac/poimgr PythonOption TracUriRoot /trac/poimgr #Order deny,allow #Deny from all #Allow from 192.168.1.0/24 AuthType Basic AuthName "TRAC-POIMGR" AuthUserFile "/repos/svn-auth-file" require valid-user </location>
Notes:
http://www.yolinux.com/TUTORIALS/LinuxSubversionAndTracServer.html
Depending on your installation, you may encounter some problems. I had problems with expat errors:
ExpatError (null): line 1,column 0.
Turns out that it was confused between the link libraries of apache and that of python.
#ps aux | grep http | head -3 #sof -p 29982 | grep expat # strings libexpat.so.0.1.0 | grep expat_ expat_1.95.2 # strings /usr/lib/python2.3/lib-dynload/pyexpat.so | grep expat_ expat_1.95.7 Quickfix is to use symbolic links: #cd /usr/local/apache2/lib/ #cp -Rf /usr/lib/libexpat.so.0.5.0 /usr/local/apache2/lib/ #ln -s libexpat.so.0.5.0 libexpat.so #ln -s libexpat.so.0.5.0 libexpat.so.0 #su -l #/etc/init.d/httpd restart
Configuring Trac.
1. I have to move /etc/svn-auth-file to /repos-auth-file. Change the permissions so “nobody” could access it.
2. How to configure my users? Well, since its an intranet application and my trac-users and developers is both in the svn-auth-file, I need a way to configure users easily. Follow these steps from trac-hack.
easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
Role base authorisation in trac
trac-admin /var/www/trac/poiclient permission remove anonymous \ TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY for n in rupert andrew; do trac-admin /var/www/trac/{app_name} permission add $n TRAC_ADMIN done for n in rupert andrew; do trac-admin /var/www/trac/{app_name} permission add $n WIKI_DELETE done trac-admin /var/www/trac/poiclient permission add authenticated \ BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW \ REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW \ TICKET_CREATE TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW \ WIKI_CREATE WIKI_MODIFY WIKI_VIEW
3. Here’s my trac.ini. Things to look at is the notification and account-manager.
4. Deleting a Trac Ticket:
# sqlite3 trac.db
delete from ticket_custom where ticket = [ticketID];
delete from ticket_change where ticket = [ticketID];
delete from ticket where id = [ticketID];
Other References:
http://www.dscpl.com.au/wiki/ModPython/Articles/ExpatCausingApacheCrash
http://www.yolinux.com/TUTORIALS/LinuxSubversionAndTracServer.html
Trac and Multiple Subversion Repositories
Future Work:
http://insurrection.tigris.org/
Comments