[151475] contrib/mp-buildbot
cal at macports.org
cal at macports.org
Tue Aug 16 15:22:14 PDT 2016
Revision: 151475
https://trac.macports.org/changeset/151475
Author: cal at macports.org
Date: 2016-08-16 15:22:14 -0700 (Tue, 16 Aug 2016)
Log Message:
-----------
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.
Modified Paths:
--------------
contrib/mp-buildbot/mpbb-cleanup
contrib/mp-buildbot/mpbb-gather-archives
contrib/mp-buildbot/mpbb-install-dependencies
contrib/mp-buildbot/mpbb-install-port
contrib/mp-buildbot/mpbb-list-subports
contrib/mp-buildbot/mpbb-selfupdate
Modified: contrib/mp-buildbot/mpbb-cleanup
===================================================================
--- 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)
@@ -10,15 +10,15 @@
cleanup() {
echo "----> Deactivating ports"
- # $option_prefix is set by mpbb
- # shellcheck disable=SC2154
+ # $option_prefix is set by mpbb
+ # shellcheck disable=SC2154
if [ -n "$("${option_prefix}/bin/port" -q installed active)" ]; then
"${option_prefix}/bin/port" -fp deactivate active
fi
echo
echo "----> Uninstalling obsolete ports"
- # $thisdir is set by mpbb and points to the directory in which this script resides
- # shellcheck disable=SC2154
+ # $thisdir is set by mpbb and points to the directory in which this script resides
+ # shellcheck disable=SC2154
"${option_prefix}/bin/port-tclsh" "${thisdir}/tools/uninstall-old-ports.tcl"
echo
echo "----> Deleting distfiles"
Modified: contrib/mp-buildbot/mpbb-gather-archives
===================================================================
--- 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)
@@ -11,8 +11,12 @@
gather-archives() {
curl=/usr/bin/curl
+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
tclsh=${option_prefix}/bin/port-tclsh
+ # $option_staging_dir is set in mpbb
+ # shellcheck disable=SC2154
if [ -d "${option_staging_dir}" ]; then
find "${option_staging_dir}" -type f -delete -print | sed -E -e "s|^.*/||" -e 's/^/Deleting previously staged archive: /'
rm -rf "${option_staging_dir}"
@@ -26,7 +30,11 @@
archive_port=$(basename "$(dirname "${archive_path}")")
archive_basename=$(basename "${archive_path}")
+ # $option_archive_site is set in mpbb
+ # shellcheck disable=SC2154
if ! ${curl} -fIsL "${option_archive_site}/${archive_port}/${archive_basename}" > /dev/null; then
+ # $option_workdir is set in mpbb
+ # shellcheck disable=SC2154
if "${tclsh}" "${option_workdir}/tools/port_binary_distributable.tcl" -v "${archive_port}"; then
echo "Staging archive for upload: ${archive_basename}"
mkdir -p "${option_staging_dir}/${archive_port}" || { status=$?; break; }
Modified: contrib/mp-buildbot/mpbb-install-dependencies
===================================================================
--- 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)
@@ -13,10 +13,12 @@
local dependencies
local dependencies_count
local dependencies_counter
+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
local log_status_dependencies="${option_logdir}/dependencies-progress.txt"
local log_subports_progress="${option_logdir}/ports-progress.txt"
- if [ -z "${option_port}" ]; then
+ if [ -z "${option_port:-}" ]; then
errmsg "--port is required"
return 1
fi
@@ -26,6 +28,8 @@
> "$log_status_dependencies"
# calculate list of dependencies in-order
+ # $option_prefix and $thisdir are set in mpbb
+ # shellcheck disable=SC2154
dependencies=$("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/dependencies.tcl" "${option_port}")
if [ $? -ne 0 ]; then
echo "Calculating dependencies for '${option_port}' failed, aborting." >&2
@@ -51,7 +55,7 @@
echo >> "$log_status_dependencies"
- echo "$dependencies" | while read dependency; do
+ echo "$dependencies" | while read -r dependency; do
# Split portname +variant1+variant2 into portname and variants, where
# the variants are optional.
depname=${dependency%% *}
@@ -60,6 +64,8 @@
text="Installing dependency ($dependencies_counter of $dependencies_count) '${depname}' with variants '${depvariants}'"
echo "----> ${text}"
echo -n "${text} ... " >> "$log_status_dependencies"
+ # $depvariants isn't quoted on purpose
+ # shellcheck disable=SC2086
if ! "${option_prefix}/bin/port" -d install --unrequested "$depname" $depvariants; then
echo "Build of dependency '${depname}' failed, aborting." >&2
echo "[FAIL]" >> "$log_status_dependencies"
Modified: contrib/mp-buildbot/mpbb-install-port
===================================================================
--- 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)
@@ -10,12 +10,14 @@
}
install-port() {
+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
local log_port_contents="${option_logdir}/port-contents.txt"
local log_port_stats="${option_logdir}/port-statistics.txt"
local log_port_main="${option_logdir}/main.log"
local log_subports_progress="${option_logdir}/ports-progress.txt"
- if [ -z "${option_port}" ]; then
+ if [ -z "${option_port:-}" ]; then
errmsg "--port is required"
return 1
fi
@@ -28,13 +30,17 @@
# log: summary for the portwatcher
echo -n "- Installing ${option_port} ... " >> "$log_subports_progress"
- local time_start=$(date +%s)
+ local time_start
+ local time_stop
+ time_start=$(date +%s)
+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
if ! "${option_prefix}/bin/port" -dk install "${option_port}"; then
echo "Build of '${option_port}' failed."
echo "[FAIL]" >> "$log_subports_progress"
return 1
fi
- local time_stop=$(date +%s)
+ time_stop=$(date +%s)
echo "[OK]" >> "$log_subports_progress"
@@ -44,22 +50,41 @@
# TODO: printing statistics (and installing the port + dependencies)
# only makes sense when the port hasn't been installed previously
# log: statistics
- echo "time: $(($time_stop - $time_start))s" >> "$log_port_stats"
+ echo "time: $((time_stop - time_start))s" >> "$log_port_stats"
- 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"
+ 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
fi
+ # 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"
# log: main.log
- local port_mainlog=$("${option_prefix}/bin/port" logfile "${option_port}")
- if [ -f $port_mainlog ]; then
+ local port_mainlog
+ port_mainlog=$("${option_prefix}/bin/port" logfile "${option_port}")
+ if [ $? -eq 0 ] && [ -f "$port_mainlog" ]; then
cp -f "$port_mainlog" "$log_port_main"
fi
}
Modified: contrib/mp-buildbot/mpbb-list-subports
===================================================================
--- 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)
@@ -18,10 +18,14 @@
local exclude
local exclude_reasons
local reason
+ # $option_logdir is set in mpbb
+ # shellcheck disable=SC2154
local log_subports_progress="${option_logdir}/ports-progress.txt"
os_version="$(sw_vers -productVersion | cut -d . -f 1-2)"
is_64bit_capable="$(sysctl -n hw.cpu64bit_capable)"
+ # $optoin_prefix is set in mpbb
+ # shellcheck disable=SC2154
ports=$("${option_prefix}/bin/port" -q info --index --line --name "${portname}" "subportof:${portname}" 2>/dev/null) || return $?
for port in $ports; do
exclude=0
@@ -31,6 +35,8 @@
exclude=1
exclude_reasons+=("its name contains 'graveyard'")
else
+ # $thisdir is set in mpbb
+ # shellcheck disable=SC2154
for portgroup in $("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/portgroups.tcl" "$port"); do
if [ "$portgroup" = "obsolete-1.0" ]; then
exclude=1
@@ -41,7 +47,7 @@
if [[ $exclude -eq 0 && "${os_version}" = "10.6" && "${is_64bit_capable}" = "0" ]]; then
supported_archs=$("${option_prefix}/bin/port-tclsh" "${thisdir}/tools/supported-archs.tcl" "${port}")
- if [[ -n "${supported_archs}" && !("${supported_archs}" == *"x86_64"* && "${supported_archs}" == *"i386"*) ]]; then
+ if [[ -n "${supported_archs}" && ! ("${supported_archs}" == *"x86_64"* && "${supported_archs}" == *"i386"*) ]]; then
exclude=1
exclude_reasons+=("the ${os_version}_x86_64 builder will build it")
fi
@@ -69,7 +75,7 @@
list-subports() {
local log_subports_progress="${option_logdir}/ports-progress.txt"
- if [ $# -le 0 -a -z "${option_port}" ]; then
+ if [ $# -le 0 ] && [ -z "${option_port:-}" ]; then
errmsg "Either --port or a list of positional arguments with port names is required."
return 1
fi
Modified: contrib/mp-buildbot/mpbb-selfupdate
===================================================================
--- 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)
@@ -9,6 +9,8 @@
}
selfupdate() {
+ # $option_prefix is set in mpbb
+ # shellcheck disable=SC2154
if [ ! -f "${option_prefix}/bin/port" ]; then
macports_version=2.3.4
macports_distname=MacPorts-${macports_version}
@@ -20,8 +22,8 @@
tar -xjf ${macports_distfile} || return $?
fi
cd ${macports_distname} || return $?
- ./configure --prefix=${option_prefix} --enable-readline || return $?
- make -j$(sysctl -n hw.activecpu) || return $?
+ ./configure --prefix="${option_prefix}" --enable-readline || return $?
+ make -j"$(sysctl -n hw.activecpu)" || return $?
make install || return $?
cd .. || return $?
rm -rf ${macports_distfile} ${macports_distname} || return $?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160816/2f092053/attachment-0001.html>
More information about the macports-changes
mailing list