[116846] users/cal/ports/macports/mpstats

cal at macports.org cal at macports.org
Sat Feb 8 06:41:30 PST 2014


Revision: 116846
          https://trac.macports.org/changeset/116846
Author:   cal at macports.org
Date:     2014-02-08 06:41:30 -0800 (Sat, 08 Feb 2014)
Log Message:
-----------
mpstats: move UUID to $prefix/var/macports/stats-uuid, move config to $prefix/etc/macports/stats.conf

Don't reinplace stats.conf and install it directly (rather than just as
.default) so we can update the stats URL for existing users.

Modified Paths:
--------------
    users/cal/ports/macports/mpstats/Portfile
    users/cal/ports/macports/mpstats/files/mpstats.tcl

Added Paths:
-----------
    users/cal/ports/macports/mpstats/files/stats.conf

Removed Paths:
-------------
    users/cal/ports/macports/mpstats/files/mpstats.conf

Modified: users/cal/ports/macports/mpstats/Portfile
===================================================================
--- users/cal/ports/macports/mpstats/Portfile	2014-02-08 14:12:48 UTC (rev 116845)
+++ users/cal/ports/macports/mpstats/Portfile	2014-02-08 14:41:30 UTC (rev 116846)
@@ -3,7 +3,7 @@
 PortSystem          1.0
 
 name                mpstats
-version             0.1
+version             0.1.2
 categories          sysutils
 license             BSD
 platforms           darwin
@@ -52,9 +52,11 @@
         ${worksrcpath}/mpstats.plist.default \
         ${destroot}${launchd_dir}${startupitem.plist}.default
 
+    xinstall -m 755 -d \
+        ${destroot}${prefix}/etc/macports
     xinstall -m 444 \
-        ${filespath}/mpstats.conf \
-        ${destroot}${prefix}/etc/mpstats.conf.default
+        ${filespath}/stats.conf \
+        ${destroot}${prefix}/etc/macports/stats.conf
 
     # install the plist, if startupitem.install is set
     if {[getuid] == 0 && ${startupitem.install} ne no} {
@@ -66,13 +68,12 @@
 }
 
 post-activate {
-    if {![file exists ${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
+    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
     }
 
     # the result of this will usually be too large for a 64bit integer, but we don't really care

Deleted: users/cal/ports/macports/mpstats/files/mpstats.conf
===================================================================
--- users/cal/ports/macports/mpstats/files/mpstats.conf	2014-02-08 14:12:48 UTC (rev 116845)
+++ users/cal/ports/macports/mpstats/files/mpstats.conf	2014-02-08 14:41:30 UTC (rev 116846)
@@ -1,11 +0,0 @@
-# $Id$
-# configuration for mpstats
-
-# Where to submit usage data
-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
-# the id needs to be unique for each installation and so can't be generated
-# in advance or included in the archive.
-stats_id        @STATS_UUID@

Modified: users/cal/ports/macports/mpstats/files/mpstats.tcl
===================================================================
--- users/cal/ports/macports/mpstats/files/mpstats.tcl	2014-02-08 14:12:48 UTC (rev 116845)
+++ users/cal/ports/macports/mpstats/files/mpstats.tcl	2014-02-08 14:41:30 UTC (rev 116846)
@@ -49,21 +49,30 @@
 
 proc read_config {} {
     global prefix stats_url stats_id
-    set stats_url localhost
-    set stats_id 123
-    set conf_path "${prefix}/etc/mpstats.conf"
+    set conf_path "${prefix}/etc/macports/stats.conf"
     if {[file isfile $conf_path]} {
         set fd [open $conf_path r]
         while {[gets $fd line] >= 0} {
             set optname [lindex $line 0]
             if {$optname eq "stats_url"} {
                 set stats_url [lindex $line 1]
-            } elseif {$optname eq "stats_id"} {
-                set stats_id [lindex $line 1]
             }
         }
         close $fd
     }
+
+    set uuid_path "${prefix}/var/macports/stats-uuid"
+    if {[file isfile $uuid_path]} {
+        set fd [open $uuid_path r]
+        gets $fd stats_id
+        close $fd
+        if {[string length $stats_id] == 0} {
+            puts stderr "UUID file ${uuid_path} seems to be empty. Abort."
+        }
+    } else {
+        puts stderr "UUID file ${uuid_path} missing. Abort."
+        exit 1
+    }
 }
 
 # extraction of gcc version
@@ -88,7 +97,8 @@
         # Set gcc version
         return $gcc_v
     } else {
-        ui_warn "gcc exists but could not read version information"
+        # ui_warn "gcc exists but could not read version information"
+        # Don't warn since that's the default now that gcc -> clang
         return none
     }
 }

Copied: users/cal/ports/macports/mpstats/files/stats.conf (from rev 116821, users/cal/ports/macports/mpstats/files/mpstats.conf)
===================================================================
--- users/cal/ports/macports/mpstats/files/stats.conf	                        (rev 0)
+++ users/cal/ports/macports/mpstats/files/stats.conf	2014-02-08 14:41:30 UTC (rev 116846)
@@ -0,0 +1,5 @@
+# $Id$
+# configuration for mpstats
+
+# Where to submit usage data
+stats_url       http://stats.macports.neverpanic.de/submissions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140208/65869b2f/attachment.html>


More information about the macports-changes mailing list