# -*- 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

PortSystem          1.0
PortGroup           github 1.0

github.setup        Duncaen opendoas 6.8.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            0
categories          sysutils security
license             BSD
maintainers         {danchr @danchr}

description         Run a command as another user
long_description \
    The doas utility is a program originally written for OpenBSD \
    which allows a user to run a command as though they were another \
    user. Typically doas is used to allow non-privileged users to \
    run commands as though they were the root user. The doas program \
    acts as an alternative to sudo, which is a popular method for \
    granting admin access to specific users.

platforms           darwin

checksums           rmd160  3eb2d835442bf9defcd8d7c962c7f211f6583261 \
                    sha256  c8e83a92398589177be09f032bfaae7802136fe465643ccb4f3836c16b2a346a \
                    size    32442

configure.args-append \
    --sysconfdir=${prefix}/etc

patchfiles         pam-service.diff

pre-destroot {
    if { [getuid] != 0 } {
        ui_msg "------------------------------------------------------------"
        ui_msg "Installing doas as non-root doesn't really do anything"
        ui_msg "useful, so be sure to install doas as root"
        ui_msg "------------------------------------------------------------"
    }
}

post-destroot {
    xinstall -m 640 ${filespath}/doas.conf.example ${destroot}${prefix}/etc
}

post-activate {
    if {![file exists ${prefix}/etc/doas.conf]} {
        ui_msg "Installing sample configuration to ${prefix}/etc/doas.conf"
        xinstall -m 640 ${prefix}/etc/doas.conf.example ${prefix}/etc/doas.conf
    }
}
