# -*- 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
PortGroup                   xcode 1.0

name                        PCLauncher
version                     0.0.3-75358
categories                  games
maintainers                 ryandesign
homepage                    http://plasmaclient.servegame.org/

description                 launcher for PlasmaClient

long_description            ${name} verifies your Myst Online: URU Live again \
                            username and password, downloads the secure files \
                            if necessary, and then launches PlasmaClient.

fetch.type                  svn
svn.url                     http://svn.macports.org/repository/macports/users/ryandesign/${name}
svn.revision                [lindex [split ${version} -] 1]
worksrcdir                  ${name}

# Use a working copy so the Xcode project can insert the current revision into the about box
svn.method                  checkout

depends_lib                 port:libhsplasma

depends_run                 port:PlasmaClient \
                            port:Drizzle

depends_skip_archcheck      PlasmaClient Drizzle

post-extract {
    foreach app {PCDownloader PCExtractor} {
        copy ${filespath}/${app}.in ${worksrcpath}/${app}
    }
}

patchfiles                  patch-LoginWindowController.m.diff \
                            patch-PCLauncher.xcodeproj-project.pbxproj.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/LoginWindowController.m ${worksrcpath}/PCLauncher.xcodeproj/project.pbxproj ${worksrcpath}/PCDownloader ${worksrcpath}/PCExtractor
}

post-destroot {
    fs-traverse dir ${destroot} {
        if {[file isdirectory ${dir}]} {
            file attributes ${dir} -permissions u+w
        }
    }
    foreach app {PCDownloader PCExtractor} {
        xinstall -d ${destroot}${applications_dir}/PCLauncher.app/Contents/Resources/${app}.app/Contents/MacOS
        xinstall ${worksrcpath}/${app} ${destroot}${applications_dir}/PCLauncher.app/Contents/Resources/${app}.app/Contents/MacOS/${app}
    }
    foreach app {PCAuthenticator PlasmaClient} {
        xinstall -d ${destroot}${applications_dir}/PCLauncher.app/Contents/Resources/${app}.app/Contents/MacOS
        ln -s ${prefix}/bin/PlasmaClient ${destroot}${applications_dir}/PCLauncher.app/Contents/Resources/${app}.app/Contents/MacOS/${app}
    }
}

set docdir ${prefix}/share/doc/PlasmaClient

notes "
To start PlasmaClient, run PCLauncher in ${applications_dir}

Instructions for using PlasmaClient are in the files ${docdir}/README and ${docdir}/README.mac

For more information, please visit the Guild of Writers' IRC channel at irc://irc.guildofwriters.com/#writers
"

platform darwin powerpc {
    notes-append "\n\nPlasmaClient probably does not work at all on PowerPC Macs at this time; try an Intel Mac."
}

platform darwin 8 {
    depends_run-delete      port:Drizzle
    if {![file isdirectory ${prefix}/share/mystonline/data/python] || ![file isdirectory ${prefix}/share/mystonline/data/SDL]} {
        notes-append "\n\nOn Mac OS X 10.4 Tiger, ${name} cannot download the secure files for you. Manually copy the python and SDL directories into ${prefix}/share/mystonline/data from another Mac that has PlasmaClient."
    }
}

livecheck.type              none