logo
06/11/2009

I can haz mercurial on mai forge !

Ceci est ma suite du post de l'ami Bapt ici : .

Ici je vais ajouter Mercurial à brokk.

La chose est sous NetBSD avec pkgin d'amour.

Installation de mercurial :

# pkgin in mercurial
calculating dependencies for mercurial...
nothing to upgrade.
3 packages to be installed: libffi-3.0.8nb2 python25-2.5.4nb3 mercurial-1.3.1 (12M to download, 52M to install)
proceed ? [y/N] y
[snip]
processing local summary...
updating database: 100%
marking mercurial-1.3.1 as non auto-removeable
#

Compliqué hein ?

Pour nos dépots, on fera tout sous l'utilisateur hg et dois avoir un shell, en effet, ici le push via ssh sera utilisé :

groupadd hg
useradd -m -g hg -s /bin/sh hg

Configuration du hg serve en fastcgi.

Créer un /home/hg/web/ :

# mkdir /home/hg/web

Installer et configurer le hgwebdir.fcgi :

# cd /tmp
# ftp http://mercurial.selenic.com/release/mercurial-1.3.1.tar.gz
# gunzip mercurial-1.3.1.tar.gz
# tar xvf mercurial-1.3.1.tar
# cd mercurial-1.3.1/contrib
# cp hgwebdir.fcgi /home/hg/web/
# chmod +x /home/hg/web/hgwebdir.fcgi
# vim /home/hg/web/hgwebdir.fcgi

Ajouter au tout début apres le premier commentaire :

import os
os.chdir("/home/hg")

A la dernière ligne, modifier 'hgweb.config' en 'hgweb.conf'. Décomenter

os.environ["HGENCODING"] = "UTF-8"

Et ajouter juste en dessous

os.environ['HGRCPATH'] = 'hgrc'

Maintenant le lighttpd.

Activez les modules 'rewrite' et 'fastcgi' puis voici le vhost a utiliser :

$HTTP["host"] =~ "hg.monsuperdomaine.tld" {
    accesslog.filename = "/var/log/lighttpd/hg_brokk_etoilebsd_net_access"

    url.rewrite-once = ( "^(/hgwebdir.fcgi/.*)$" => "$1", "^(/.*)$" => "/hgwebdir.fcgi$1")

    fastcgi.server = (
        "/" => (
            "hgwebdir" => (
                "bin-path" => "/home/hg/web/hgwebdir.fcgi",
                "socket" => "/tmp/hg.socket",
                "check-local" => "disable",
            )
        )
    )
}

La config 'hgweb.conf' est la suivante :

# cat /home/hg/hgweb.conf
[collections]
/home/hg/public-repos  = /home/hg/public-repos

[web]
baseurl =
encoding = UTF-8
style   = monoblue
motd = Brokk at your service sir! - A <a href="http://brokk.etoilebsd.net/" target="_blank">Brokk forge</a> service.
allow_archive = gz zip bz2

Il nous reste le compte SSH de l'utilisateur 'hg' a configurer, on est toujours dans '/tmp/mercurial-1.3.1/' :

# cp hg-ssh /home/hg/
# chmod +x /home/hg/hg-ssh
# su hg
$ cd
$ pwd
/home/hg
$ ssh-keygen -t dsa
enter, enter, enter ...
$ ssh-keygen -t rsa
enter, enter, enter ...
$ cd .ssh
$ vim authorized_keys

On remplit 'authorized_keys' avec ce qui suit :

command="/usr/pkg/bin/python2.5 /home/hg/hg-ssh public-repos/mon_super_repos",no-port-forwarding,no-X11-forwarding,no-agent-forwarding ssh-dss BLAHBLAHSAYMAKLEEAMOIPOUET

Ici, public-repos/mon_super_repos peux être sous la forme public-repos/{repos1,repos2} ou private-repos/, le dossier private-repos/* ne sera pas vu via l'interface web.

Maintenant lancez votre lighttpd

# /etc/rc.d/lighttpd start

Puis accédez a votre url définie dans la config du lighttpd, et voila :)

UPDATES:

  1. Ajout encoding et paths dans le hgwebdir.fcgi (Merci geekounet)

Nom :
URL (optionel) :
Écrire ici: "i love freebsd"
Commentaires :

Pages : 1