<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[152581] contrib/mp-buildbot</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/152581">152581</a></dd>
<dt>Author</dt> <dd>cal@macports.org</dd>
<dt>Date</dt> <dd>2016-09-12 12:14:24 -0700 (Mon, 12 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>mp-buildbot: Don't re-run previously failed builds

If a port's build has previously failed, we do not want to waste cycles
to re-attempt it (e.g. as dependencies of other ports), unless the
failed port's definition has changed.

To achieve that, create a file with a reference to the last failed build
for every failing port, and fail builds that depend on failed ports
early.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#contribmpbuildbotREADMEmd">contrib/mp-buildbot/README.md</a></li>
<li><a href="#contribmpbuildbotmpbb">contrib/mp-buildbot/mpbb</a></li>
<li><a href="#contribmpbuildbotmpbbinstalldependencies">contrib/mp-buildbot/mpbb-install-dependencies</a></li>
<li><a href="#contribmpbuildbotmpbbinstallport">contrib/mp-buildbot/mpbb-install-port</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#contribmpbuildbotfunctions">contrib/mp-buildbot/functions</a></li>
<li><a href="#contribmpbuildbottoolscanonical_variantstcl">contrib/mp-buildbot/tools/canonical_variants.tcl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="contribmpbuildbotREADMEmd"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/README.md (152580 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/README.md        2016-09-12 19:13:35 UTC (rev 152580)
+++ contrib/mp-buildbot/README.md        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -91,3 +91,6 @@
</span><span class="cx">       persist for the duration of an `mpbb` run, so it may be used to
</span><span class="cx">       share ancillary files (e.g., a Subversion checkout of the ports
</span><span class="cx">       tree) between builds of different ports.
</span><ins>+-   `$option_failcache_dir`:
+      A directory for storing information about previously failed builds which
+      saves time because builds that are known to fail will not be attempted.
</ins></span></pre></div>
<a id="contribmpbuildbotfunctions"></a>
<div class="addfile"><h4>Added: contrib/mp-buildbot/functions (0 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/functions                                (rev 0)
+++ contrib/mp-buildbot/functions        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -0,0 +1,134 @@
</span><ins>+#!/bin/bash
+# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4
+
+# Helper functions for mp-buildbot
+
+# Print $0 and arguments to standard error.
+# Unset IFS to ensure &quot;$*&quot; uses spaces as separators.
+msg() (unset IFS; printf &gt;&amp;2 '%s: %s\n' &quot;$0&quot; &quot;$*&quot;)
+err() { msg error: &quot;$@&quot;; }
+warn() { msg warning: &quot;$@&quot;; }
+
+## Compute a failcache hash for the given port
+#
+# Computes and prints a hash uniquely identifying a specific state of a port's
+# definition files, including the Portfile's hash as well as the port's
+# patchfiles. To build the hash, this function executes the following
+# algorithm:
+#  - For the Portfile, and each file in files/ (if any), calculate a SHA256
+#    hash
+#  - Sort the hash values alphabetically
+#  - Hash the result using SHA256
+# This means a failcache entry will not match if a patchfile changes. A common
+# case where this is the desired behavior is a port committed without
+# a required patchfile.
+#
+# Valid arguments are all arguments accepted by &quot;port dir&quot;.
+compute_failcache_hash() {
+    local portdir
+    local -a filelist
+
+    portdir=$(&quot;${option_prefix}/bin/port&quot; dir &quot;$@&quot;)
+    if [ $? -ne 0 ] || [ -z &quot;$portdir&quot; ]; then
+        err &quot;Could not compute failcache hash: port dir&quot; &quot;$@&quot; &quot;failed&quot;
+        return 1
+    fi
+
+    if [ ! -d &quot;$portdir&quot; ]; then
+        err &quot;Port directory $portdir does not exist&quot;
+        return 2
+    fi
+
+    filelist=(&quot;$portdir/Portfile&quot;)
+    if [ -d &quot;$portdir/files&quot; ]; then
+        filelist+=(&quot;$portdir/files&quot;)
+    fi
+
+    find &quot;${filelist[@]}&quot; -type f -exec openssl dgst -sha256 {} \; |\
+        cut -d' ' -f2 |\
+        sort |\
+        openssl dgst -sha256 |\
+        cut -d' ' -f2
+}
+
+## Compute a key that uniquely identifies a (port, variants, portfile-hash) tuple
+#
+# Valid arguments are a port name, optionally followed by a variant
+# specification. Invokes &quot;port dir&quot; to find the Portfile and patchfiles and
+# computes a checksum of these files that will become part of the hash.
+failcache_key() {
+    local port=$1
+    if [ -z &quot;$port&quot; ]; then
+        err &quot;failcache_key expects a port argument, but none was given.&quot;
+        return 1
+    fi
+
+    local checksum
+    checksum=$(compute_failcache_hash &quot;$port&quot;)
+    if [ $? -ne 0 ]; then
+        err &quot;compute_failcache_hash $port failed&quot;
+        return 2
+    fi
+
+    local canonical_variants
+    canonical_variants=$(&quot;${option_prefix}/bin/port-tclsh&quot; &quot;${thisdir}/tools/canonical_variants.tcl&quot; &quot;$@&quot;)
+    if [ $? -ne 0 ]; then
+        err &quot;tools/canonical_variants.tcl&quot; &quot;$@&quot; &quot;failed&quot;
+        return 4
+    fi
+
+    echo &quot;$port $canonical_variants $checksum&quot;
+}
+
+## Test whether a given port with variants has previously failed.
+#
+# Valid arguments are a port name, optionally followed by a variant
+# specification. Succeeds if the port did not previsouly fail to build,
+# fails if the port is known to fail.
+failcache_test() {
+    local key
+    key=$(failcache_key &quot;$@&quot;)
+    if [ $? -ne 0 ]; then
+        err &quot;Could not determine failcache key for&quot; &quot;$@&quot;
+        return 1
+    fi
+
+    if [ -f &quot;${option_failcache_dir}/${key}&quot; ]; then
+        printf &quot;port %s previously failed in build %s\n&quot; &quot;${key}&quot; &quot;$(&lt;&quot;${option_failcache_dir}/${key}&quot;)&quot;
+        return 1
+    else
+        return 0
+    fi
+}
+
+## Mark a build of a given port with variants as successful.
+#
+# Valid arguments are a port name, optionally followed by a variant
+# specification. Removes any database entries that marked a port as failed.
+failcache_success() {
+    local key
+    key=$(failcache_key &quot;$@&quot;)
+    if [ $? -ne 0 ]; then
+        err &quot;Could not determine failcache key for&quot; &quot;$@&quot;
+        return 1
+    fi
+
+    rm -f &quot;${option_failcache_dir}/${key}&quot;
+}
+
+## Mark a build of a given port with variants as failed.
+#
+# Valid arguments are a port name, optionally followed by a variant
+# specification. Creates or updates the timestamp of a database entry that
+# marks a port as failed.
+failcache_failure() {
+    local key
+    key=$(failcache_key &quot;$@&quot;)
+    if [ $? -ne 0 ]; then
+        err &quot;Could not determine failcache key for&quot; &quot;$@&quot;
+        return 1
+    fi
+
+    mkdir -p &quot;${option_failcache_dir}&quot;
+    echo &quot;${BUILDBOT_BUILDURL:-unknown}&quot; &gt; &quot;${option_failcache_dir}/${key}&quot;
+}
</ins></span></pre></div>
<a id="contribmpbuildbotmpbb"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb (152580 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb        2016-09-12 19:13:35 UTC (rev 152580)
+++ contrib/mp-buildbot/mpbb        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -8,11 +8,10 @@
</span><span class="cx"> # Don't inherit any option variables from the calling environment.
</span><span class="cx"> unset &quot;${!option_@}&quot;
</span><span class="cx"> 
</span><del>-# Print $0 and arguments to standard error.
-# Unset IFS to ensure &quot;$*&quot; uses spaces as separators.
-msg() (unset IFS; printf &gt;&amp;2 '%s: %s\n' &quot;$0&quot; &quot;$*&quot;)
-err() { msg error: &quot;$@&quot;; }
-warn() { msg warning: &quot;$@&quot;; }
</del><ins>+# Load function library
+thisdir=$(cd &quot;$(dirname &quot;$0&quot;)&quot; &amp;&amp; pwd)
+# shellcheck source=functions
+. &quot;$thisdir/functions&quot;
</ins><span class="cx"> 
</span><span class="cx"> mpbb-usage() {
</span><span class="cx">     # &quot;prog&quot; is defined in mpbb-help.
</span><span class="lines">@@ -126,6 +125,7 @@
</span><span class="cx">     option_jobs_dir=${option_work_dir}/infrastructure/jobs
</span><span class="cx">     option_log_dir=${option_work_dir}/logs
</span><span class="cx"> }
</span><ins>+option_failcache_dir=${option_work_dir}/failcache
</ins><span class="cx"> 
</span><span class="cx"> # Inform the user if old repositories are still present.
</span><span class="cx"> if [[ -d ${option_work_dir}/tools/.svn ]]; then
</span><span class="lines">@@ -146,7 +146,6 @@
</span><span class="cx"> # must define functions &quot;FOO&quot; and &quot;FOO-usage&quot;.
</span><span class="cx"> cmds=()
</span><span class="cx"> usages=(mpbb-usage)
</span><del>-thisdir=$(cd &quot;$(dirname &quot;$0&quot;)&quot; &amp;&amp; pwd)
</del><span class="cx"> for cmdfile in &quot;$thisdir/mpbb-&quot;*; do
</span><span class="cx">     # Unfortunately ShellCheck does not currently support following multiple
</span><span class="cx">     # files, so we'll just disable the warning.
</span></span></pre></div>
<a id="contribmpbuildbotmpbbinstalldependencies"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-install-dependencies (152580 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-install-dependencies        2016-09-12 19:13:35 UTC (rev 152580)
+++ contrib/mp-buildbot/mpbb-install-dependencies        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -41,6 +41,9 @@
</span><span class="cx">     local dependencies
</span><span class="cx">     local dependencies_count
</span><span class="cx">     local dependencies_counter
</span><ins>+    local depname
+    local depvariants
+    local failcachecounter
</ins><span class="cx">     # $option_log_dir is set in mpbb
</span><span class="cx">     # shellcheck disable=SC2154
</span><span class="cx">     local log_status_dependencies=&quot;${option_log_dir}/dependencies-progress.txt&quot;
</span><span class="lines">@@ -53,7 +56,7 @@
</span><span class="cx">     # calculate list of dependencies in-order
</span><span class="cx">     # $option_prefix and $thisdir are set in mpbb
</span><span class="cx">     # shellcheck disable=SC2154
</span><del>-    dependencies=$(&quot;${option_prefix}/bin/port-tclsh&quot; &quot;${thisdir}/tools/dependencies.tcl&quot; &quot;$port&quot;)
</del><ins>+    dependencies=$(&quot;${option_prefix}/bin/port-tclsh&quot; &quot;${thisdir}/tools/dependencies.tcl&quot; &quot;$@&quot;)
</ins><span class="cx">     if [ $? -ne 0 ]; then
</span><span class="cx">         echo &quot;Calculating dependencies for '$port' failed, aborting.&quot; &gt;&amp;2
</span><span class="cx">         echo &quot;Building '$port' ... [ERROR] (failed to calculate dependencies) maintainers: $(get-maintainers &quot;$port&quot;).&quot; &gt;&gt; &quot;$log_subports_progress&quot;
</span><span class="lines">@@ -72,26 +75,67 @@
</span><span class="cx">     echo &quot;$dependencies&quot; | sed -E 's/^/ - /' | tee -a &quot;$log_status_dependencies&quot;
</span><span class="cx">     echo &gt;&gt; &quot;$log_status_dependencies&quot;
</span><span class="cx"> 
</span><del>-    echo &quot;$dependencies&quot; | while read -r dependency; do
</del><ins>+    # Check whether any of the dependencies have previously failed
+    failcachecounter=0
+    while read -r dependency; do
</ins><span class="cx">         # Split portname +variant1+variant2 into portname and variants, where
</span><span class="cx">         # the variants are optional.
</span><span class="cx">         depname=${dependency%% *}
</span><span class="cx">         depvariants=${dependency:${#depname}+1}
</span><span class="cx"> 
</span><ins>+        # $depvariants isn't quoted on purpose
+        # shellcheck disable=SC2086
+        if ! failcache_test &quot;$depname&quot; $depvariants; then
+            text=&quot;Dependency '${depname}' with variants '${depvariants}' has previously failed and is required.&quot;
+            echo &quot;$text&quot; &gt;&amp;2
+            echo &quot;$text&quot; &gt;&gt; &quot;$log_status_dependencies&quot;
+            echo &quot;Building '$port' ... [ERROR] (failed to install dependency '${depname}') maintainers: $(get-maintainers &quot;$port&quot; &quot;${depname}&quot;).&quot; &gt;&gt; &quot;$log_subports_progress&quot;
+            failcachecounter=$((failcachecounter + 1))
+        fi
+    done &lt;&lt;&lt;&quot;$dependencies&quot;
+
+    if [ $failcachecounter -gt 0 ]; then
+        echo &quot;Aborting build because $failcachecounter dependencies are known to fail.&quot; &gt;&amp;2
+        return 1
+    fi
+
+    while read -r dependency; do
+        # Split portname +variant1+variant2 into portname and variants, where
+        # the variants are optional.
+        depname=${dependency%% *}
+        depvariants=${dependency:${#depname}+1}
+
</ins><span class="cx">         text=&quot;Installing dependency ($dependencies_counter of $dependencies_count) '${depname}' with variants '${depvariants}'&quot;
</span><span class="cx">         echo &quot;----&gt; ${text}&quot;
</span><span class="cx">         echo -n &quot;${text} ... &quot; &gt;&gt; &quot;$log_status_dependencies&quot;
</span><span class="cx">         # $depvariants isn't quoted on purpose
</span><span class="cx">         # shellcheck disable=SC2086
</span><span class="cx">         if ! &quot;${option_prefix}/bin/port&quot; -d install --unrequested &quot;$depname&quot; $depvariants; then
</span><del>-            echo &quot;Build of dependency '${depname}' failed, aborting.&quot; &gt;&amp;2
</del><ins>+            echo &quot;Build of dependency '${depname}' with variants '${depvariants}' failed, aborting.&quot; &gt;&amp;2
</ins><span class="cx">             echo &quot;[FAIL]&quot; &gt;&gt; &quot;$log_status_dependencies&quot;
</span><span class="cx">             echo &quot;Building '$port' ... [ERROR] (failed to install dependency '${depname}') maintainers: $(get-maintainers &quot;$port&quot; &quot;${depname}&quot;).&quot; &gt;&gt; &quot;$log_subports_progress&quot;
</span><ins>+
+            # Update failcache
+            # $depvariants isn't quoted on purpose
+            # shellcheck disable=SC2086
+            failcache_failure &quot;$depname&quot; $depvariants
+            if [ $? -ne 0 ]; then
+                err &quot;failcache_failure $depname $depvariants failed.&quot;
+                return 1
+            fi
</ins><span class="cx">             return 1
</span><span class="cx">         else
</span><span class="cx">             echo &quot;[OK]&quot; &gt;&gt; &quot;$log_status_dependencies&quot;
</span><ins>+            # Remove failcache if it exists
+            # $depvariants isn't quoted on purpose
+            # shellcheck disable=SC2086
+            failcache_success &quot;$depname&quot; $depvariants
+            if [ $? -ne 0 ]; then
+                err &quot;failcache_success $depname $depvariants failed.&quot;
+                return 1
+            fi
</ins><span class="cx">             dependencies_counter=$((dependencies_counter + 1))
</span><span class="cx">         fi
</span><del>-    done
</del><ins>+    done &lt;&lt;&lt;&quot;$dependencies&quot;
</ins><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="contribmpbuildbotmpbbinstallport"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-install-port (152580 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-install-port        2016-09-12 19:13:35 UTC (rev 152580)
+++ contrib/mp-buildbot/mpbb-install-port        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -55,10 +55,23 @@
</span><span class="cx">     time_start=$(date +%s)
</span><span class="cx">     # $option_prefix is set in mpbb
</span><span class="cx">     # shellcheck disable=SC2154
</span><del>-    if ! &quot;${option_prefix}/bin/port&quot; -dk install &quot;$port&quot;; then
</del><ins>+    if &quot;${option_prefix}/bin/port&quot; -dk install &quot;$@&quot;; then
+        # Remove failcache if it exists
+        failcache_success &quot;$@&quot;
+        if [ $? -ne 0 ]; then
+            err &quot;failcache_success&quot; &quot;$@&quot; &quot;failed.&quot;
+            return 1
+        fi
+    else
</ins><span class="cx">         echo &quot;Build of '$port' failed.&quot;
</span><span class="cx">         # log: summary for the portwatcher
</span><span class="cx">         echo &quot;Building '$port' ... [ERROR] maintainers: $(get-maintainers &quot;$port&quot;).&quot; &gt;&gt; &quot;$log_subports_progress&quot;
</span><ins>+        # update failcache
+        failcache_failure &quot;$@&quot;
+        if [ $? -ne 0 ]; then
+            err &quot;failcache_failure&quot; &quot;$@&quot; &quot;failed.&quot;
+            return 1
+        fi
</ins><span class="cx">         return 1
</span><span class="cx">     fi
</span><span class="cx">     time_stop=$(date +%s)
</span></span></pre></div>
<a id="contribmpbuildbottoolscanonical_variantstcl"></a>
<div class="addfile"><h4>Added: contrib/mp-buildbot/tools/canonical_variants.tcl (0 => 152581)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/tools/canonical_variants.tcl                                (rev 0)
+++ contrib/mp-buildbot/tools/canonical_variants.tcl        2016-09-12 19:14:24 UTC (rev 152581)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+#!/usr/bin/env 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
+# Writes the canonical list of variants as it appears in binary archive names
+# to stdout.
+#
+# Copyright (c) 2016 The MacPorts Project.
+# Copyright (c) 2016 Clemens Lang &lt;cal@macports.org&gt;
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 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 any 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 EXPRESSED 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 AUTHOR 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.
+
+package require macports
+
+if {[llength $::argv] == 0} {
+    puts stderr &quot;Usage: $argv0 &lt;portname&gt; \[(+|-)variant...\]&quot;
+    exit 1
+}
+
+# initialize macports
+if {[catch {mportinit &quot;&quot; &quot;&quot; &quot;&quot;} result]} {
+   ui_error &quot;$errorInfo&quot;
+   ui_error &quot;Failed to initialize ports sytem: $result&quot;
+   exit 1
+}
+
+# look up the path of the Portfile for the given port
+set portname [lindex $::argv 0]
+#try -pass_signal {...}
+try {
+    set result [mportlookup $portname]
+    if {[llength $result] &lt; 2} {
+        ui_error &quot;No such port: $portname&quot;
+        exit 1
+    }
+} catch {{*} eCode eMessage} {
+    ui_error &quot;mportlookup $portname failed: $eMessage&quot;
+    exit 1
+}
+
+# parse the given variants from the command line
+array set variants {}
+foreach item [lrange $::argv 1 end] {
+    foreach {_ sign variant} [regexp -all -inline -- {([-+])([[:alpha:]_]+[\w\.]*)} $item] {
+        set variants($variant) $sign
+    }
+}
+
+# open the port to get its active variants
+array set portinfo [lindex $result 1]
+#try -pass_signal {...}
+try {
+    set mport [mportopen $portinfo(porturl) [list subport $portname] [array get variants]]
+} catch {{*} eCode eMessage} {
+    ui_error &quot;mportopen ${portinfo(porturl)} failed: $eMessage&quot;
+    exit 1
+}
+
+array set info [mportinfo $mport]
+puts $info(canonical_active_variants)
+
+#try -pass_signal {...}
+try {
+    mportclose $mport
+} catch {{*} eCode eMessage} {
+    ui_warn &quot;mportclose $portname failed: $eMessage&quot;
+}
+
+# shut down MacPorts
+#try -pass_signal {...}
+try {
+    mportshutdown
+} catch {{*} eCode eMessage} {
+    ui_error &quot;mportshutdown failed: $eMessage&quot;
+    exit 1
+}
</ins><span class="cx">Property changes on: contrib/mp-buildbot/tools/canonical_variants.tcl
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>

</body>
</html>