ページ更新: 2008-10-23 (木) (3862日前)

関連: ソフト/Script言語/Python/WSGI

(2008-10-22 新規作成)

TracMercurialプラグイン、および、Apache 2.2.x + mod_wsgi + Mercurial のメモ。

目次

[編集]

情報源 #

[編集]

メモ #

[編集]

Debian 4.0 #

PythonでMercurialが使えるようになっているか?:

$ python -c 'import mercurial'
$

プラグインをチェックアウトしてインストールする:

$ svn co http://svn.edgewall.com/repos/trac/sandbox/mercurial-plugin-0.11
$ cd mercurial-plugin-0.11
$ sudo python setup.py install
running install
running bdist_egg
running egg_info
creating TracMercurial.egg-info
writing requirements to TracMercurial.egg-info/requires.txt
writing TracMercurial.egg-info/PKG-INFO
writing namespace_packages to TracMercurial.egg-info/namespace_packages.txt
writing top-level names to TracMercurial.egg-info/top_level.txt
writing dependency_links to TracMercurial.egg-info/dependency_links.txt
writing entry points to TracMercurial.egg-info/entry_points.txt
writing manifest file 'TracMercurial.egg-info/SOURCES.txt'
writing manifest file 'TracMercurial.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-i686/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/tracext
copying tracext/__init__.py -> build/lib/tracext
creating build/lib/tracext/hg
copying tracext/hg/backend.py -> build/lib/tracext/hg
copying tracext/hg/__init__.py -> build/lib/tracext/hg
creating build/bdist.linux-i686
creating build/bdist.linux-i686/egg
creating build/bdist.linux-i686/egg/tracext
creating build/bdist.linux-i686/egg/tracext/hg
copying build/lib/tracext/hg/backend.py -> build/bdist.linux-i686/egg/tracext/hg
copying build/lib/tracext/hg/__init__.py -> build/bdist.linux-i686/egg/tracext/hg
copying build/lib/tracext/__init__.py -> build/bdist.linux-i686/egg/tracext
byte-compiling build/bdist.linux-i686/egg/tracext/hg/backend.py to backend.pyc
byte-compiling build/bdist.linux-i686/egg/tracext/hg/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-i686/egg/tracext/__init__.py to __init__.pyc
installing package data to build/bdist.linux-i686/egg
running install_data
warning: install_data: setup script did not provide a directory for 'COPYING' -- installing right in 'build/bd
ist.linux-i686/egg'
copying COPYING -> build/bdist.linux-i686/egg
warning: install_data: setup script did not provide a directory for 'README' -- installing right in 'build/bdi
st.linux-i686/egg'
copying README -> build/bdist.linux-i686/egg
creating build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/PKG-INFO -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/SOURCES.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/dependency_links.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/entry_points.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/namespace_packages.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/requires.txt -> build/bdist.linux-i686/egg/EGG-INFO
copying TracMercurial.egg-info/top_level.txt -> build/bdist.linux-i686/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/TracMercurial-0.11.0.5-py2.4.egg' and adding 'build/bdist.linux-i686/egg' to it
removing 'build/bdist.linux-i686/egg' (and everything under it)
Processing TracMercurial-0.11.0.5-py2.4.egg
Copying TracMercurial-0.11.0.5-py2.4.egg to /usr/lib/python2.4/site-packages
Adding TracMercurial 0.11.0.5 to easy-install.pth file

Installed /usr/lib/python2.4/site-packages/TracMercurial-0.11.0.5-py2.4.egg
Processing dependencies for TracMercurial==0.11.0.5

リポジトリを作成する:

$ sudo mkdir /var/hg
$ sudo chown www-data:www-data /var/hg
$ sudo -u www-data hg init /var/hg/hgsandbox

Tracプロジェクトを作成する:

$ sudo -u www-data trac-admin /var/trac/hgsandbox initenv
Creating a new Trac environment at /var/trac/hgsandbox

Trac will first ask a few questions about your environment
in order to initialize 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]> hgsandbox

 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 type of version control system,
 By default, it will be svn.
 
 If you don't want to use Trac with version control integration,
 choose the default here and don't specify a repository directory.
 in the next question.

Repository type [svn]> hg

 Please specify the absolute path to the version control
 repository, or leave it blank to use Trac without a repository.
 You can also set the repository location later.

Path to repository [/path/to/repos]> /var/hg/hgsandbox

Creating and Initializing Project
 Installing default wiki pages

  :
  :

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

  http://trac.edgewall.org/

Congratulations!

Tracにアクセスすると、以下の警告が表示された:

Warning: リポジトリと同期できません(サポートされていないバージョン管理システム "hg です: 
適切なコンポーネントが見つかりません。該当するプラグインが有効に設定されているか
確認してください。)。詳細は Trac のログを参照してください。

プラグインを有効にする:

[components]
tracext.hg.* = enabled

これでTracの警告は消えた。

このTracプロジェクトの管理権限を得る:

$ sudo -u www-data trac-admin /var/trac/hgsandbox permission add adminuser TRAC_ADMIN

httpd.confにTrac用の認証を追加:

### trac
<Location "/trac/hgsandbox/login">
    AuthType Digest
    AuthName "DEFAULT_GROUP"
    AuthUserFile "/var/svn/DEFAULT_GROUP.htdigest"
    Require valid-user
</Location>

Tracのリポジトリブラウザにアクセスするとエラーが発生(内容は失念):

リポジトリになにか1つコミットしてやる:

$ cd /var/hg/hgsandbox/
$ sudo -u www-data touch .hgignore
$ sudo -u www-data hg add .hgignore
$ sudo -u www-data hg st .
A .hgignore

$ sudo -u www-data hg ci -m "initial" .hgignore .
No username found, using 'www-data' instead

これでTracリポジトリブラウザのエラーが消えた。

以下、作業中:

  • Mercurialへのアクセス
    • mod_wsgiで
      • Debian 4.0 + etch-backports に入ってるもの
      • 自分でビルドする
    • (代替1) cgiで
    • (代替2) リバースプロキシ (mod_proxy) + hgweb
  • 認証

メモ: 2008-10-24

HgWebDirStepByStep - Mercurial を見ながら、mod_wsgi経由の閲覧の設定をやってみた。

環境はDebian 4.0, Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_python/3.2.10 Python/2.4.4 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_wsgi/2.3

閲覧だけ、認証無し、ならこんな感じか。 [collections]で楽しようと思ったけどいまいちconfigの動作がわからんので[paths]でリポジトリを一個ずつ指定した。

/var/www/wsgi/hgwebdir.wsgi:

from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.hgwebdir_mod import hgwebdir

CONFIG = '/var/hg/public.config'
application = hgwebdir(CONFIG)

/var/hg/config:

#[collections]
#hgsandbox = /var/hg/hgsandbox # リポジトリhgsandboxのURLがhttp://localhost/hg/var/hg/hgsandboxになる。
# /var/hg/hgsandbox = /var/hg/hgsandbox  # 見つからなくなる
# hgsandbox = hgsandbox   # 500 Internal Server Error: OSError: [Errno 2] No such file or directory: 'hgsandbox'

[paths]
hgsandbox = /var/hg/hgsandbox

/etc/apache2/sites-available/trac:

WSGIScriptAlias /hg /var/www/wsgi/hgwebdir.wsgi