Ticket #50121: Portfile

File Portfile, 4.0 KB (added by florian@…, 9 years ago)
Line 
1# -*- 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
2# $Id$
3
4PortSystem          1.0
5
6name                chrony
7version             2.2
8categories          sysutils net
9license             GPL-2
10platforms           darwin
11maintainers         eprofs.de:florian openmaintainer
12
13description         Chrony is a versatile implementation of the \
14                    Network Time Protocol (NTP)
15long_description    Chrony can synchronize the system clock with NTP \
16    servers, reference clocks, and manual input. It can also operate \
17    as an NTPv4 (RFC 5905) server and peer to provide a time service \
18    to other computers in the network. \
19    It is designed to perform well in a wide range of conditions, \
20    including intermittent network connections, heavily congested \
21    networks, changing temperatures (ordinary computer clocks are \
22    sensitive to temperature), and systems that do not run \
23    continuosly, or run on a virtual machine.
24
25homepage            http://chrony.tuxfamily.org/
26master_sites        http://download.tuxfamily.org/chrony/
27checksums           rmd160  4fc9672e000c956a6464cf47bcd66c48036a88d6 \
28                    sha256  d3fd820fa63badf54ee0e48a649b94ea739df3aac5efa104bd90f89795aa2485
29
30depends_lib         port:readline
31
32configure.args      --sysconfdir=${prefix}/etc \
33                    --localstatedir=${prefix}/var \
34                    --with-sendmail=/usr/sbin/sendmail
35
36post-patch {
37    # Change the location of the pidfile
38    reinplace "s|/var/run/chronyd.pid|${prefix}/var/run/${name}/chronyd.pid|" \
39        ${worksrcpath}/conf.c
40}
41
42post-build {
43    # This creates the helper application, chrony-netchanged, which monitors
44    # the network state and switches chronyd on when an internet link comes up
45    # and off when it goes down.
46    system -W ${worksrcpath} "${configure.cc} ${configure.cflags} [get_canonical_archflags cc] \
47        -DPREFIX=\\\"${prefix}\\\" -framework CoreFoundation -framework SystemConfiguration \
48        -o chrony-netchanged ${filespath}/chrony-netchanged.c"
49}
50
51post-destroot {
52    xinstall -m 755 ${worksrcpath}/chrony-netchanged ${destroot}${prefix}/sbin/chrony-netchanged
53
54    xinstall -m 755 -d ${destroot}${prefix}/etc/${name}/${name}
55    xinstall -m 0644 ${filespath}/${name}.conf.in \
56            ${destroot}${prefix}/etc/${name}/${name}.conf-dist
57    reinplace "s|@PREFIX@|${prefix}|" ${destroot}${prefix}/etc/${name}/${name}.conf-dist
58    xinstall -m 0755 ${filespath}/${name}-netchange.in \
59            ${destroot}${prefix}/etc/${name}/${name}-netchange
60    reinplace "s|@PREFIX@|${prefix}|" ${destroot}${prefix}/etc/${name}/${name}-netchange
61
62    xinstall -m 770 -g wheel -d ${destroot}${prefix}/var/run/${name}
63}
64
65destroot.keepdirs   ${destroot}${prefix}/var/run/${name}
66
67post-activate {
68    if {![file exists ${prefix}/etc/${name}/${name}.conf]} {
69        file copy ${prefix}/etc/${name}/${name}.conf-dist ${prefix}/etc/${name}/${name}.conf
70    }
71}
72
73startupitem.create  yes
74startupitem.pidfile auto ${prefix}/var/run/${name}/chronyd.pid
75
76# Start chronyd and chrony-netchanged and monitor the reachability
77# of the first NTP server found in chrony.conf:
78startupitem.start   \
79        "${prefix}/sbin/chronyd -r -s -f ${prefix}/etc/${name}/${name}.conf
80        sleep 2
81        target=\$(test -f ${prefix}/etc/${name}/${name}.conf && awk '/^\s*(pool|server)/ {print \$2; exit}' ${prefix}/etc/${name}/${name}.conf)
82        if ! ( \[ -e ${prefix}/var/run/chrony-netchanged.pid \] && kill -0 \$(cat ${prefix}/var/run/chrony-netchanged.pid) 2>/dev/null ) ; then
83                ${prefix}/sbin/chrony-netchanged \$target &
84                /bin/echo -n \$! > ${prefix}/var/run/${name}/chrony-netchanged.pid
85        fi"
86
87startupitem.stop    \
88        "/bin/kill \$(cat ${prefix}/var/run/${name}/chronyd.pid)
89        /bin/kill \$(cat ${prefix}/var/run/${name}/chrony-netchanged.pid)
90        /bin/rm -f ${prefix}/var/run/${name}/chrony-netchanged.pid"
91
92livecheck.type      regex
93livecheck.url       ${homepage}download.html
94livecheck.regex     {chrony-(\d+\.\d+(\.\d+)?)}