# -*- mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
# $Id: Portfile 57375 2009-09-10 08:16:41Z ryandesign@macports.org $

PortSystem 1.0

name            cgit
version         0.8.2.1
set git-version 1.6.3
categories      www devel
maintainers     sfiera openmaintainer
description     A fast web interface for the git source code management system
homepage        http://hjemli.net/git/cgit/
platforms       darwin
dist_subdir     git-core

long_description \
    cgit is an attempt to create a fast web interface for the git scm, using a \
    builtin cache to decrease server io-pressure. It can run on any \
    CGI-capable web server.

use_bzip2       yes
set cgit-dist   ${distfiles}
set git-dist    [suffix git-${git-version}]
distfiles       ${cgit-dist}:cgit ${git-dist}:git
master_sites    ${homepage}snapshot:cgit \
                http://www.kernel.org/pub/software/scm/git:git
checksums       ${cgit-dist} \
                    md5     33e56f0621e53327f89233c7ccb7d8be \
                    sha1    1c40de81530a3c0513bc963cc81f14685448f6f9 \
                    rmd160  2e83250130aa1d4f087c853567c794b58a24368c \
                ${git-dist} \
                    md5     a5e6165506cddd94954277cf81f44b14 \
                    sha1    1dab1068d1886828bdb512e9b809bc779de35609 \
                    rmd160  b496878b113ae8d13d2eaa1b65e4dd2d8e72834d

depends_lib     port:git-core \
                port:openssl \
                port:zlib \
                port:libiconv

post-extract {
    file delete ${worksrcpath}/git
    file rename ${worksrcpath}/../git-${git-version} ${worksrcpath}/git
}

post-patch {
    file copy ${filespath}/cgit.conf ${worksrcpath}/cgit.conf
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/cgit.conf
    reinplace "s|@GIT_VER@|${git-version}|g" ${worksrcpath}/cgit.conf
}

post-destroot {
    xinstall -m 444 ${worksrcpath}/cgitrc.5.txt ${destroot}${prefix}/etc/cgitrc.sample
    xinstall -m 700 -o www -g www -d ${destroot}${prefix}/var/cache/cgit
    destroot.keepdirs ${destroot}${prefix}/var/cache/cgit
}

use_configure   no
configure.ldflags-append -liconv
build.env       CFLAGS="${configure.cflags}" LDFLAGS="${configure.ldflags}"
destroot.env    CFLAGS="${configure.cflags}" LDFLAGS="${configure.ldflags}"

livecheck.type  regex
livecheck.url   ${homepage}
livecheck.regex {stable.>CGIT ([0-9.]+)}
