アクセスコントロールとかリポジトリ管理とかを簡単にやりたくて調べていたら見つけました。
http://www.lshift.net/mercurial-server.html
ソースコードがあったのでダウンロード&インストール
wget http://dev.lshift.net/paul/mercurial-server/mercurial-server_1.0.1.tar.gz tar zxvf mercurial-server_1.0.1.tar.gz cd mercurial-server_1.0.1.orig python setup.py build python setup.py install
root(管理者?)の公開鍵を設定しておく
mkdir -p /etc/mercurial-server/keys/root cp pubkey /etc/mercurial-server/keys/root/admin.pub chmod 644 /etc/mercurial-server/keys/root/admin.pub
hgユーザになって(なければ作って)初期化
su - hg /usr/init/hginit cp: cannot stat `/init/dot-mercurial-server': No such file or directory /usr/init/hginit /usr
repos/hgadminが出来ている。
設定を反映する。
sudo -u hg refresh-auth
hgユーザーの~/.ssh/authorized_keysにcommand=”hg-ssh…”が追加されている。
cat .mercurial-server # WARNING: a .mercurial-server file in your home directory means # that refresh-auth can and will trash your ~/.ssh/authorized_keys file. [paths] repos = ~/repos authorized_keys = ~/.ssh/authorized_keys keys = /etc/mercurial-server/keys:~/repos/hgadmin/keys access = /etc/mercurial-server/access.conf:~/repos/hgadmin/access.conf [env] # Use a different hgrc for remote pulls - this way you can set # up access.py for everything at once without affecting local operations HGRCPATH = /etc/mercurial-server/remote-hgrc.d
ディレクトリはrepos/projectnameだけど、リモートアクセスはssh://hg@example.com/projectnameとかになるのかな。
/etc/mercurial-server/access.confにルールを記述
init user=root/** deny repo=hgadmin write user=users/**
試しにローカルからリモートに向けてclone
mkdir hoge cd hoge hg init hg clone . ssh://hg@example.com/hoge ssh example.com remote$ ls repos hgadmin hoge
OKですね。
hoge/.hg/hgrcとか編集してupdateするとかhooks設定とかできます
例えばこうとか。
[hooks] changegroup.aaaab_update = hg update -C default > /dev/null
hgadminをcloneしてユーザー追加。さっきcloneしたhogeプロジェクトに書き込めるようにする。
hg clone ssh://hg@example.com/hgadmin cd hgadmin mkdir -p keys/users touch access.conf cp hogeuser.pub keys/users/hoge.pub vi access.conf write repo=hoge user=users/hoge.pub hg add hg ci -m 'add user' hg push
もっといろいろ設定できるし、しなきゃいけない気がするけど、あとは下記URL参照ってことで。
http://dev.lshift.net/paul/mercurial-server/docbook.html