source: trunk/dports/sysutils/mpstats/Portfile

Last change on this file was 123308, checked in by cal@…, 3 years ago

mpstats: Don't fail because of missing env variables, closes #44409, run first submission two minutes after installation (otherwise the next submission would not have been until a week later)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1# $Id: Portfile 123308 2014-08-07 23:36:34Z ryandesign@macports.org $
2
3PortSystem          1.0
4
5name                mpstats
6version             0.1.6
7categories          sysutils macports
8license             BSD
9platforms           darwin
10supported_archs     noarch
11maintainers         cal openmaintainer
12description         submit statistics about your macports installation
13long_description \
14   This is a script and LaunchAgent which will run weekly to report \
15   information about your system and installed ports to a server, which \
16   publishes the aggregate statistics on the web. \
17   \nThis helps us to make better decisions on which configurations we should \
18   support and test more and which ports are most commonly used.
19
20homepage            http://www.macports.org/
21distfiles
22
23set launchd_dir     ${prefix}/etc/${startupitem.location}/${startupitem.uniquename}/
24
25startupitem.create   no
26startupitem.autostart \
27                    yes
28
29extract.mkdir       yes
30extract {
31    xinstall -m 644 -W ${filespath} mpstats.tcl mpstats.plist.default ${worksrcpath}
32}
33
34configure {
35    reinplace "s|@PREFIX@|${prefix}|g" \
36        ${worksrcpath}/mpstats.tcl \
37        ${worksrcpath}/mpstats.plist.default
38    reinplace "s|@LABEL@|${startupitem.uniquename}|g" \
39        ${worksrcpath}/mpstats.plist.default
40}
41
42build {}
43
44destroot {
45    xinstall -m 755 \
46        ${worksrcpath}/mpstats.tcl \
47        ${destroot}${prefix}/libexec/mpstats
48
49    xinstall -m 755 -d \
50        ${destroot}${launchd_dir}
51    xinstall -m 444 \
52        ${worksrcpath}/mpstats.plist.default \
53        ${destroot}${launchd_dir}${startupitem.plist}.default
54
55    xinstall -m 755 -d \
56        ${destroot}${prefix}/etc/macports
57    xinstall -m 444 \
58        ${filespath}/stats.conf \
59        ${destroot}${prefix}/etc/macports/stats.conf
60
61    # install the plist, if startupitem.install is set
62    if {[getuid] == 0 && ${startupitem.install} ne no} {
63        xinstall -m 755 -d ${destroot}/Library/${startupitem.location}
64        # note this symlink *will* be broken at destroot time; we'll place the
65        # correct file there on activation
66        ln -sf "${launchd_dir}${startupitem.plist}" "${destroot}/Library/${startupitem.location}"
67    }
68}
69
70post-activate {
71    set uuidfile ${prefix}/var/macports/stats-uuid
72    if {![file exists ${uuidfile}] || [file size ${uuidfile}] == 0} {
73        set uuid [exec /usr/bin/uuidgen]
74        set fd [open ${uuidfile} w]
75        puts $fd $uuid
76        close $fd
77    }
78
79    xinstall -m 644 \
80        ${launchd_dir}${startupitem.plist}.default \
81        ${launchd_dir}${startupitem.plist}
82    reinplace "s|@WEEKDAY@|[expr {int(7 * rand())}]|g" \
83        ${launchd_dir}${startupitem.plist}
84    reinplace "s|@HOUR@|[clock format [clock seconds] -format %H]|g" \
85        ${launchd_dir}${startupitem.plist}
86    reinplace "s|@MINUTE@|[clock format [expr {[clock seconds] + 120}] -format %M]|g" \
87        ${launchd_dir}${startupitem.plist}
88}
89
90post-deactivate {
91    delete ${launchd_dir}${startupitem.plist}
92}
93
94notes \
95    "Installing this port automatically enables weekly reporting of data to the stats server. \
96     Uninstall or deactivate this port if you want to stop providing data to MacPorts."
Note: See TracBrowser for help on using the repository browser.