# $Id: Portfile,v 1.12 2006/04/13 21:52:37 markd Exp $

PortSystem 1.0
name		cvsweb
version		3.0.6
categories	devel www
maintainers	darwinports@opendarwin.org
description	WWW interface for CVS repositories
long_description	\
	FreeBSD-CVSweb is a WWW CGI script that allows remote users to \
	browse a CVS repository tree via web.  It can display the revision \
	history of a file, as well as diffs between revisions and \
	downloading the whole file.
homepage	http://www.freebsd.org/projects/cvsweb.html
platforms	darwin
master_sites    http://people.FreeBSD.org/~scop/cvsweb/ \
		ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/local-distfiles/scop/
checksums	md5 0e1eec962b1db00e01b295fff84b6e89

depends_build	port:perl5.8 \
		port:p5-ipc-run \
		port:p5-file-temp \
		port:p5-uri \
		port:p5-mime-types \
		port:p5-string-ediff \
		port:cvsgraph

configure	{}
build		{}

set cgi_path ""
set httpd_conf_path ""
set icons_path ""
set css_path ""

variant darwin {
	global cgi_path httpd_conf_path
	set cgi_path "/Library/WebServer/CGI-Executables/"
	set httpd_conf_path "/private/etc/httpd/"
	set icons_path "/Library/WebServer/icons/"
	set css_path "/Library/WebServer/css/"
}

variant freebsd {
        global cgi_path httpd_conf_path
        set cgi_path "/usr/local/www/cgi-bin/"
        set httpd_conf_path "/usr/local/etc/apache/"
        set icons_path "/usr/local/www/icons/"
        set css_path "/usr/local/www/css/"
}

# apache darwinport interop
        if {[ file exists ${prefix}/sbin/httpd]} {
                set cgi_path "${prefix}/www/cgi-bin/"
                set httpd_conf_path "${prefix}/etc/apache/"
                set icons_path "${prefix}/www/icons/"
                set icons_path "${prefix}/www/css/"
}


	destroot {
		file mkdir ${destroot}${cgi_path}
		file mkdir ${destroot}${httpd_conf_path}
		file mkdir ${destroot}${icons_path}
                file mkdir ${destroot}${css_path}
		xinstall -m 755 ${worksrcpath}/cvsweb.cgi ${destroot}${cgi_path}
		xinstall -m 644 ${worksrcpath}/cvsweb.conf ${destroot}${httpd_conf_path}
		eval xinstall -m 755 [glob ${worksrcpath}/icons/*] ${destroot}${icons_path}
                eval xinstall -m 755 [glob ${worksrcpath}/css/*] ${destroot}${css_path}

		reinplace "s|#!/usr/bin/perl|#!${prefix}/bin/perl|g" \
                        "${destroot}${cgi_path}/cvsweb.cgi"
                reinplace "s|/usr/local/etc/cvsweb/cvsweb.conf|${httpd_conf_path}cvsweb.conf|g" \
                        "${destroot}${cgi_path}/cvsweb.cgi"
                reinplace "s|/bin /usr/bin /usr/local/bin|/bin /usr/bin /usr/local/bin ${prefix}/bin ${prefix}/sbin|g" \
                        "${destroot}${cgi_path}/cvsweb.cgi"
}
