# $Id: Portfile 123308 2014-08-07 23:36:34Z cal@macports.org $ PortSystem 1.0 name mpstats version 0.1.6 categories sysutils macports license BSD platforms darwin supported_archs noarch maintainers cal openmaintainer description submit statistics about your macports installation long_description \ This is a script and LaunchAgent which will run weekly to report \ information about your system and installed ports to a server, which \ publishes the aggregate statistics on the web. \ \nThis helps us to make better decisions on which configurations we should \ support and test more and which ports are most commonly used. homepage http://www.macports.org/ distfiles set launchd_dir ${prefix}/etc/${startupitem.location}/${startupitem.uniquename}/ startupitem.create no startupitem.autostart \ yes extract.mkdir yes extract { xinstall -m 644 -W ${filespath} mpstats.tcl mpstats.plist.default ${worksrcpath} } configure { reinplace "s|@PREFIX@|${prefix}|g" \ ${worksrcpath}/mpstats.tcl \ ${worksrcpath}/mpstats.plist.default reinplace "s|@LABEL@|${startupitem.uniquename}|g" \ ${worksrcpath}/mpstats.plist.default } build {} destroot { xinstall -m 755 \ ${worksrcpath}/mpstats.tcl \ ${destroot}${prefix}/libexec/mpstats xinstall -m 755 -d \ ${destroot}${launchd_dir} xinstall -m 444 \ ${worksrcpath}/mpstats.plist.default \ ${destroot}${launchd_dir}${startupitem.plist}.default xinstall -m 755 -d \ ${destroot}${prefix}/etc/macports xinstall -m 444 \ ${filespath}/stats.conf \ ${destroot}${prefix}/etc/macports/stats.conf # install the plist, if startupitem.install is set if {[getuid] == 0 && ${startupitem.install} ne no} { xinstall -m 755 -d ${destroot}/Library/${startupitem.location} # note this symlink *will* be broken at destroot time; we'll place the # correct file there on activation ln -sf "${launchd_dir}${startupitem.plist}" "${destroot}/Library/${startupitem.location}" } } post-activate { set uuidfile ${prefix}/var/macports/stats-uuid if {![file exists ${uuidfile}] || [file size ${uuidfile}] == 0} { set uuid [exec /usr/bin/uuidgen] set fd [open ${uuidfile} w] puts $fd $uuid close $fd } xinstall -m 644 \ ${launchd_dir}${startupitem.plist}.default \ ${launchd_dir}${startupitem.plist} reinplace "s|@WEEKDAY@|[expr {int(7 * rand())}]|g" \ ${launchd_dir}${startupitem.plist} reinplace "s|@HOUR@|[clock format [clock seconds] -format %H]|g" \ ${launchd_dir}${startupitem.plist} reinplace "s|@MINUTE@|[clock format [expr {[clock seconds] + 120}] -format %M]|g" \ ${launchd_dir}${startupitem.plist} } post-deactivate { delete ${launchd_dir}${startupitem.plist} } notes \ "Installing this port automatically enables weekly reporting of data to the stats server. \ Uninstall or deactivate this port if you want to stop providing data to MacPorts."