Trac (subversion) a Ubuntu

Trac és un sistema integrat per gestionar projectes de software que proporciona:

  1. Interfície web pel sistema subversion.
  2. Gestió de bugs.
  3. Gestió de sol·licituds.
  4. Planificació en el temps.
  5. Generació de documentació estil wiki.

Instal·lació:

aptitude install trac libapache2-svn

Creem el fitxer de configuració per Apache “/etc/apache2/sites-available/trac” amb el contingut:

<VirtualHost *>
        ServerAdmin webmaster@localhost
        ServerName trac.example.com
        DocumentRoot /usr/share/trac/cgi-bin/
        <Directory /usr/share/trac/cgi-bin/>
                Options Indexes FollowSymLinks MultiViews ExecCGI
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        Alias /trac "/usr/share/trac/htdocs"

        <Location /trac.cgi>
            SetEnv TRAC_ENV_PARENT_DIR "/var/trac"
        </Location>

        DirectoryIndex trac.cgi
        ErrorLog /var/log/apache2/error.trac.log
        CustomLog /var/log/apache2/access.trac.log combined
</VirtualHost>

Descomentar del fitxer “/etc/apache2/apache2.conf” la línia:

# To use CGI scripts outside /cgi-bin/:
#
AddHandler cgi-script .cgi

Activem la configuració que acabem de crear i desactivem el site que configura Apache per defecte:

a2ensite trac
a2dissite default

Reiniciem apache:

/etc/init.d/apache2 restart

Creem el repositori subversion relacionat i afegim un projecte:

mkdir /var/svn
svnadmin create /var/svn
cd /tmp
mkdir projecte/
cd projecte/
echo Hello > Hola.cs
svn import . -m "Inici"  file:///var/svn/projecte
cd
rm -rf /tmp/projecte

Inicialitzem l’entorn per Trac:

cd /var/trac/
trac-admin /var/trac/projecte initenv

A les preguntes contestem:

Creating a new Trac environment at /var/trac/projecte

Trac will first ask a few questions about your environment
in order to initalize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.

Project Name [My Project]> El meu projecte

 Please specify the connection string for the database to use.
 By default, a local SQLite database is created in the environment
 directory. It is also possible to use an already existing
 PostgreSQL database (check the Trac documentation for the exact
 connection string syntax).

Database connection string [sqlite:db/trac.db]>

 Please specify the absolute path to the project Subversion repository.
 Repository must be local, and trac-admin requires read+write
 permission to initialize the Trac database.

Path to repository [/var/svn/test]> /var/svn/projecte

 Please enter location of Trac page templates.
 Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]>

Creating and Initializing Project
 Configuring Project
 ...

---------------------------------------------------------------------
Project environment for 'El meu projecte' created.

You may now configure the environment by editing the file:

  /var/trac/projecte/conf/trac.ini

If you'd like to take this new project environment for a test drive,
try running the Trac standalone web server `tracd`:

  tracd --port 8000 /var/trac/projecte

Then point your browser to http://localhost:8000/projecte.
There you can also browse the documentation for your installed
version of Trac, including information on further setup (such as
deploying Trac to a real web server).

The latest documentation can also always be found on the project
website:

  http://projects.edgewall.com/trac/

Congratulations!

Donem permisos per a que es pugui modificar el contingut del directori des de la web:

chown -R www-data /var/trac/projecte/

Ara ja es possible accedir a “http://localhost/” on es mostrarà un llistat de tots el projectes disponibles, en el nostre cas només hi haurà “El meu projecte”.

Per permetre accés per password cal afegir a “/etc/apache2/sites-available/trac” (abans de “”):

	<Location "/trac.cgi/*/login">
            AuthType Basic
            AuthName "Trac"
            AuthUserFile /etc/apache2/dav_svn.passwd
            Require valid-user
       </Location>

Crearem el fitxer “/etc/apache2/dav_svn.passwd” amb el usuaris “user1” i “user2”:

htpasswd2 -c /etc/apache2/dav_svn.passwd user1
htpasswd2 /etc/apache2/dav_svn.passwd user2

A cada usuari podem assignar-li una serie de permisos a Trac, per això utilitzarem la comanda trac-admin:

# trac-admin /var/trac/projecte/
Trac [/var/trac/projecte]> permission list
...
Trac [/var/trac/projecte]> permission add user1 TRAC_ADMIN
Trac [/var/trac/projecte]> quit

Al fer “permission list” es pot veure el llistat d’usuaris amb els seus permisos. L’usuari anonymous sempre existeix i representa tots els usuaris que no s’han identificat, si volguessim fer que tothom s’hagi d’identificar podríem treure tots el permisos a anonymous.

Per habilitar l’accés normal subversion (amb permís de lectura per tothom) cal afegir a “/etc/apache2/sites-available/trac” (abans de “”):

	<Location /svn/>
            DAV svn
            SVNPath /var/svn/
            AuthType Basic
            AuthName "Subversion Repository"
            AuthUserFile /etc/apache2/dav_svn.passwd
            <LimitExcept GET PROPFIND OPTIONS REPORT>
                Require valid-user
            </LimitExcept>
        </Location>

Els usuaris son els mateixos que per l’aplicació Trac, donat que aquests es defineixen al fitxer “/etc/apache2/dav_svn.passwd” tal i com ja hem vist.

Ara podríem fer una copia local del repositori amb:

svn checkout http://localhost/svn/projecte

3 thoughts on “Trac (subversion) a Ubuntu

  1. 🙁 en softcatala he estat intentant contactar amb ells, però m’escriu un robot, que trist! A part he escrit als fòrums i m’han esborrat comentaris, més trist encara!

Leave a Reply to Isabel Cancel reply

Your email address will not be published. Required fields are marked *