[116821] users/cal/ports/macports/mpstats
cal at macports.org
cal at macports.org
Fri Feb 7 15:39:55 PST 2014
Revision: 116821
https://trac.macports.org/changeset/116821
Author: cal at macports.org
Date: 2014-02-07 15:39:55 -0800 (Fri, 07 Feb 2014)
Log Message:
-----------
mpstats: working macports statistics submission port
Modified Paths:
--------------
users/cal/ports/macports/mpstats/Portfile
users/cal/ports/macports/mpstats/files/mpstats.conf
Added Paths:
-----------
users/cal/ports/macports/mpstats/files/mpstats.plist.default
Removed Paths:
-------------
users/cal/ports/macports/mpstats/files/setupstats.sh
Modified: users/cal/ports/macports/mpstats/Portfile
===================================================================
--- users/cal/ports/macports/mpstats/Portfile 2014-02-07 23:39:28 UTC (rev 116820)
+++ users/cal/ports/macports/mpstats/Portfile 2014-02-07 23:39:55 UTC (rev 116821)
@@ -8,38 +8,90 @@
license BSD
platforms darwin
supported_archs noarch
-maintainers nomaintainer
+maintainers cal openmaintainer
description submit statistics about your macports installation
long_description \
- This is a script and LaunchAgent which can run weekly to report \
+ 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.
+ 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/
-master_sites sourceforge:macports
+distfiles
-use_bzip2 yes
-checksums rmd160 6411865c289d95f15eec870fd3aa8d1ffa7c4502 \
- sha256 43a7c0e5956acf96f6a3e9c913229c6decbeabb5a4e5645a829a7fca7878a7ef
+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|set prefix /opt/local|set prefix ${prefix}|" ${worksrcpath}/mpstats.tcl
+ 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 ${worksrcpath}/mpstats.tcl ${destroot}${prefix}/bin/mpstats
- xinstall -m 444 ${worksrcpath}/mpstats.conf ${destroot}${prefix}/etc/mpstats.conf.default
- system -W ${worksrcpath} "DESTDIR=${destroot} ./setupstats.sh ${prefix}/bin/mpstats"
+ 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 444 \
+ ${filespath}/mpstats.conf \
+ ${destroot}${prefix}/etc/mpstats.conf.default
+
+ # 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 {
if {![file exists ${prefix}/etc/mpstats.conf]} {
- copy ${prefix}/etc/mpstats.conf.default ${prefix}/etc/mpstats.conf
- reinplace "s|@STATS_UUID@|[exec uuidgen]|" ${prefix}/etc/mpstats.conf
+ xinstall -m 644 \
+ ${prefix}/etc/mpstats.conf.default \
+ ${prefix}/etc/mpstats.conf
+
+ reinplace "s|@STATS_UUID@|[exec uuidgen]|" \
+ ${prefix}/etc/mpstats.conf
}
+
+ # the result of this will usually be too large for a 64bit integer, but we don't really care
+ set hwuuid [exec system_profiler SPHardwareDataType | grep "Hardware UUID" | awk "/Hardware UUID/ {print \$3}" | tr -d - | bc]
+ xinstall -m 644 \
+ ${launchd_dir}${startupitem.plist}.default \
+ ${launchd_dir}${startupitem.plist}
+ reinplace "s|@WEEKDAY@|[expr $hwuuid % 7]|g" \
+ ${launchd_dir}${startupitem.plist}
+ reinplace "s|@HOUR@|[clock format [clock seconds] -format %H]|g" \
+ ${launchd_dir}${startupitem.plist}
+ reinplace "s|@MINUTE@|[clock format [clock seconds] -format %M]|g" \
+ ${launchd_dir}${startupitem.plist}
}
+post-deactivate {
+ delete -force ${launchd_dir}${startupitem.plist}
+}
+
notes \
-"To enable automatic weekly reporting of data to the stats server,\
-run:
-launchctl load -w /Library/LaunchAgents/org.macports.stats.plist"
+ "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."
Modified: users/cal/ports/macports/mpstats/files/mpstats.conf
===================================================================
--- users/cal/ports/macports/mpstats/files/mpstats.conf 2014-02-07 23:39:28 UTC (rev 116820)
+++ users/cal/ports/macports/mpstats/files/mpstats.conf 2014-02-07 23:39:55 UTC (rev 116821)
@@ -2,7 +2,7 @@
# configuration for mpstats
# Where to submit usage data
-stats_url localhost
+stats_url http://stats.macports.neverpanic.de/submissions
# Unique identifier for usage statistics - should be of the form produced by
# `uuidgen`. Note that mpstats.conf.default has a placeholder value here, as
Added: users/cal/ports/macports/mpstats/files/mpstats.plist.default
===================================================================
--- users/cal/ports/macports/mpstats/files/mpstats.plist.default (rev 0)
+++ users/cal/ports/macports/mpstats/files/mpstats.plist.default 2014-02-07 23:39:55 UTC (rev 116821)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>Label</key>
+ <string>@LABEL@</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>@PREFIX@/libexec/mpstats</string>
+ <string>submit</string>
+ </array>
+ <key>StartCalendarInterval</key>
+ <dict>
+ <key>Weekday</key>
+ <integer>@WEEKDAY@</integer>
+ <key>Hour</key>
+ <integer>@HOUR@</integer>
+ <key>Minute</key>
+ <integer>@MINUTE@</integer>
+ </dict>
+ </dict>
+</plist>
Deleted: users/cal/ports/macports/mpstats/files/setupstats.sh
===================================================================
--- users/cal/ports/macports/mpstats/files/setupstats.sh 2014-02-07 23:39:28 UTC (rev 116820)
+++ users/cal/ports/macports/mpstats/files/setupstats.sh 2014-02-07 23:39:55 UTC (rev 116821)
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-# Where the generated plist should be written
-PLIST=${DESTDIR}/Library/LaunchAgents/org.macports.stats.plist
-
-die () {
- echo >&2 "$@"
- exit 1
-}
-
-# Make sure exactly 2 arguments are provided
-[ "$#" -eq 1 ] || die "exactly one argument required"
-
-# $1 must be the path to the script launchd will execute
-SCRIPT=$1
-
-# Make sure the script argument is executable
-if [ ! -x "${DESTDIR}${SCRIPT}" ]; then
- die "$SCRIPT is not a valid executable"
-fi
-
-# Determine the day and time that launchd should run the script
-setup_times() {
- # Get hardware uuid - Hardware UUID: UUID
- huuid=`system_profiler SPHardwareDataType | grep "Hardware UUID"`
-
- # Strip out Hardware UUID:
- huuid=`echo $huuid | awk '/Hardware UUID/ {print $3;}'`
-
- # Strip out '-' characters
- huuid=`echo $huuid | tr -d -`
-
- # Weekday is hardware uuid mod 7
- weekday=`echo $huuid % 7 | bc`
-
- # Use current hours and minute
- hour=`date '+%H'`
- minute=`date '+%M'`
-}
-
-# Generate the launchd plist that executes 'port stats submit'
-# Outputs to the file $plist
-generate_plist() {
- setup_times
- mkdir -p `dirname $PLIST`
- cat <<-EOF > $PLIST
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>Label</key>
- <string>org.macports.stats</string>
- <key>ProgramArguments</key>
- <array>
- <string>$SCRIPT</string>
- <string>submit</string>
- </array>
- <key>StartCalendarInterval</key>
- <dict>
- <key>Weekday</key>
- <integer>$weekday</integer>
- <key>Hour</key>
- <integer>$hour</integer>
- <key>Minute</key>
- <integer>$minute</integer>
- </dict>
- </dict>
- </plist>
- EOF
-}
-
-# Generate and install the plist
-generate_plist
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140207/8d257222/attachment.html>
More information about the macports-changes
mailing list