# -*- 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: Portfile 112969 2013-11-05 19:09:52Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           python 1.0

name                salt
version             2014.1.7
categories          sysutils
platforms           darwin
maintainers         saltstack.com:cr
license             Apache-2
supported_archs     noarch

description         Salt is a Python-based remote execution, automation, \
                    configuration, and orchestration engine.

long_description    SaltStack is fast, scalable and flexible software for data \
                    center automation, from infrastructure and any cloud, \
                    to the entire application stack.

homepage            http://docs.saltstack.com/
fetch.type          git
git.url             git://github.com/saltstack/salt.git
git.branch          v2014.1.7

# master_sites        https://pypi.python.org/packages/source/s/salt/

# checksums           rmd160  4ca8aedca823f4e6d5711ee78777d46036d77a44 \
#                    sha256  bc501c50cef7af9ce857b6f4a7c34b0238cc6a2810e4bd6e3ff7e0bfb082343f

python.default_version 27
python.link_binaries_suffix

depends_build       port:py${python.version}-setuptools

depends_lib-append  port:py${python.version}-crypto \
                    port:py${python.version}-m2crypto \
                    port:py${python.version}-msgpack \
                    port:py${python.version}-pip \
                    port:py${python.version}-yaml \
                    port:py${python.version}-zmq \
                    port:swig-python

livecheck.type      regex
livecheck.regex     {topics/releases/([0-9]+\.[0-9]+\.[0-9]+)\.html}

variant minion {
    startupitem.create        yes
    startupitem.name          salt-minion
    startupitem.netchange     yes
    startupitem.logevents     yes
    startupitem.logfile       ${prefix}/var/log/salt/minion
    startupitem.executable    ${prefix}/bin/salt-minion

    if ![file exists /opt/local/etc/salt/minion] {
        file copy ${worksrcpath}/conf/minion /opt/local/etc/salt
    }
}

variant master {

    post-destroot {
        file mkdir /opt/local/etc/salt
        if ![file exists /opt/local/etc/salt/master] {
            file copy ${worksrcpath}/conf/master /opt/local/etc/salt
        }

        if ![file exists /etc/salt] {
            file link /etc/salt /opt/local/etc/salt
        }
        file copy ${worksrcpath}/pkg/macports/com.saltstack.salt.master.plist /Library/LaunchDaemons
    }
    notes-append "
This variant is for the salt-master.  To start the salt-master via launchd, run
    
sudo launchctl load -w /Library/LaunchDaemons/com.saltstack.salt.master.plist

To disable launchd management, run 

sudo launchctl unload -w /Library/LaunchDaemons/com.saltstack.salt.master.plist

"
}

variant syndic {

    post-destroot {
        file copy ${worksrcpath}/pkg/macports/com.saltstack.salt.syndic.plist /Library/LaunchDaemons
    }
    notes-append "
This variant is for the salt-syndic.  To start the salt-syndic via launchd, run
    
sudo launchctl load -w /Library/LaunchDaemons/org.macports.salt-syndic.plist

To disable launchd management, run 

sudo launchctl unload -w /Library/LaunchDaemons/org.macports.salt-syndic.plist

"
}

post-destroot {
    file mkdir /opt/local/etc/salt

    if ![file exists /etc/salt] {
        file link /etc/salt /opt/local/etc/salt
    }
}


