kanonをmacへインストールしようとしてみた2(動

なんか、いろいろあって、もうちょっと頑張ってみることにした。
macで開発環境作ったことなかったし、portになれておくのもいいのかも?

というわけで、昨日のブログの続き。
macports用のリストを作って、kanon-setupに組み込むところからです。

pkglist.macの作成

  • pkglist.macを作成して、すでにインストール済のmod_wsgiに加え、他のosリストを参考にしながら必要そうなパッケージを追加
    • unicode_pathオプションはもしかしたらない方がいいかも?

mod_wsgi
mercurial
subversion +mod_dav_svn +unicode_path
bzr
sqlite3

  • OSがmacのときは、pkglist.macを使ってportsのコマンドを実行するようにkanon-setupを修正
    • 修正した箇所はこんな感じ
### install ubuntu package
if [ "$OS" = 'ubuntu' ]
then
    apt-get update
    apt-get -y install `cat pkglist.ubuntu`
elif [ "$OS" = 'rhel' ]
then
    yum -y install `cat pkglist.rhel`
elif [ "$OS" = 'mac' ]
then
    port selfupdate
    port install `cat pkglist.mac`
fi

/opt/kanon/bin/kanon-create-project でエラーが起きるので対応(直接編集しちゃったけど、mac版作った方がいいかも)

  • macapacheは、グループが"_www"、ユーザーは"admin"で動くっぽいのでchownコマンドをそのように修正
    • グループ名とユーザー名は、若干あやしいのでもうちょっとしっかり調べた方がいいかも
    • あと、修正が難しかったので、今回、この部分はmacでしか動かないように直しちゃいました
which apache2 >& /dev/null
if [ $? = 0 ]
then
    APACHE_USER=www-data
else
    which httpd >& /dev/null
    if [ $? = 0 ]
    then
        APACHE_USER=apache
    else
        echo "Apacheが見つかりません。Apacheをインストールしてください。"
        exit    fi
fi

//mac用に設定
APACHE_USER=admin
APACHE_GROUP=_www
  • chownがエラーになるので、該当箇所を修正
    • リポリトリのchown
# リポジトリ作成

if [ "$REPO_TYPE" = 'hg' ]
then
   hg init $KANON_VAR/hg/$PROJECT_NAME
   chown -R $APACHE_GROUP:$APACHE_USER $KANON_VAR/hg/$PROJECT_NAME
elif [ "$REPO_TYPE" = 'svn' ]
then
   svnadmin create $KANON_VAR/svn/$PROJECT_NAME
   cp $KANON_CONFIG/vcs-template/svn/* $KANON_VAR/svn/$PROJECT_NAME/hooks
   chown -R $APACHE_GROUP:$APACHE_USER $KANON_VAR/svn/$PROJECT_NAME
elif [ "$REPO_TYPE" = 'bzr' ]
then
   bzr init-repo $KANON_VAR/bzr/$PROJECT_NAME
   bzr init $KANON_VAR/bzr/$PROJECT_NAME/trunk
   chown -R $APACHE_GROUP:$APACHE_USER $KANON_VAR/bzr/$PROJECT_NAME
elif [ "$REPO_TYPE" != '' ]
then
   echo "Unsupported repository type: " $REPO_TYPE
   exit
fi
    • トラックのプロジェクトのパスのchown
chown -R $APACHE_GROUP:$APACHE_USER $TRAC_PROJECT_PATH

mac用のhttpd.confを作成

  • apacheの起動で以下のエラーが発生します

Unknown DAV provider: svn

  • なんで、httpd.conf.rhelをもとにhttpd.conf.macを作成し、ファイルの先頭にmod_dav_svn.soのロードを追加

LoadModule dav_svn_module modules/mod_dav_svn.so

  • で、再度実行すると、今度は以下のようなエラーメッセージが表示されます

Invalid command 'AuthzSVNAccessFile', perhaps misspelled or defined by a module not included in the server configuration

  • mod_authz_svnが必要だっていわれているみたいですね。なんで、もう1行追加します

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

  • で、apacheを再起動して、http://localhost/trac/[projectname] にアクセスしたときに、以下のような画面が表示されます

Traceback (most recent call last):
File "build/bdist.macosx-10.6-universal/egg/trac/web/api.py", line 436, in send_error
data, 'text/html')
File "build/bdist.macosx-10.6-universal/egg/trac/web/chrome.py", line 832, in render_template
template = self.load_template(filename, method=method)
File "build/bdist.macosx-10.6-universal/egg/trac/web/chrome.py", line 793, in load_template
self.get_all_templates_dirs(), auto_reload=self.auto_reload,
File "build/bdist.macosx-10.6-universal/egg/trac/web/chrome.py", line 506, in get_all_templates_dirs
dirs.extend(provider.get_templates_dirs() or [])
File "build/bdist.macosx-10.6-universal/egg/trac/web/chrome.py", line 484, in get_templates_dirs
pkg_resources.resource_filename('trac', 'templates'),
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 841, in resource_filename
self, resource_name
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1311, in get_resource_filename
return self._extract_resource(manager, zip_path)
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1318, in _extract_resource
manager, os.path.join(zip_path, name)
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 1332, in _extract_resource
self.egg_name, self._parts(zip_path)
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 921, in get_cache_path
self.extraction_error()
File "/opt/kanon/lib/python2.6/setuptools-0.6c9-py2.6.egg/pkg_resources.py", line 887, 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.

もっとスムーズに行くかと思ってたけど、意外と道のり長いな。。。
とりあえず、エラーで気になるのは、以下の箇所

Permission denied: '/var/opt/kanon/trac/.egg-cache'

次やるとしたら、apacheのユーザーまわりと、pythonまわりみてみる感じか。
続く?