#!@PREFIX@/bin/port-tclsh
# -*- 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
# Copyright (c) 2011,2013 The MacPorts Project
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of The MacPorts Project nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if {[catch {mportinit} result]} {
puts stderr "Error: $result"
ui_msg "Usage: $::argv0 \[submit|show\]"
# Reads the configuration from the statistics config file at $prefix/etc/macports/stats.conf and the
# UUID file $prefix/var/macports/stats-uiud. Stores the configured values in global variables.
# Currently, the following configuration variables are supported:
# - stats_url The URL that will be used for POST submission of the statistics
# - stats_id The UUID of this MacPorts installation; to be read from the UUID file
# Prints an error message (but doesn't abort) if the UUID is empty.
global prefix stats_url stats_id
set conf_path "${prefix}/etc/macports/@CONFNAME@.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]
set uuid_path "${prefix}/var/macports/stats-uuid"
if {[file isfile $uuid_path]} {
set fd [open $uuid_path r]
if {[string length $stats_id] == 0} {
ui_error "UUID file ${uuid_path} seems to be empty."
ui_error "UUID file ${uuid_path} missing."
# extraction of gcc version
if {[catch {set gccpath [macports::binaryInPath "gcc"]}] != 0} {
# Call gcc -v - Note that output will be on stderr not stdout
# This succeeds if catch returns nonzero
if { [catch { exec $gccpath -v } gccinfo] == 0} {