wiki:pm/Tracメモ

Version 2 (modified by toraneko, 54 years ago) (diff)

--

Tracとは?

Tracとは、オープンソースで開発されているバグトラッキングシステムです。まぁ、バグトラッキングシステムにもBuzillaをはじめ色々ありますが、Tracは次のような特徴があります。

  • シンプルなユーザインタフェース
  • バグ修正とSubversionのソースコードの連携
  • wikiの統合によるコミュニケーション機能
  • 強力なリンク機能。[34]#123などと書くだけで、Subversionのチェンジセットやチケットへリンクを貼ることができます。

Tracは、次のオープンソースプロジェクトで利用されています。

Ruby on RailsやSpringIDEなど新鋭のプロジェクトを中心に採用が進んでおり、今最も注目のバグトラッキングシステムと言えるでしょう。

参考リンク

インタアクトのサイトでは、tracを日本語化したtrac-jaが配布されています。また、マニュアルの日本語化も行っています。

Tracの拡張機能、マクロなどが投稿されているサイトです。

インストール

適当に作ったパッケージが http://ultimania.org/debian/にあります。/etc/apt/sources.listに次の行を追加し

 deb http://ultimania.org/debian/ ./
 deb http://www.backports.org/debian/ sarge-backports main contrib

apt-getでインストールしてください。

 # apt-get install trac python2.3-japanese-codecs

ここでは、Subversionのリポジトリで日本語を扱うために、python2.3-japanese-codecsをインストールしておきます。

依存関係でインストールできない場合

下記のパッケージも一緒にインストールしてみるとよい。

  • python2.3-subversion
  • python2.3-sqlite
  • python2.3-clearsilver

セットアップ

Tracを利用するには、SubversionのリポジトリとTracのデータベースを生成します。

Subversionのディレクトリの作成

 # svnadmin create /tmp/svn

Tracのプロジェクトの作成

 # rm -rf /tmp/trac
 # trac-admin /tmp/trac initenv
 Creating a new Trac environment at /tmp/trac
  
 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]> Project Ultimania          ☆プロジェクト名
  
  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]> /tmp/svn           ☆Subversionのリポジトリのパス
  
  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 
   trac.repository_dir 
   ...

次のようにやってもok。

 # trac-admin /tmp/trac initenv "Project Name" sqlite:db/trac.db /tmp/svn /usr/share/trac/templates

Tracの簡易起動

 # tracd -p 8081 /tmp/trac

これで、tracdを起動したホストの8081ポートへブラウザでアクセスすると、Tracを利用することができます。

PostgreSQLの利用

PythonからPostgreSQLを利用するpsycopg(Debianの場合python2.3-psycopgパッケージ)をインストールし、

conf/trac.iniファイルのdatabaseプロパティを下記のように設定する。

 database = postgres://<ユーザ名>:<パスワード>@localhost/<データベース名>

例えば、次のように記述

 database = postgres://trac:tracpass@localhost/trac

データベースを作成しておく必要があるが、下記のようにutf-8で作成する必要があるので注意。

 $ createdb --encoding utf-8 trac

Webから利用

CGI

Tracは簡易Webサーバが入っているとはいえ、ふつーはApacheを使います。Apacheで利用するには、設定ファイルに次のように記述します。

 <LocationMatch "/[[:alnum:]]+/login">
      AuthType Basic
      AuthName "Trac Authentication"
      AuthUserFile /home/trac/.htpasswd
      Require valid-user
 </LocationMatch>
 
 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi
 <Location "/trac">
    SetEnv TRAC_ENV "/tmp/trac"
 </Location>
ついでに、SVNのリポジトリの設定も記述
 <Location /svn>
    DAV svn
    SVNPath /tmp/svn
 </Location>

mod_python

cgiを使うと劇重だが、mod-pythonを使うとかなり早くなる。mod-pythonのインストールは、次の通り。

 # apt-get install libapache2-mod-python2.3

Apacheの設定は、上記の設定を次のように変更する。

 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi
 <Location "/trac">
 #  SetEnv TRAC_ENV "/tmp/trac"
    SetHandler mod_python
    PythonHandler trac.web.modpython_frontend
    PythonOption TracEnv /tmp/trac
    PythonOption TracUriRoot /trac
 </Location>

FastCGI

FastCGIは、アプリケーションプロセスをWebサーバと別に実行しておき、Webサーバとアプリケーションプロセスで通信する仕組みである。この方法もmod_pythonと同様に高速化できるが、より汎用的に作られている。 mod_fastcgiとmod_fcgidの2種類がある。mod_fcgidの方が新しく安定しているようなので、mod_fcgidを利用することをお勧めする。

mod_fcgid

 # apt-get install libapache2-mod-fcgid
 # a2enmod fcgid
/etc/apache2/mod-enabled/fcgid.conf
 <IfModule mod_fcgid.c>
 # TRAC_ENVもしくはTRAC_ENV_PARENT_DIRを設定
   DefaultInitEnv TRAC_ENV /home/trac/test
 #  DefaultInitEnv TRAC_ENV_PARENT_DIR /home/trac
   AddHandler fcgid-script .fcgi
   SocketPath /var/lib/apache2/fcgid/sock
 </IfModule>
DefaultInit
/etc/apache2/site-enabled/xxx 
 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.fcgi
 <Location "/trac">
 </Location>

mod_fastcgi

 FastCgiConfig -initial-env TRAC_ENV=/tmp/trac
 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.fcgi
 <Location "/trac">
 </Location>