[151047] contrib/mp-buildbot

cal at macports.org cal at macports.org
Sat Aug 6 06:00:13 PDT 2016


Revision: 151047
          https://trac.macports.org/changeset/151047
Author:   cal at macports.org
Date:     2016-08-06 06:00:13 -0700 (Sat, 06 Aug 2016)
Log Message:
-----------
mp-buildbot: Install dependencies one-by-one

Install dependencies step by step in install-dependencies so that we can track
which dependencies failed and start building a fail cache again. Additionally,
this fixes a problem where
 > port echo depof:wine
would print a list of dependencies but those dependencies were not installed
with the +universal variant as required. To do this, tools/dependencies.tcl
calls mportdepends, which determines the necessary variants of the
dependencies.

Modified Paths:
--------------
    contrib/mp-buildbot/mpbb-install-dependencies

Added Paths:
-----------
    contrib/mp-buildbot/tools/dependencies.tcl

Modified: contrib/mp-buildbot/mpbb-install-dependencies
===================================================================
--- contrib/mp-buildbot/mpbb-install-dependencies	2016-08-06 12:45:17 UTC (rev 151046)
+++ contrib/mp-buildbot/mpbb-install-dependencies	2016-08-06 13:00:13 UTC (rev 151047)
@@ -10,19 +10,40 @@
 }
 
 install-dependencies() {
+    local dependencies
+
     if [ -z "${option_port}" ]; then
         errmsg "--port is required"
         return 1
     fi
 
-    # skip if the port has no dependencies
-    if [ -z "$(${option_prefix}/bin/port echo depof:${option_port})" ]; then
+    # calculate list of dependencies in-order
+    dependencies=$("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/dependencies.tcl" "${option_port}")
+    if [ $? -ne 0 ]; then
+        echo "Calculating dependencies for '${option_port}' failed, cleaning up..." >&2
+        cleanup
+        return 1
+    fi
+
+    if [ -z "$dependencies" ]; then
+        echo "'${option_port}' has no dependencies, continuing..."
         return 0
     fi
 
-    if ! "${option_prefix}/bin/port" -d install --unrequested depof:"${option_port}"; then
-        echo "Build failed, cleaning up..."
-        cleanup
-        return 1
-    fi
+    echo "Installing dependencies:"
+    echo "$dependencies" | sed -E 's/^/ - /'
+
+    echo "$dependencies" | while read dependency; do
+        # Split portname +variant1+variant2 into portname and variants, where
+        # the variants are optional.
+        depname=${dependency%% *}
+        depvariants=${dependency:${#depname}}
+
+        echo "Installing dependency '${depname}', variants: '${depvariants}'"
+        if ! "${option_prefix}/bin/port" -d install --unrequested "$depname" $depvariants; then
+            echo "Build of dependency '${depname}' failed, cleaning up..." >&2
+            cleanup
+            return 1
+        fi
+    done
 }

Added: contrib/mp-buildbot/tools/dependencies.tcl
===================================================================
--- contrib/mp-buildbot/tools/dependencies.tcl	                        (rev 0)
+++ contrib/mp-buildbot/tools/dependencies.tcl	2016-08-06 13:00:13 UTC (rev 151047)
@@ -0,0 +1,115 @@
+#!/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 a list of dependencies for a given port including variants (e.g. if
+# the universal variant is required) to stdout.
+#
+# Copyright (c) 2016 The MacPorts Project.
+# Copyright (c) 2016 Clemens Lang <cal at macports.org>
+#
+# 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 "Usage: $argv0 <portname>"
+    exit 1
+}
+
+# initialize macports
+if {[catch {mportinit "" "" ""} result]} {
+   ui_error "$errorInfo"
+   ui_error "Failed to initialize ports sytem: $result"
+   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] < 2} {
+        ui_error "No such port: $portname"
+        exit 1
+    }
+} catch {{*} eCode eMessage} {
+    ui_error "mportlookup $portname failed: $eMessage"
+    exit 1
+}
+
+# open the port so we can run dependency calculation
+array set portinfo [lindex $result 1]
+#try -pass_signal {
+try {
+    set mport [mportopen $portinfo(porturl) [list subport $portname] {}]
+} catch {{*} eCode eMessage} {
+    ui_error "mportopen ${portinfo(porturl)} failed: $eMessage"
+    exit 1
+}
+
+# gather a list of dependencies with the correct variants (+universal is dealt
+# with in specific ways)
+if {[mportdepends $mport "activate"] != 0} {
+    ui_error "mportdepends $portname activate failed."
+    exit 1
+}
+
+# sort these dependencies topologically; exclude the given port itself
+set dlist [dlist_append_dependents $macports::open_mports $mport {}]
+dlist_delete dlist $mport
+
+## print dependencies with variants
+foreach ditem $dlist {
+    set depname [ditem_key $ditem provides]
+    array set depinfo [mportinfo $ditem]
+
+    puts [string trim "$depname $depinfo(canonical_active_variants)"]
+}
+
+# close all open ports
+foreach ditem $dlist {
+    #try -pass_signal {
+    try {
+        mportclose $ditem
+    } catch {{*} eCode eMessage} {
+        ui_warn "mportclose [ditem_key $ditem provides] failed: $eMessage"
+    }
+}
+#try -pass_signal {
+try {
+    mportclose $mport
+} catch {{*} eCode eMessage} {
+    ui_error "mportclose $portname failed: $eMessage"
+    exit 1
+}
+
+# shut down MacPorts
+#try -pass_signal {
+try {
+    mportshutdown
+} catch {{*} eCode eMessage} {
+    ui_error "mportshutdown failed: $eMessage"
+    exit 1
+}


Property changes on: contrib/mp-buildbot/tools/dependencies.tcl
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160806/67f5ee5c/attachment.html>


More information about the macports-changes mailing list