<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Open Coder &#187; trac</title>
	<atom:link href="http://www.opencoder.co.uk/tag/trac/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.opencoder.co.uk</link>
	<description>Helping the fellow geek</description>
	<lastBuildDate>Fri, 15 Apr 2011 12:25:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Trac adding git, mylyn and post-commit hooks</title>
		<link>http://www.opencoder.co.uk/2010/03/trac-adding-git-mylyn-and-post-commit-hooks/</link>
		<comments>http://www.opencoder.co.uk/2010/03/trac-adding-git-mylyn-and-post-commit-hooks/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 19:14:58 +0000</pubDate>
		<dc:creator>Chris McDonald</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.opencoder.co.uk/?p=153</guid>
		<description><![CDATA[It has been another long time between posts, but here is as promised, but very delayed, the second part to this post. Working with git repositories in trac It is incredibly simple to use a git repository instead of svn with trac, you just need to have the right plugin installed and enabled. Once again [...]]]></description>
			<content:encoded><![CDATA[<p>It has been another long time between posts, but here is as promised, but very delayed, the second part to <a title="Setting up a svn trac server" href="http://www.opencoder.co.uk/2010/01/setting-up-a-svn-and-trac-server/" target="_blank">this post</a>.</p>
<h3>Working with git repositories in trac</h3>
<p>It is incredibly simple to use a git repository instead of svn with trac, you just need to have the right plugin installed and enabled. Once again I&#8217;ll give install details for FreeBSD and Ubuntu.</p>
<p>Firstly we need to install the trac git plugin. For FreeBSD there is as usual a dedicated port install for what we need. As of writing the plugin version is 0.11.0.2 r7034. As the root user run:</p>
<pre>cd /usr/ports/www/trac-gitplugin
make install clean</pre>
<p>Ubuntu users, as root or using <em>sudo</em>:</p>
<pre>apt-get install trac-git</pre>
<p>With the trac git plugin installed, all we need to do is create a new git repository if we haven&#8217;t got one already and create a new trac project pointing to the git repository (or edit the trac.ini config file of an existing trac project). So following from the FreeBSD logic in the previous post, lets create a new git repository in /usr/local/git as root.</p>
<pre>cd /usr/local
mkdir git
cd git
mkdir MyGitProject
git init MyGitProject</pre>
<p>The git repository above was created by the root user, if you are accessing the git repository over ssh and want to be able to push changes to it, you will need to make sure that the user has read and write access to the folder and everything in the .git folder. What I have done in the past is create a group on the system called <em>developers</em> and add all the user accounts to the group. Then change the group of the git repository to <em>developers</em> and give it group write access. You have to make sure the whole folder and all files are writable by this group or you will get errors trying to push to the repository. An alternative is to just create the git repository using one user account or change the owner of the whole repository to a specific user account and only use that user account to push and pull to the server.</p>
<p>With the repository created, we can now create a new trac project, this is the same steps as in the previous post but we change the repository type from svn to git.</p>
<pre>cd /usr/local/trac
mkdir MyTracGitProject
trac-admin MyTracGitProject initenv</pre>
<p>The trac-admin program runs in interactive mode and will ask you questions to set up your repository, example questions and responses are given below.</p>
<pre>Project Name [My Project]&gt; My Trac Git Project
Database connection string [sqlite:db/trac.db]&gt;
Repository type [svn]&gt; git
Path to repository [/path/to/repos]&gt; /usr/local/git/MyGitProject/.git</pre>
<p>Now we just need to edit the trac.ini, this is in the trac project folder, so in our case /usr/local/trac/MyTracGitProject/conf/trac.ini. Make sure that under the [trac] section repository_type is <em>git</em> and the repository_dir is correctly pointing to the <em>.git</em> folder. Also FreeBSD gets the location of the git binary wrong, under the [git] section change git_bin from <em>/usr/bin/git</em> to <em>/usr/local/bin/git</em>. Finally, add the following if your trac.ini file does not already have it.</p>
<pre>[components]
tracext.git.* = enabled</pre>
<p>Now we just need to change the owner of the new trac project to the web user and edit the apache config for the new trac project location. See the <a title="Setting up a trac server" href="http://www.opencoder.co.uk/2010/01/setting-up-a-svn-and-trac-server/" target="_blank">previous</a> post for how to do that.</p>
<h3>Adding Mylyn support for trac</h3>
<p>Mylyn for Eclipse is great, if you are not using it already, you should be. It basically allows you to create tasks, those tasks you can activate and work on, whilst a task is activated it looks at what files you have open and have been working on. So that the next time you activate the task, you see only the files that are most relevant to the task, for more info on Mylyn go <a title="Mylyn" href="http://www.eclipse.org/mylyn/" target="_blank">here</a>. Mylyn is integrated in the more recent editions of Eclipse, but there is a Mylyn trac plugin that allows you to create and view tickets in your trac repository. How nice is that? If someone reports a new bug, you can see it appear right in your IDE, work on it and close it, all from within Eclipse.</p>
<p>To get the Mylyn support working in trac you need to install and enable the xml-rpc plugin. As usual FreeBSD has a port for it.</p>
<pre>cd /usr/ports/www/trac-xmlrpc
make install clean</pre>
<p>Ubuntu users can run:</p>
<pre>easy_install -Z -U http://trac-hacks.org/svn/xmlrpcplugin/trunk # 0.11</pre>
<p>At the end of the install process keep a look out for the location where the python egg was installed, we need to copy that file to our plugins folder in the trac project. This was /usr/local/lib/python2.6/site-packages/TracXMLRPC-1.0.6-py2.6.egg on FreeBSD.</p>
<p>Edit the trac.ini file, under the [component] section add:</p>
<pre>tracrpc.* = enabled</pre>
<p>Now when you go to the admin section of your trac site you should see the xml-rpc plugin available under <em>Plugins</em>.</p>
<h3>Close and comment on trac tickets in your SVN commit messages</h3>
<p>You can have trac close and add comments to your tickets simply by including certain text triggers in your SVN commit messages, such as <em>fixes #231</em>, r<em>efs bug:29. </em>To get this working you need to include a special script in your svn repository location. First download this <a title="Trac post commit hook" href="http://trac.edgewall.org/browser/branches/0.11-stable/contrib/trac-post-commit-hook?format=txt" target="_blank">python script</a> from the trac web site. Save it in a location which is easily accessible, on FreeBSD I put the script in the trac share folder <em>/usr/local/share/trac</em>.</p>
<p>Now go to your svn repository location in the hooks folder you should see a lot of files with a .tmpl extension. One of them is post-commit.tmpl, we need to copy this and edit it as follows:</p>
<pre>cp post-commit.tmpl post-commit
edit post-commit</pre>
<p>Ignore all the comments, at the end make sure the file reads as below:</p>
<pre>TRAC_ENV="/usr/local/trac/[TracProjectName]"
REPOS="$1"
REV="$2"

/usr/local/bin/python /usr/local/share/trac/trac-post-commit.py -p "$TRAC_ENV" -r "$REV"
#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf</pre>
<p>Replace [TracProjectName] with your trac project name or change the path if yours is different. I specified the full path to the python command, on freebsd when this shell script is triggered the script does not inherit you environment PATH, so absolute paths to commands need to be specified, at least on FreeBSD anyway. Change the path of the trac-post-commit.py file to wherever you saved it. I commented out the mailer.py script, this is another post-commit script that you can run which sends an email detailing the commit. This script should be shipped with your subversion installation, on FreeBSD it is in <em>/usr/local/share/subversion/hook-scripts/mailer/mailer.py</em>.</p>
<p>Finally we need to make sure that the python script is executable and owned by the web user like everything else in the svn repository.</p>
<pre>chmod 755 post-commit
chown www post-commit</pre>
<p>Now when you do your next commit to the repository try closing or referencing one of the trac tickets. You can refer to a ticket by prefixing the ticket number with <em>#</em>, <em>ticket:</em>, <em>issue:</em> or <em>bug:</em>. You can close a ticket using by using a command prefix <em>close, closed, closes, fix, fixed, fixes</em> before the ticket reference. To comment on a ticket but not close it use any of these command prefixes: <em>addresses, re, references, refs</em> or <em>see</em>.</p>
<p>You can customise these commands or ticket references, just edit the trac-post-commit.py file, the following is what you&#8217;ll need to change:</p>
<pre>ticket_prefix = '(?:#|(?:ticket|issue|bug)[: ]?)'

    _supported_cmds = {'close':      '_cmdClose',
                       'closed':     '_cmdClose',
                       'closes':     '_cmdClose',
                       'fix':        '_cmdClose',
                       'fixed':      '_cmdClose',
                       'fixes':      '_cmdClose',
                       'addresses':  '_cmdRefs',
                       're':         '_cmdRefs',
                       'references': '_cmdRefs',
                       'refs':       '_cmdRefs',
                       'see':        '_cmdRefs'}</pre>
<p>So, thats all for now. Apparently you can also do git post-commit hooks as well, but as I am not using git that much I haven&#8217;t tried it out yet. Happy coding with your svn/git trac repositories.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.opencoder.co.uk/2010/03/trac-adding-git-mylyn-and-post-commit-hooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting up a svn trac server</title>
		<link>http://www.opencoder.co.uk/2010/01/setting-up-a-svn-and-trac-server/</link>
		<comments>http://www.opencoder.co.uk/2010/01/setting-up-a-svn-and-trac-server/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 21:27:24 +0000</pubDate>
		<dc:creator>Chris McDonald</dc:creator>
				<category><![CDATA[Servers]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.opencoder.co.uk/?p=118</guid>
		<description><![CDATA[It has been way too long since the last post, so here is something you might find useful. A couple of months back we noticed that our commercially hosted svn and trac repositories were becoming quite unresponsive and slow, which held up development albeit only slightly. Time is money as they say, so we decided [...]]]></description>
			<content:encoded><![CDATA[<p>It has been way too long since the last post, so here is something you might find useful.</p>
<p>A couple of months back we noticed that our commercially hosted svn and trac repositories were becoming quite unresponsive and slow, which held up development albeit only slightly. Time is money as they say, so we decided to cancel our commercial hosting and go for a local svn set up on our development server (just an old networked dell laptop, not very high specs at all). Our dev server is just a freebsd 7.1 install on an old dell laptop, which already had Apache, MySQL and PHP installed (FAMP server). For this guide you will need to have at least Apache installed (plus a few other port installs which I will detail below), but if you&#8217;re going to install Apache you might as well go all the way and have MySQL and PHP, see <a title="Creating a home webserver" href="http://www.opencoder.co.uk/2009/08/creating-a-home-web-server/" target="_blank">here</a> and <a title="Creating a home webserver part 2" href="http://www.opencoder.co.uk/2009/09/creating-a-home-web-server-part-2/" target="_blank">here</a> posts on this. This guide is mainly for FreeBSD, although steps should be similar for Ubuntu, although your installs are very different, where appropriate I&#8217;ll put the ubuntu alternative installation steps.</p>
<p>Assuming you have already set up your FAMP server, next steps are as follows:</p>
<h3>Install subversion</h3>
<p>Use the make options as defined below. At the time of writing I am installing subversion 1.6.6</p>
<pre>cd /usr/ports/devel/subversion
make install clean</pre>
<div id="attachment_119" class="wp-caption aligncenter" style="width: 430px"><img class="size-full wp-image-119" title="Subversion make options" src="http://www.opencoder.co.uk/wp-content/uploads/2010/01/Screen-shot-2010-01-03-at-16.30.05.png" alt="Subversion make options" width="420" height="292" /><p class="wp-caption-text">Subversion make options</p></div>
<p>This might take a while depending on how many dependencies need to be installed.</p>
<h3>Install trac</h3>
<p>Leave the options as they are or copy from below. At time of writing I am installing trac 0.11.5</p>
<pre>cd /usr/ports/www/trac
make install clean</pre>
<div id="attachment_135" class="wp-caption aligncenter" style="width: 428px"><img class="size-full wp-image-135" title="trac make options" src="http://www.opencoder.co.uk/wp-content/uploads/2010/01/Screen-shot-2010-01-08-at-21.33.05.png" alt="trac make options" width="418" height="290" /><p class="wp-caption-text">trac make options</p></div>
<h3>Install mod_python for apache</h3>
<p>From /usr/ports/www/mod_python3. Trac runs on python, the trac website neds to be handled by python so we need to install this apache module for the trac website(s) to work</p>
<pre>cd /usr/ports/www/mod_python3
make install clean</pre>
<p>Apache needs to be set up to enable the new mod_python module, so edit the httpd.conf file located in /usr/local/etc/apache22/httpd.conf add the following to the end of the LoadModule section if it is not there already.</p>
<pre>LoadModule python_module libexec/apache22/mod_python.so</pre>
<h3>Install Git (optional)</h3>
<p>There is a trac plugin to work with git repositiories if you prefer that to svn. I will not go into git now, see my next post for integrating trac with a git repository.</p>
<pre>cd /usr/ports/devel/git
make install clean</pre>
<div id="attachment_136" class="wp-caption aligncenter" style="width: 431px"><img class="size-full wp-image-136" title="git make options" src="http://www.opencoder.co.uk/wp-content/uploads/2010/01/Screen-shot-2010-01-08-at-21.33.36.png" alt="git make options" width="421" height="290" /><p class="wp-caption-text">git make options</p></div>
<p>You do not need perforce or cvs support unless you want it. I have never used either, only subversion. You will not be able to install the GUI Tools without install the X11 windowing system. If you have already got X11 installed, then I would recommend installing the GUI tools as they can help with visualising the current branch on the development tree, but if not then do not bother as X11 takes <em>AGES</em> to install and will bloat your system with hundreds of dependencies.</p>
<h3>Install the trac git plugin (optional)</h3>
<p>You can install the trac git plugin if you want to work with git repositories rather than svn.</p>
<pre>cd /usr/ports/www/trac-gitplugin
make install clean</pre>
<p>Ubuntu install steps for the all of the above are below(they are a lot simpler and quicker! Ubuntu uses pre-compiled files binary files and automatically sets up apache with the relevant modules loaded):</p>
<pre>sudo apt-get install subversion
sudo apt-get install libapache2-mod-python
sudo apt-get install libapache2-svn
sudo apt-get install trac
sudo apt-get install git-core
sudo apt-get install trac-git</pre>
<p>Now that we have all the programs we need lets go on to set up an svn repository.</p>
<h3>Create an SVN repository</h3>
<p>First we need to decide where we are going to have our svn repository, where ever you decide to keep it, you will need to make sure it is readable (and writable if you want to make checkins) by the apache user. For this example I am storing all my svn repositories under one location, /usr/local/svn. Make sure you are root and run the following:</p>
<pre>cd /usr/local
mkdir svn
cd svn
mkdir repositories
cd respositories
mkdir Test
svnadmin create Test
cd /usr/local/svn
htpasswd -c .passwd [Username]
[Enter password, and again]
chown -R www /usr/local/svn</pre>
<p>Ok, the steps above we created a location where we are going to store our svn repositories, we created one respository called Test, then we created an apache basic authentication access file which the svn server will use to authenticate the users. Finally we changed the owner of the entire svn directory over to the apache web user. Ubuntu users can perform the same steps, feel free to choose a different location than /usr/local, this is common practice in a freebsd system.</p>
<h3>Setup Apache to serve our SVN repository</h3>
<p>Now we need to tell apache which directory contains our svn repository. As root create the following file by running:</p>
<pre>touch /usr/local/etc/apache22/Includes/svn.conf</pre>
<p>Ubuntu users:</p>
<pre>touch /etc/apache2/conf.d/svn.conf</pre>
<p>Then edit that file and save the following in it:</p>
<pre>&lt;Location /svn&gt;<br style="padding: 0px; margin: 0px;" />DAV svn<br style="padding: 0px; margin: 0px;" />SVNParentPath /usr/local/svn/repositories<br style="padding: 0px; margin: 0px;" />AuthType Basic<br style="padding: 0px; margin: 0px;" />AuthName "Subversion access"<br style="padding: 0px; margin: 0px;" />AuthUserFile /usr/local/svn/.passwd<br style="padding: 0px; margin: 0px;" />Require valid-user<br style="padding: 0px; margin: 0px;" />&lt;/Location&gt;</pre>
<p>Now if you restart your apache webserver (apachectl restart) and navigate to <em>http://[server address]/svn/Tes</em>t you should be asked for your username and password. Once you have logged in you should see your empty repository!</p>
<h3>Create a trac repository</h3>
<p>Now we will create a trac repository, I will follow the same logic as for the svn repositories and keep all the trac repositories under /usr/local/trac. As root again run:</p>
<pre>cd /usr/local
mkdir trac
cd trac
mkdir Test
trac-admin Test initenv</pre>
<p>trac-admin is an interactive program and you will be asked a series of questions to set up the trac repository. You will have to enter or accept the default value (by pressing return) at the following prompts:</p>
<pre>Project Name [My Project]&gt; Test
Database connection string [sqlite:db/trac.db]&gt;
Repository type [svn]&gt;
Path to repository [/path/to/repos]&gt; /usr/local/svn/repositories/Test</pre>
<p>When you have finished change the owner of the trac folder to the apache web user:</p>
<pre>chown -R www /usr/local/trac</pre>
<p>The steps are again the same for Ubuntu users.</p>
<h3>Setup apache to serve our trac repository</h3>
<p>Apache needs to serve the trac repository using the mod_python module we installed earlier. To set this up, create the configuration file by running the following as root:</p>
<pre>touch /usr/local/etc/apache22/Includes/trac.conf</pre>
<p>Ubuntu users:</p>
<pre>touch /etc/apache2/conf.d/trac.conf</pre>
<p>Save the following text in the new file:</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;Location /trac/MyRepoName&gt;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">SetHandler mod_python</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">PythonHandler trac.web.modpython_frontend</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">PythonOption TracEnv /usr/local/trac/Test</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">PythonOption TracUriRoot /trac/Test</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">AuthType Basic</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">AuthName &#8220;trac access&#8221;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">AuthUserFile /usr/local/svn/.passwd</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Require valid-user</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 3074px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">&lt;/Location&gt;</div>
<pre>&lt;Location /trac/MyRepoName&gt;
SetHandler mod_python
PythonHandler trac.web.modpython_frontend
PythonOption TracEnv /usr/local/trac/Test
PythonOption TracUriRoot /trac/Test
AuthType Basic
AuthName "trac access"
AuthUserFile /usr/local/svn/.passwd
Require valid-user
&lt;/Location&gt;</pre>
<p>Now if you restart apache again by running apachectl restart and navigate to <em>http://[server address]/trac/Test</em> you should be asked to authenticate and see your trac site!</p>
<h3>Testing the SVN repository</h3>
<p>To test the repository we will checkout a working copy, in your users home directory, try the following:</p>
<pre>mkdir svnworkingcopy
cd svnworkingcopy
svn checkout http://[server address]/svn/Test . --username [username]
[Enter password]
svn mkdir trunk branches tags
svn commit -m "Checking in svn directory structure"</pre>
<p>Now if you go back to the trac site and click the <em>Timeline</em> button you should see the first commit with the message. Click on <em>Browse source</em> to see the directory structure we just created. You now have everything you need to work with your trac and svn repository and to start adding and committing your project code.</p>
<p>Look out for the next post which will detail a few more steps to get more out of your trac server setup including:</p>
<ul>
<li>Using a git repository instead by using the trac git plugin</li>
<li>A few extras steps that will help integrating your trac repository with the Eclipse Mylyn trac connector</li>
<li>A svn post-commit hook to automatically add comments or close your trac tickets, simply by referring to a ticket number in your svn commit messages</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.opencoder.co.uk/2010/01/setting-up-a-svn-and-trac-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

