Subversionの導入

インストール

ここからsubversionのソースをダウンロードしてインストールする。
subversionをインストールする前にApacheのインストールをしておく。
またINSTALLファイルを読んで依存ライブラリを確認しておく。
Apacheと連携して、ブラウザからHTTPプロトコルリポジトリにアクセスするためにはneon(バージョン0.25以降)というライブラリが必要。またその際にSSL機能を使うのであればopensslも必要となる。

自分の環境にはopensslはインストール済みなのでneonのみインストールする。


# wget http://www.webdav.org/neon/neon-0.28.6.tar.gz
# tar xzvf neon-0.28.6.tar.gz
# cd neon-0.28.6
# ./configure --prefix=/usr/local/neon-0.28.6 --with-ssl
# make
# make install

subversionをインストールする。


# wget http://subversion.tigris.org/downloads/subversion-1.6.6.tar.gz
# tar xzvf subversion-1.6.6.tar.gz
# cd subversion-1.6.6
# ./configure
# --prefix=/usr/local/subversion-1.6.6
# --with-apxs=/usr/local/httpd/bin/apxs
# --with-apr=/usr/local/apr-httpd
# --with-apr-util=/usr/local/apr-util-httpd
# --with-neon=/usr/local/neon-0.28.6
# --with-ssl
configureを実行すると以下のエラーが出た。

An appropriate version of sqlite could not be found. We recommmend
3.6.13, but require at least 3.4.0.
Please either install a newer sqlite on this system

or

get the sqlite 3.6.13 amalgamation from:
http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
unpack the archive using tar/gunzip and copy sqlite3.c from the
resulting directory to:
/usr/local/src/subversion-1.6.6/sqlite-amalgamation/sqlite3.c
This file also ships as part of the subversion-deps distribution.

configure: error: Subversion requires SQLite

エラーメッセージに従ってsqlite3.cを取得してコピーする。

$ wget http://www.sqlite.org/sqlite-amalgamation-3.6.13.tar.gz
$ tar xzvf sqlite-amalgamation-3.6.13.tar.gz
# mkdir /usr/local/src/subversion-1.6.6/sqlite-amalgamation
# cp sqlite-3.6.13/sqlite3.c /usr/local/src/subversion-1.6.6/sqlite-amalgamation/
再びconfigureを実行すると無事終了したが以下のようにberkeley-dbが無いという警告が出た。

configure: WARNING: we have configured without BDB filesystem support


You don't seem to have Berkeley DB version 4.0.14 or newer
installed and linked to APR-UTIL. We have created Makefiles which
will build without the Berkeley DB back-end; your repositories will
use FSFS as the default back-end. You can find the latest version of
Berkeley DB here:
http://www.oracle.com/technology/software/products/berkeley-db/index.html

berkeley-dbは使わないので警告は無視して続行する。

# make
ここで今度は以下のエラー。

/usr/bin/ld: cannot find -lexpat
expatをインストールする。

# wget http://sourceforge.net/projects/expat/files/expat/2.0.1/expat-2.0.1.tar.gz/download
# tar expat-2.0.1.tar.gz
# cd expat-2.0.1
# ./configure --prefix=/usr/local/expat-2.0.1
# make
# make install
再びconfigure&makeしても上のエラーが消えないので
LD_LIBRARY_PATH環境変数にexpatライブラリのパスを指定するとmakeが通った。
最終的には以下のように実行。

# cd /usr/local/src/subversion-1.6.6
# make clean
# export LD_LIBRARY_PATH=/usr/local/export-2.0.1/lib/
# ./configure
# --prefix=/usr/local/subversion-1.6.6
# --with-apxs=/usr/local/httpd/bin/apxs
# --with-apr=/usr/local/apr-httpd
# --with-apr-util=/usr/local/apr-util-httpd
# --with-neon=/usr/local/neon-0.28.6
# --with-ssl
# make
# make install

設定

シンボリックリンクを張る。


# ln -s subversion-1.6.6 subversion
環境変数の設定。~/.bash_profileに以下を追加。

export PATH=$PATH:/usr/local/subversion/bin
export SVN_EDITOR=/usr/bin/vim
Apache連携用のモジュールを確認してみる。

$ ls -lt /usr/local/httpd/modules
mod_authz_svn.so
mod_dav_svn.so
libphp5.so
mod_dav_fs.so
mod_rewrite.so
mod_dav.so
mod_proxy_ajp.so
mod_proxy_balancer.so
mod_ssl.so
mod_proxy.so
mod_proxy_connect.so
mod_proxy_ftp.so
mod_proxy_http.so
mod_authz_svn.soとmod_dav_svn.soというモジュールが作成されている。
また、svn --versionとコマンド打つと組み込まれた機能を確認できる。

以下のリポジトリアクセス (RA) モジュールが利用できます:

* ra_neon : Neon を利用して WebDAV (DeltaV) プロトコルリポジトリにアクセスするモジュール。
- 'http' スキームを操作します
- 'https' スキームを操作します
* ra_svn : svn ネットワークプロトコルを使ってリポジトリにアクセスするモジュール。
- 'svn' スキームを操作します
* ra_local : ローカルディスク上のリポジトリにアクセスするモジュール。
- 'file' スキームを操作します

/usr/local/httpd/conf/extra/httpd-svn.confを作成して以下を記述。


DAV svn
SVNPath /var/svn/repo
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /usr/local/httpd-2.2.9/conf/.webdav_passwd
Require valid-user
BrowserMatch "MSIE" AuthDigestEnableQueryStringHack = On

httpd.confに以下を記述してhttpd-svn.confを読み込ませる。

# Subversion
Include conf/extra/httpd-svn.conf

インポートとチェックアウト

subversionリポジトリ用のディレクトリを作成する。


# mkdir /var/svn/
# svnadmin create --fs-type fsfs /var/svn/repo
# chown -R httpd:httpd /var/svn/repo
--fs-typeはリポジトリのフォーマットを指定する。
省略するとデフォルトが適用される。以前はBerkely DBがデフォルトだったが、バージョン1.2からFSFSがデフォルトになった。


初期インポートする。

$ svn import myapp/ http://localhost/svn/myapp/trunk
実行すると以下のような注意が出た。

                                                                                                                                            • -

ATTENTION! Your password for authentication realm:

http://localhost:80 Subversion repository

can only be stored to disk unencrypted! You are advised to configure
your system so that Subversion can store passwords encrypted, if
possible. See the documentation for details.

You can avoid future appearances of this warning by setting the value
of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
'/home/totemn/.subversion/servers'.

                                                                                                                                            • -

暗号化されていないパスワードを保存しますか (yes/no)?

./subversion/serversに以下の行を加える。

store-plaintext-passwords=no
リポジトリの中身を確認してみる。

# svnlook tree /var/svn/repo/
> myapp/
> trunk/
data1
data2
チェックアウトする。

# svn checkout http://localhost/svn/myapp

コマンドに与えるパスについて

svnコマンドに与えるパスは、

  • file:/// (ローカル)
  • http:// (リモート)

のいずれかのURL形式で与える。
しかし、svnadminやsvnlookは上のような指定はできない。
単純に、/var/svn/repoのようにファイルシステム形式で指定する。