# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$

PortSystem                  1.0

name                        websvn
version                     2.3.3
set file_id                 49056
categories                  www
platforms                   darwin
maintainers                 ryandesign
license                     GPL-2
supported_archs             noarch
homepage                    http://www.websvn.info/
master_sites                http://websvn.tigris.org/files/documents/1380/${file_id}

description                 web-based Subversion repository viewer in PHP

long_description            WebSVN offers a view onto your Subversion \
                            repositories designed to reflect the Subversion \
                            methodology. You can view the log of any file or \
                            directory and see a list of all the files changed, \
                            added or deleted in any given revision. You can \
                            also view the differences between two revisions of \
                            a file.

checksums                   sha1    8425f1a98fb92ad28f8b13227ce1d4c73a323c7e \
                            rmd160  a57c4a140494e53017b6646b602ec2d2ba096d82

depends_run                 port:php5-web \
                            port:php5-mbstring \
                            port:subversion

patchfiles                  patch-distconfig.php.diff
post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/include/distconfig.php
}

use_configure               no

build                       {}

destroot.keepdirs           ${destroot}${prefix}/www/${name}/cache
destroot {
    copy ${worksrcpath} ${destroot}${prefix}/www/${name}
    
    # Cache
    delete ${destroot}${prefix}/www/${name}/cache/tmp
    file attributes ${destroot}${prefix}/www/${name}/cache -owner www -group www
    xinstall -d ${destroot}${prefix}/var/cache
    ln -s ../../www/${name}/cache ${destroot}${prefix}/var/cache/${name}
    
    # Config
    xinstall -d ${destroot}${prefix}/etc/${name}
    ln -s ../../www/${name}/include/config.php ${destroot}${prefix}/etc/${name}
    ln -s ../../www/${name}/include/distconfig.php ${destroot}${prefix}/etc/${name}
    
    # Documentation
    xinstall -d ${destroot}${prefix}/share/doc
    move ${destroot}${prefix}/www/${name}/doc ${destroot}${prefix}/share/doc/${name}
    move ${destroot}${prefix}/www/${name}/changes.txt ${destroot}${prefix}/www/${name}/license.txt ${destroot}${prefix}/share/doc/${name}
    
    # Symlink into docroot
    xinstall -d ${destroot}${prefix}/www/htdocs
    ln -s ../${name} ${destroot}${prefix}/www/htdocs
}

post-activate {
    if {![file exists ${prefix}/www/${name}/include/config.php]} {
        ui_msg "To set up WebSVN, copy"
        ui_msg "${prefix}/www/${name}/include/distconfig.php to"
        ui_msg "${prefix}/www/${name}/include/config.php and then make changes."
    } else {
        ui_msg "You may need to update your config.php for any changes that have been made"
        ui_msg "in this version of WebSVN. Compare ${prefix}/www/${name}/include/config.php"
        ui_msg "with ${prefix}/www/${name}/include/distconfig.php."
    }
}

livecheck.type              regex
livecheck.url               ${homepage}download/
livecheck.regex             ${name}-(\[0-9.\]+)${extract.suffix}