<!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>[151475] 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/151475">151475</a></dd>
<dt>Author</dt> <dd>cal@macports.org</dd>
<dt>Date</dt> <dd>2016-08-16 15:22:14 -0700 (Tue, 16 Aug 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>mp-buildbot: Fix SC warnings, improve err handling
Fix or disable all remaining ShellCheck warnings, add and/or improve error
handling, make sure everything is properly quoted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#contribmpbuildbotmpbbcleanup">contrib/mp-buildbot/mpbb-cleanup</a></li>
<li><a href="#contribmpbuildbotmpbbgatherarchives">contrib/mp-buildbot/mpbb-gather-archives</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>
<li><a href="#contribmpbuildbotmpbblistsubports">contrib/mp-buildbot/mpbb-list-subports</a></li>
<li><a href="#contribmpbuildbotmpbbselfupdate">contrib/mp-buildbot/mpbb-selfupdate</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="contribmpbuildbotmpbbcleanup"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-cleanup (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-cleanup        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-cleanup        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -10,15 +10,15 @@
</span><span class="cx">
</span><span class="cx"> cleanup() {
</span><span class="cx"> echo "----> Deactivating ports"
</span><del>-        # $option_prefix is set by mpbb
-        # shellcheck disable=SC2154
</del><ins>+ # $option_prefix is set by mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if [ -n "$("${option_prefix}/bin/port" -q installed active)" ]; then
</span><span class="cx"> "${option_prefix}/bin/port" -fp deactivate active
</span><span class="cx"> fi
</span><span class="cx"> echo
</span><span class="cx"> echo "----> Uninstalling obsolete ports"
</span><del>-        # $thisdir is set by mpbb and points to the directory in which this script resides
-        # shellcheck disable=SC2154
</del><ins>+ # $thisdir is set by mpbb and points to the directory in which this script resides
+ # shellcheck disable=SC2154
</ins><span class="cx"> "${option_prefix}/bin/port-tclsh" "${thisdir}/tools/uninstall-old-ports.tcl"
</span><span class="cx"> echo
</span><span class="cx"> echo "----> Deleting distfiles"
</span></span></pre></div>
<a id="contribmpbuildbotmpbbgatherarchives"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-gather-archives (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-gather-archives        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-gather-archives        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -11,8 +11,12 @@
</span><span class="cx">
</span><span class="cx"> gather-archives() {
</span><span class="cx"> curl=/usr/bin/curl
</span><ins>+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> tclsh=${option_prefix}/bin/port-tclsh
</span><span class="cx">
</span><ins>+ # $option_staging_dir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if [ -d "${option_staging_dir}" ]; then
</span><span class="cx"> find "${option_staging_dir}" -type f -delete -print | sed -E -e "s|^.*/||" -e 's/^/Deleting previously staged archive: /'
</span><span class="cx"> rm -rf "${option_staging_dir}"
</span><span class="lines">@@ -26,7 +30,11 @@
</span><span class="cx"> archive_port=$(basename "$(dirname "${archive_path}")")
</span><span class="cx"> archive_basename=$(basename "${archive_path}")
</span><span class="cx">
</span><ins>+ # $option_archive_site is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if ! ${curl} -fIsL "${option_archive_site}/${archive_port}/${archive_basename}" > /dev/null; then
</span><ins>+ # $option_workdir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if "${tclsh}" "${option_workdir}/tools/port_binary_distributable.tcl" -v "${archive_port}"; then
</span><span class="cx"> echo "Staging archive for upload: ${archive_basename}"
</span><span class="cx"> mkdir -p "${option_staging_dir}/${archive_port}" || { status=$?; break; }
</span></span></pre></div>
<a id="contribmpbuildbotmpbbinstalldependencies"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-install-dependencies (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-install-dependencies        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-install-dependencies        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -13,10 +13,12 @@
</span><span class="cx"> local dependencies
</span><span class="cx"> local dependencies_count
</span><span class="cx"> local dependencies_counter
</span><ins>+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> local log_status_dependencies="${option_logdir}/dependencies-progress.txt"
</span><span class="cx"> local log_subports_progress="${option_logdir}/ports-progress.txt"
</span><span class="cx">
</span><del>- if [ -z "${option_port}" ]; then
</del><ins>+ if [ -z "${option_port:-}" ]; then
</ins><span class="cx"> errmsg "--port is required"
</span><span class="cx"> return 1
</span><span class="cx"> fi
</span><span class="lines">@@ -26,6 +28,8 @@
</span><span class="cx"> > "$log_status_dependencies"
</span><span class="cx">
</span><span class="cx"> # calculate list of dependencies in-order
</span><ins>+ # $option_prefix and $thisdir are set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> dependencies=$("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/dependencies.tcl" "${option_port}")
</span><span class="cx"> if [ $? -ne 0 ]; then
</span><span class="cx"> echo "Calculating dependencies for '${option_port}' failed, aborting." >&2
</span><span class="lines">@@ -51,7 +55,7 @@
</span><span class="cx">
</span><span class="cx"> echo >> "$log_status_dependencies"
</span><span class="cx">
</span><del>- echo "$dependencies" | while read dependency; do
</del><ins>+ echo "$dependencies" | 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="lines">@@ -60,6 +64,8 @@
</span><span class="cx"> text="Installing dependency ($dependencies_counter of $dependencies_count) '${depname}' with variants '${depvariants}'"
</span><span class="cx"> echo "----> ${text}"
</span><span class="cx"> echo -n "${text} ... " >> "$log_status_dependencies"
</span><ins>+ # $depvariants isn't quoted on purpose
+ # shellcheck disable=SC2086
</ins><span class="cx"> if ! "${option_prefix}/bin/port" -d install --unrequested "$depname" $depvariants; then
</span><span class="cx"> echo "Build of dependency '${depname}' failed, aborting." >&2
</span><span class="cx"> echo "[FAIL]" >> "$log_status_dependencies"
</span></span></pre></div>
<a id="contribmpbuildbotmpbbinstallport"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-install-port (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-install-port        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-install-port        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -10,12 +10,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> install-port() {
</span><ins>+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> local log_port_contents="${option_logdir}/port-contents.txt"
</span><span class="cx"> local log_port_stats="${option_logdir}/port-statistics.txt"
</span><span class="cx"> local log_port_main="${option_logdir}/main.log"
</span><span class="cx"> local log_subports_progress="${option_logdir}/ports-progress.txt"
</span><span class="cx">
</span><del>- if [ -z "${option_port}" ]; then
</del><ins>+ if [ -z "${option_port:-}" ]; then
</ins><span class="cx"> errmsg "--port is required"
</span><span class="cx"> return 1
</span><span class="cx"> fi
</span><span class="lines">@@ -28,13 +30,17 @@
</span><span class="cx"> # log: summary for the portwatcher
</span><span class="cx"> echo -n "- Installing ${option_port} ... " >> "$log_subports_progress"
</span><span class="cx">
</span><del>- local time_start=$(date +%s)
</del><ins>+ local time_start
+ local time_stop
+ time_start=$(date +%s)
+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if ! "${option_prefix}/bin/port" -dk install "${option_port}"; then
</span><span class="cx"> echo "Build of '${option_port}' failed."
</span><span class="cx"> echo "[FAIL]" >> "$log_subports_progress"
</span><span class="cx"> return 1
</span><span class="cx"> fi
</span><del>- local time_stop=$(date +%s)
</del><ins>+ time_stop=$(date +%s)
</ins><span class="cx">
</span><span class="cx"> echo "[OK]" >> "$log_subports_progress"
</span><span class="cx">
</span><span class="lines">@@ -44,22 +50,41 @@
</span><span class="cx"> # TODO: printing statistics (and installing the port + dependencies)
</span><span class="cx"> # only makes sense when the port hasn't been installed previously
</span><span class="cx"> # log: statistics
</span><del>- echo "time: $(($time_stop - $time_start))s" >> "$log_port_stats"
</del><ins>+ echo "time: $((time_stop - time_start))s" >> "$log_port_stats"
</ins><span class="cx">
</span><del>- local port_workdir=$("${option_prefix}/bin/port" work "${option_port}")
- local port_workdir_size=$(du -ks "$port_workdir" | sed 's/^ *//' | tr '\t' '\n' | head -n 1)
- echo "workdir: ${port_workdir_size}k" >> "$log_port_stats"
- local port_destdir="$port_workdir/destroot"
- if [ -d "$port_destdir" ]; then
- local port_destdir_size=$(du -ks "$port_destdir" | sed 's/^ *//' | tr '\t' '\n' | head -n 1)
- echo "destdir: ${port_destdir_size}k" >> "$log_port_stats"
- else
- echo "destdir: -" >> "$log_port_stats"
</del><ins>+ local port_workdir
+ local port_workdir_size=""
+ local port_destdir_size=""
+ local print_arg_workdir="ERROR"
+ local print_arg_destdir="ERROR"
+ # First, compute port_workdir_size and port_destdir_size
+ port_workdir=$("${option_prefix}/bin/port" work "${option_port}")
+ if [ -n "$port_workdir" ]; then
+ port_workdir_size=$(du -ks "$port_workdir" | sed 's/^ *//' | tr '\t' '\n' | head -n 1)
+ if [ $? -eq 0 ] && [ -n "$port_workdir_size" ]; then
+ print_arg_workdir="${port_workdir_size}k"
+ fi
+
+ local port_destdir="$port_workdir/destroot"
+ # if we arrive here, 'port work $option_port' was successful, so we're
+ # at least going to print 'destdir: -'
+ print_arg_destdir="-"
+ if [ -d "$port_destdir" ]; then
+ port_destdir_size=$(du -ks "$port_destdir" | sed 's/^ *//' | tr '\t' '\n' | head -n 1)
+ if [ $? -eq 0 ] && [ -n "$port_destdir_size" ]; then
+ print_arg_destdir="${port_destdir_size}k"
+ fi
+ fi
</ins><span class="cx"> fi
</span><ins>+ # Then print them, or on error (or if destdir doesn't exist), print the
+ # appropriate message
+ echo "workdir: $print_arg_workdir" >> "$log_port_stats"
+ echo "destdir: $print_arg_destdir" >> "$log_port_stats"
</ins><span class="cx">
</span><span class="cx"> # log: main.log
</span><del>- local port_mainlog=$("${option_prefix}/bin/port" logfile "${option_port}")
- if [ -f $port_mainlog ]; then
</del><ins>+ local port_mainlog
+ port_mainlog=$("${option_prefix}/bin/port" logfile "${option_port}")
+ if [ $? -eq 0 ] && [ -f "$port_mainlog" ]; then
</ins><span class="cx"> cp -f "$port_mainlog" "$log_port_main"
</span><span class="cx"> fi
</span><span class="cx"> }
</span></span></pre></div>
<a id="contribmpbuildbotmpbblistsubports"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-list-subports (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-list-subports        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-list-subports        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -18,10 +18,14 @@
</span><span class="cx"> local exclude
</span><span class="cx"> local exclude_reasons
</span><span class="cx"> local reason
</span><ins>+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> local log_subports_progress="${option_logdir}/ports-progress.txt"
</span><span class="cx">
</span><span class="cx"> os_version="$(sw_vers -productVersion | cut -d . -f 1-2)"
</span><span class="cx"> is_64bit_capable="$(sysctl -n hw.cpu64bit_capable)"
</span><ins>+ # $optoin_prefix is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> ports=$("${option_prefix}/bin/port" -q info --index --line --name "${portname}" "subportof:${portname}" 2>/dev/null) || return $?
</span><span class="cx"> for port in $ports; do
</span><span class="cx"> exclude=0
</span><span class="lines">@@ -31,6 +35,8 @@
</span><span class="cx"> exclude=1
</span><span class="cx"> exclude_reasons+=("its name contains 'graveyard'")
</span><span class="cx"> else
</span><ins>+ # $thisdir is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> for portgroup in $("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/portgroups.tcl" "$port"); do
</span><span class="cx"> if [ "$portgroup" = "obsolete-1.0" ]; then
</span><span class="cx"> exclude=1
</span><span class="lines">@@ -41,7 +47,7 @@
</span><span class="cx">
</span><span class="cx"> if [[ $exclude -eq 0 && "${os_version}" = "10.6" && "${is_64bit_capable}" = "0" ]]; then
</span><span class="cx"> supported_archs=$("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/supported-archs.tcl" "${port}")
</span><del>- if [[ -n "${supported_archs}" && !("${supported_archs}" == *"x86_64"* && "${supported_archs}" == *"i386"*) ]]; then
</del><ins>+ if [[ -n "${supported_archs}" && ! ("${supported_archs}" == *"x86_64"* && "${supported_archs}" == *"i386"*) ]]; then
</ins><span class="cx"> exclude=1
</span><span class="cx"> exclude_reasons+=("the ${os_version}_x86_64 builder will build it")
</span><span class="cx"> fi
</span><span class="lines">@@ -69,7 +75,7 @@
</span><span class="cx"> list-subports() {
</span><span class="cx"> local log_subports_progress="${option_logdir}/ports-progress.txt"
</span><span class="cx">
</span><del>- if [ $# -le 0 -a -z "${option_port}" ]; then
</del><ins>+ if [ $# -le 0 ] && [ -z "${option_port:-}" ]; then
</ins><span class="cx"> errmsg "Either --port or a list of positional arguments with port names is required."
</span><span class="cx"> return 1
</span><span class="cx"> fi
</span></span></pre></div>
<a id="contribmpbuildbotmpbbselfupdate"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-selfupdate (151474 => 151475)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-selfupdate        2016-08-16 21:50:08 UTC (rev 151474)
+++ contrib/mp-buildbot/mpbb-selfupdate        2016-08-16 22:22:14 UTC (rev 151475)
</span><span class="lines">@@ -9,6 +9,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> selfupdate() {
</span><ins>+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
</ins><span class="cx"> if [ ! -f "${option_prefix}/bin/port" ]; then
</span><span class="cx"> macports_version=2.3.4
</span><span class="cx"> macports_distname=MacPorts-${macports_version}
</span><span class="lines">@@ -20,8 +22,8 @@
</span><span class="cx"> tar -xjf ${macports_distfile} || return $?
</span><span class="cx"> fi
</span><span class="cx"> cd ${macports_distname} || return $?
</span><del>- ./configure --prefix=${option_prefix} --enable-readline || return $?
- make -j$(sysctl -n hw.activecpu) || return $?
</del><ins>+ ./configure --prefix="${option_prefix}" --enable-readline || return $?
+ make -j"$(sysctl -n hw.activecpu)" || return $?
</ins><span class="cx"> make install || return $?
</span><span class="cx"> cd .. || return $?
</span><span class="cx"> rm -rf ${macports_distfile} ${macports_distname} || return $?
</span></span></pre>
</div>
</div>
</body>
</html>