2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

EC2にKanonとtrac-code-comments-pluginをインストールする

Posted at

Kanonとは?

Kanon

Trac/Maven/Jenkinsを一括インストールするツール
(Trac LightningのLinux版)

Kanon LAB (公式サイトだが繋がらない?)
okamototk / KanonConductor — Bitbucket

trac-code-comments-plugin

Trac(Kanon)のリポジトリブラウザ上でコードに対するコメントを付けることが出来るようになるプラグイン
Automattic/trac-code-comments-plugin

Tracには他にも同様のプラグインがいくつかあるが、これが一番新しそうで、使いやすそうに見えた。
(リポジトリもGithubにあるし)

環境

使用環境

AWS EC2のRed Hat Enterprise Linux 7.0 (HVM), SSD Volume Type - ami-99bef1a9を利用する。

準備

yum updateとMercurial,gitのインストールをしておく。
(Kanon上のリポジトリとしてsvn,bazaarを使用する場合は併せてインストールしておく)

sudo yum update
sudo yum install -y hg git

Kanon インストール

BitBucketに書いてある手順どおりに。
okamototk / KanonConductor — Bitbucket

Kanon ソースの取得

BitBucketではMercurialを使用してクローンする。

hg clone https://bitbucket.org/okamototk/kanonconductor

Kanon インストール

コマンド一発で。

cd kanonconductor
sudo ./kanon-setup

幾つか質問されるので、それなりに答えるだけでインストール完了。
自分の環境では、/opt/kanonにKanonがインストールされた。
また、サンプルプロジェクトが/var/opt/kanon/trac/SampleProjectに作成されていた。

trac関連のコマンドを実行出来るようにするために/opt/kanon/binにパスを通しておく。

export PATH=/opt/kanon/bin:$PATH

Kanonにアクセス

インストールが完了した時点で、Kanonのhttpdによるサーブも完了しており、http://${IP}/tracでKanonプロジェクトにアクセスできる。

新たにKanonプロジェクトを作成したい場合はkanon-create-projectコマンドにより行う。
いくつかの質問に答えるだけでプロジェクトを作成できる。

trac-code-comments-pluginのインストール

Kanonのリポジトリブラウザでコードに対するコメントを残せるtrac-code-comment-pluginをインストールする。
Automattic/trac-code-comments-plugin

trac-code-comments-plugin ソースの取得

Githubよりクローンする。

git clone https://github.com/Automattic/trac-code-comments-plugin

trac-code-comment-plugin のインストール

git cloneしたソースよりeggファイルを作成する。
(python 2.4+ が必要)

cd trac-code-comments-plugin
python setup.py bdist_egg

これで、distディレクトリにeggファイルが作成されるので、このeggファイルを${TRAC_PROJECT}/plugins配下に移動する。
今回はKanonインストール時に作成されたSampleProjectにインストールする。

sudo mv dist/TracCodeComments-1.1.1-py2.6.egg /var/opt/kanon/trac/SampleProject/plugins
sudo chown apache:apache /var/opt/kanon/trac/SampleProject/plugins/TracCodeComments-1.1.1-py2.6.egg

これで、httpdを再起動すればインストールが完了するはずだが、自分の環境ではエラーとなった。

Traceback (most recent call last):
  File "/opt/kanon/lib/python2.6/site-packages/Trac-0.12.4.ja1-py2.6.egg/trac/web/api.py", line 446, in send_error
    data, 'text/html')
  File "/opt/kanon/lib/python2.6/site-packages/Trac-0.12.4.ja1-py2.6.egg/trac/web/chrome.py", line 835, in render_template
    template = self.load_template(filename, method=method)
  File "/opt/kanon/lib/python2.6/site-packages/Trac-0.12.4.ja1-py2.6.egg/trac/web/chrome.py", line 796, in load_template
    self.get_all_templates_dirs(), auto_reload=self.auto_reload,
  File "/opt/kanon/lib/python2.6/site-packages/Trac-0.12.4.ja1-py2.6.egg/trac/web/chrome.py", line 511, in get_all_templates_dirs
    dirs.extend(provider.get_templates_dirs() or [])
  File "build/bdist.linux-x86_64/egg/code_comments/web.py", line 25, in get_templates_dirs
    return [self.get_template_dir()]
  File "build/bdist.linux-x86_64/egg/code_comments/web.py", line 29, in get_template_dir
    return resource_filename(__name__, 'templates')
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 869, in resource_filename
    self, resource_name
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 1345, in get_resource_filename
    return self._extract_resource(manager, zip_path)
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 1352, in _extract_resource
    manager, os.path.join(zip_path, name)
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 1370, in _extract_resource
    self.egg_name, self._parts(zip_path)
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 949, in get_cache_path
    self.extraction_error()
  File "/opt/kanon/lib/python2.6/site-packages/distribute-0.6.14-py2.6.egg/pkg_resources.py", line 915, in extraction_error
    raise err
ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 13] Permission denied: '/var/opt/kanon/trac/.egg-cache'

The Python egg cache directory is currently set to:

  /var/opt/kanon/trac/.egg-cache

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

どうやら、eggファイルを展開する場合、.egg-cacheディレクトリを作成する必要があるらしい。
ので、apacheがアクセスできる.egg-cacheディレクトリを作成する。

sudo mkdir /var/opt/kanon/trac/.egg-cache
sudo chown apache:apache /var/opt/kanon/trac/.egg-cache

Kanonの上部メニューにCode Commentsメニューが表示されていればインストール完了。
(ログインする必要あり)

コードレビュー

  • リポジトリブラウザのコード上に表示されるコメントアイコンをクリック

スクリーンショット 2014-11-23 0.04.18.png

  • ダイアログが表示されるのでコメントを入力する(Trac Wiki記法が使える)

スクリーンショット 2014-11-23 0.04.34.png

  • 下記の形式でコメントが表示される(コメントを縮小表示はできなそう…)

スクリーンショット 2014-11-23 0.04.55.png

  • Code Commentメニューでは、作成されたコメント一覧を見ることができる

スクリーンショット 2014-11-23 0.05.08.png

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?