* [[Subversion]]
CVSに変えてそろそろこちらに移行したいなーと思っていました。
#contents
** インストール
まずhttp://subversion.tigris.org/project_packages.htmlのhttp://subversion.tigris.org/svn_1.2_releasenotes.htmlからsubversion-1.2.3.tar.gzをダウンロードしました。またhttp://www.oracle.com/database/berkeley-db.htmlより、Berkeley DBをダウンロードします。
tar xzvf db-4.3.28.tar.gz
cd db-4.3.28/build_unix
../dist/configure --enable-compat185
後々めんどくさいことしたくない場合は、
../dist/configure --enable-compat185 --prefix=/usr
make
make install
引数の--enable-compat185はBerkeley DB 1 との互換性を保ちます。またleopardの場合は
../dist/configure --enable-compat185 --prefix=/usr
としてやりました。
distで./configureをたたくと下記のエラーがでますので注意してください。
Berkeley DB should not be built in the top-level or dist directories
では/etc/ld.so.conf.dのファイルに/usr/local/BerkeleyDB.4.3/libを追加して、ldconfigしておきます。ついでに/usr/local/apache2/libも追加しておきました。では[[Apache]]のインストールにしたがって、WebDAV用にインストールしておきます。終わりましたら、Subversionです。3/28現在1.4.6ですね。
tar xzvf subversion-1.2.3.tar.gz
cd subversion-1.2.3
./configure --with-apr=/usr/local/apache2 --with-apr-util=/usr/local/apache2
--with-berkeley-db=/usr/local/BerkeleyDB.4.3
make
make install
INSTALLをみていると、autoconf 2.50 or newer (Unix only)とあるので、whichやfindでしらべておきます。apache2.2ですとconfigureでBerkeleyのところでエラーがでました。subversion1.3でも同じでした。ちなみにこんなエラーです。
configure: error: APR-UTIL was installed independently, it won't be
possible to use the specified Berkeley DB
この時、フォルダにaprとapr-utilがいるので、--with-aprと--with-apr-utilを外して再度やってみましょう。aprとapr-utilがない場合は、subversion-deps-1.4.6.tar.gzをダウンロードして解凍しておきましょう。
aprは1.2ではなく0.9です。するとmakeで
configure: error: APR-UTIL was installed independently,
ってエラーがでました。しょうがないので、
apr/include/apr.h
を開き
#define APR_HAS_SENDFILE 0
にしてmakeしました。
またlibtool 1.4 or newer (Unix only)なので、これもあれば、--versionでバージョンを確認しておきます。またhttp://www.webdav.org/neon/よりneonという HTTP and WebDAV client libraryをダウンロードしておきます。と思ったら、
The source code is included with the latest Subversion tarball
とあり、たしかにneonのディレクトリがあるので、いらないのかな? 新しいバージョンと入れ替えておけばいいのでしょうか。とりあえず、インストールしてみたがよくわかりません。
tar xzvf neon-0.25.3.tar.gz
cd neon-0.25.3
./configure
make
make install
ではhttpd.confを見てみると
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
が追加されていたので、念のためldconfigとhttpdを再起動しておきました。ではxinetdに登録しておきます。
useradd -m -d /home/svn -s /bin/false svn
でユーザを作っておいて
/usr/local/bin/svnadmin create /home/hoge/svn-rep
でレポジトリを作ったら、
chown -R svn:svn /home/hoge/svn-rep
で権限を変更しておきます。ではxinetd.dで
# default: on
# description: svnserve
service svn
{
socket_type = stream
wait = no
user = svn
server = /usr/local/bin/svnserve
server_args = -i -r /home/hoge/svn-rep
log_on_failure += USERID
disable = no
}
このserver_argsの-iはinetd モードで、-rはサービスを提供するディレクトリのルートです。sshでやる場合は、-i -r /home/hoge/svn-repを-i -t -r /home/hoge/svn-repにして、
chmod -R 770 /home/hoge/svn-rep
chmod g+s /home/hoge/svn-rep/db
では、httpでやるには
<Location /svn>
DAV svn
SVNPath /usr/local/svn-rep
AuthType Basic
AuthUserFile /etc/auth.conf
AuthName test
require valid-user
</Location>
/etc/auth.confは[[Apache]]の認証を参照して、作成しておきましょう。認証は好みで。この例のBasicもどうかと思いますが。sslでなければ、せめてDigest承認ぐらいに。ここで SVNPath /usr/local/svn-repとしてますが、1つのレポジトリに複数のディレクトリがる場合は、片方を直すとどちらもバージョンがあがっていきます。これがいやな場合は、たとえば
mkdir /usr/local/svn-rep
/usr/local/bin/svnadmin create /usr/local/svn-rep/rep1
/usr/local/bin/svnadmin create /usr/local/svn-rep/rep2
としておいて、(権限はapacheからみえるように)
<Location /svn>
DAV svn
SVNParentPath /usr/local/svn-rep
AuthType Basic
AuthUserFile /etc/auth.conf
AuthName test
require valid-user
</Location>
にしておき、http://localhost/svn/rep1とかでアクセスします。
では、Apacheを再起動しましょう。
Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server: libsvn_repos-1.so.0: cannot open shared object file: No such file or directory
とエラーがでる場合は、/etc/ld.so.conf.dに/usr/local/libを追加して(libsvn_repos-1.so.0が/usr/local/libにいれば)、ldconfigしておきましょう。また
Cannot load /usr/local/apache2/modules/mod_dav_svn.so into server: /usr/local/apache2/modules/mod_dav_svn.so: undefined symbol: dav_xml_get_cdata
とでる場合は、Apacheのコンパイルで--enable-dav=yesを指定しましょう。後はパーミッションはきちんとしておきましょう。Apacheを起動しているユーザで参照できるように。
クライアントは
http://tortoisesvn.tigris.org/download.htmlからOfficial version for Win2k/XPとLanguage Packsを落としました。TortoiseSVNです。http://tortoisesvn.bluegate.org/Help/dailyuseguide.htmlにわかりやすい使い方がありました。インストール後、追加したい場合は、exploreからそのフォルダで右クリックして、インポートします。プロジェクト名は
プロジェクト名/trunk
プロジェクト名/branches
プロジェクト名/tags
とするみたいです。svnserveの場合は、(サーバのIPが仮に192.168.1.2として)
svn://192.168.1.2/project1/trunk
みたいな感じでリポジトリURLを指定します。sshの場合は、そのユーザ(hogeuser)で[[ssh]]のssh2にしたがってauthorized_keysを作り、
svn+ssh://hogeuser@192.168.1.2/home/hoge/svn-rep/project1/trunk
とします。間違っていると
No access allowed to this repository
や
Permission denied
とエラーが表示されます。httpの場合は、
http://192.168.1.2/svn
**svnserve.conf
リポジトリを作成しましたら、その中にconf/svnserve.confがあります。
# [general]
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
# anon-access = read
# auth-access = write
となってますが、
[general]
anon-access = none
auth-access = write
にしてます。頭のスペースは要りません。anonはanonymousで不特定の場合です。
後はユーザを指定してやります。#password-db = passwdの#をとり、同じディレクトリにあるpasswdファイルを編集します。
[users]
hoge = hogepass
hoge2 = hogepass2
**リポジトリ作成
/usr/local/bin/svnadmin create /home/hoge/svn-rep
**チェックアウト
svn checkout svn://192.168.1.2:3690/project1/trunk
checkoutはcoでもよい。
**python
pythonから呼び出したい場合に。subversion/bindings/swig/INSTALLを読んでみて、
wget http://switch.dl.sourceforge.net/sourceforge/swig/swig-1.3.25.tar.gz
tar xzvf swig-1.3.25.tar.gz
cd swig-1.3.25
./configure --with-python=/usr/local/bin/python
make
make install
subversionのソースを展開したディレクトリで、
make install-swig-py
すると/usr/local/lib/svn-pythonに2つディレクトリがあるので、
cp -a * /usr/local/lib/python2.4/site-packages/
ldconfig
**cvs2svn
http://cvs2svn.tigris.org/よりダウンロードしましょう。
**windows
http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
より svn-win32-1.4.2.zipをダウンロードしました。あとは展開します。
ここではクライアントで使います。あとは文字化けしますので、変数をセットしておきます。
set APR_ICONV_PATH=展開したフォルダ\iconv
binにsvn.exeがいますので使いましょう。
プロキシの設定をする場合は、
C:\Documents and Settings\ユーザ名\Application Data\Subversion
にserversファイルを作成し、
[global]
# http-proxy-exceptions = *.exception.com, www.internal-site.org
# http-proxy-host = defaultproxy.whatever.com
# http-proxy-port = 7000
# http-proxy-username = defaultusername
# http-proxy-password = defaultpassword
# http-compression = no
# No http-timeout, so just use the builtin default.
# No neon-debug-mask, so neon debugging is disabled.
# ssl-authority-files = /path/to/CAcert.pem;/path/to/CAcert2.pem
このあたりを修正します。
**TIPS
***Can't open activity db:Permission Denied
レポジトリ/dav
レポジトリ/db
の権限を見直してみましょう。
***コミット時のメール
[[Subversionで日本語ログ入りのcommitメールを送る>http://vimrc.hp.infoseek.co.jp/svn_commit_jp.html]]~
[[Subversionコミット時メール送信とTracチケットの自動クローズ>http://yamashita.dyndns.org/blog/247]]~
***編集時にロック
svn:needs-lockをプロパティに設定します。
[[編集時にロックの取得を必須にするには>http://www.gside.org/Gentoo/subversion/subversion_tips.html#A4]]
** リンク
http://kobe.cool.ne.jp/oppama/misc/subversion2.html~
http://idm.s9.xrea.com/ratio/2005/01/14/000169.html~
http://www.gside.org/Gentoo/subversion/subversion.html~
[[ソースコードの管理をしよう(Subversion編)>http://www.itmedia.co.jp/enterprise/articles/0707/20/news040.html]]~
[[SubversionとTracでファイル管理の“迷宮”から脱出>http://www.atmarkit.co.jp/fjava/rensai4/devtool02/devtool02_1.html]]~
** 参考書籍
** コメント
--#comment