BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Subversion for BSD With All the Bells and Whistles
Pages: 1, 2

In /usr/local/etc/apache22/extra/httpd-vhosts.conf:

<VirtualHost *:80>
ServerName svn.projectname.org
ServerAlias projectname.org
ServerAdmin webmaster@projectname.org
ErrorLog /var/log/apache/projectname.org/svn/httpd-error.log
TransferLog /var/log/apache/projectname.org/svn/httpd-access.log
<Location />
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /home/trac/projectname
PythonOption TracUriRoot /
</Location>
<Location /login>
Redirect permanent /login https://svn.projectname.org/projectname/login/
</Location>
<Location /svn>
DAV svn
SVNPath /home/svn/projectname
AuthzSVNAccessFile /home/svn/ro_access
</Location>
</VirtualHost>

In /usr/local/etc/apache22/extra/httpd-ssl.conf:

<Location /projectname>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /home/trac
PythonOption TracUriRoot /
</Location>
<Location /projectname/login>
AuthType Digest
AuthName "svn"
AuthDigestDomain /
AuthDigestProvider file
AuthUserFile /home/svn/htdigest
Require valid-user
order allow,deny
allow from 127.0.0.4
Satisfy any
</Location>

<Location /svn>
DAV svn
SVNParentPath /home/svn
AuthzSVNAccessFile /home/svn/access
AuthType Digest
AuthName "svn"
AuthDigestDomain /
AuthDigestProvider file
AuthUserFile /home/svn/htdigest
Require valid-user
</Location>

You'll need to put the above code in the appropriate location of the Apache SSL config file. Also, pay attention to the 127.0.0.4, as we'll be modifying it later for the IRC announcements.

As you can see, checking out the SVN repository and creating/viewing tickets is all done over an unencrypted link. Meanwhile, logging into Trac, or Subversion, is handled via SSL encryption. Of course, you could modify the above configs to handle everything over an encrypted link.

We still need to create a user and set up the read-only access.

htdigest /home/svn/htdigest svn yourusername

In /home/svn/access:
[/] yourusername = rw

The rw will allow yourusername to read and write to anything in the repository.

In /home/svn/ro_access, add:
[/]
* = r

The * matches everyone, and sets them to read-only mode.

Now that Apache is configured, you have a user, and have set up anonymous access, you're probably interested in using them!

Trac will be available at http://svn.yourprojectname.org and the Subversion repository will be available at svn co http://svn.yourprojectname.org/svn/projectname.

For the authenticated features of the above, replace http with https.

Now that we understand what is going on, let's attempt a private or closed source project. Only authenticated users are allowed to browse the repository, check out code, and create/view/edit tickets. Also, everything is encrypted via SSL. This setup will be much easier than the last, as we don't have to worry about http/https or read-only users.

In /usr/local/etc/apache22/extra/httpd-ssl.conf:

<Location /admin>
SetHandler mod_python
PythonInterpreter main_interpreter
PythonHandler trac.web.modpython_frontend
PythonOption TracEnvParentDir /home/trac
PythonOption TracUriRoot /
AuthType Digest
AuthName "prometheus"
AuthDigestDomain /
AuthDigestProvider file
AuthUserFile /home/svn/htdigest
Require valid-user
order allow,deny
allow from 127.0.0.4
Satisfy any
</Location>

Again, pay attention to the 127.0.0.4, as it will be used for the IRC announcements. Your Trac and SVN should only be available to authenticated users over https now.

Lastly, for the configuration stuff, you may want to refer to this article to allow certain groups to specific parts of the repositories. (For example, web developers don't need commit access to the source code, only to the www directory.)

Commit Messages and New Ticket Notifications over IRC

I looked for quite a while to find an easy-to-use announcement method for our developers and analysts who use IRC as their primary means of communication. In the process, I found several software projects that would work, but ultimately, I decided on using a Supybot. Supybot is an IRC bot that has multiple plugins and features, allowing you to quickly and easily adapt it for specific needs. But wait, it's even better! Supybot has an available plugin to read RSS feeds, and Trac has RSS feeds. The fact that Supybot is written in Python is even better, because we're already using Python for the Trac installation. What more can you ask for?

# cd cd /usr/ports/irc/py-supybot-plugins/
# make all install clean

This will compile Supybot, and the extra plugins pack (which contains the RSS plugin)

Change directories to wherever you want your Supybot to run from. It doesn't matter where you choose, and it's all personal preference. I personally chose to create a new user account named Supybot and su'd as that user.

# supybot-wizard

Answer the questions it asks. When it asks about plugins, enable the RSS plugin. this is the main one we are interested in, but as I mentioned earlier, supybot has a lot of plugins to enhance functionality. Spend some time, and see which ones interest you. Now that you've got that done, it's time to start it.

 nohup supybot YourBotName.conf &

Your announcement bot should appear on your IRC channel within a few minutes. If not, check the logs and fix the problems. After he appears in your channel, you'll need to identify yourself to him with the username and password you chose a minute ago.

/msg YourBotName identify YourUsername YourPassword

He should respond with "The operation succeeded" or something similar.

Now it's time to configure the actual announcement plugin. You'll want to message (/msg) all of the following commands to your new announcement bot.

 config plugins.rss.announcementprefix ""
config plugins.rss.waitperiod 60
config plugins.rss.announce.showlinks true
rss add projectname http://svn.yourproject.org/projectname/timeline?ticket=on&ticket_details=on&milestone=on&changeset=on&wiki=on&max=5&daysback=1&format=rss
rss announce #channel projectname

The above lines do the following:

  1. Disable announcement prefixes
  2. Set the RSS feed check interval to 60 seconds
  3. Show the link to the ticket or changeset being announced
  4. Add the URL where the trac RSS feed resides
  5. Start the bot announcing on #channel

In closing, this has been a very educational project for me. I've never really used Python, Subversion, or Trac before. I hope this helps those of you who want to set up a similar environment for your project.

Jeff Palmer is a systems administrator with over 15 years experience with Windows and Unix operating systems. He has worked for several privately owned ISPs and other internet upstarts. Jeff is currently working as a contractor doing FreeBSD administration for various clients, and is active in the FreeBSD community. His hobbies include racing motorcycles (on a track of course!), riding jet skis, reading, embedded computers, and almost anything else computer related.


Return to ONLamp: BSD DevCenter.



Sponsored by: