Files
mpbb/mpbb-install-dependencies
T
Lawrence Velázquez d717dc3e7d mpbb: Separate global and subcommand options
À la Git, command-line options that are applicable to all subcommands
(e.g., `--prefix`) are now given before the subcommand name, while
options that are specific to particular subcommands (e.g.,
`--archive-site`) come after. For example, this:

    mpbb checkout --prefix /opt/local --svn /usr/bin/svn

is now:

    mpbb --prefix /opt/local checkout --svn /usr/bin/svn

This is a practical improvement as well as a conceptual one, as the
Buildbot configuration will be able to factor out the common command
prefix like so:

    cmd = ('./mpbb/mpbb', '--prefix', WithProperties(prefix))
    cmd_selfupdate = cmd + ('selfupdate',)
    cmd_checkout = cmd + ('checkout', '--svn-url', svnurl)
    [...]

For backwards compatibility with our current Buildbot deployment, all
subcommands except `list-subports` still accept `--prefix`.

git-svn-id: https://svn.macports.org/repository/macports/contrib/mp-buildbot@152525 d073be05-634f-4543-b044-5fe20cf6d1d6
2016-09-12 01:58:56 +00:00

91 lines
3.4 KiB
Bash

#!/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
# Note:
# This script is sourced by the mpbb wrapper script.
# Do not execute this directly!
install-dependencies-help() {
echo "Build and install all dependencies of port --port."
}
get-maintainers() {
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
"${option_prefix}/bin/port" info --index --maintainers --line "$@" | tr ',' '\n' | sort | uniq | tr '\n' ',' | \
awk '{gsub(/(open|no)maintainer(@macports.org)?,/, ""); print}' | \
tr '$' '\n' | sed 's/,$//' | tr '@' ';'
}
install-dependencies() {
local args
parseopt port:,prefix: "$@" || return
# shellcheck disable=SC2154
: "${option_port=}"
# shellcheck disable=SC2086
set -- ${args+"${args[@]}"}
local port=${1-${option_port}}
if [[ -z $port ]]; then
err "Must specify a port"
return 1
fi
local dependencies
local dependencies_count
local dependencies_counter
# $option_log_dir is set in mpbb
# shellcheck disable=SC2154
local log_status_dependencies="${option_log_dir}/dependencies-progress.txt"
local log_subports_progress="${option_log_dir}/ports-progress.txt"
# prepare the log file and make sure to start with an empty one
mkdir -p "${option_log_dir}"
> "$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" "$port")
if [ $? -ne 0 ]; then
echo "Calculating dependencies for '$port' failed, aborting." >&2
echo "Building '$port' ... [ERROR] (failed to calculate dependencies) maintainers: $(get-maintainers "$port")." >> "$log_subports_progress"
return 1
fi
if [ -z "$dependencies" ]; then
echo "'$port' has no dependencies, continuing." >&2
return 0
fi
dependencies_count=$(echo "$dependencies" | wc -l | sed 's/ *//g')
dependencies_counter=1
echo "Installing $dependencies_count dependencies of $port:" | tee -a "$log_status_dependencies"
echo "$dependencies" | sed -E 's/^/ - /' | tee -a "$log_status_dependencies"
echo >> "$log_status_dependencies"
echo "$dependencies" | while read -r dependency; do
# Split portname +variant1+variant2 into portname and variants, where
# the variants are optional.
depname=${dependency%% *}
depvariants=${dependency:${#depname}+1}
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"
echo "Building '$port' ... [ERROR] (failed to install dependency '${depname}') maintainers: $(get-maintainers "$port" "${depname}")." >> "$log_subports_progress"
return 1
else
echo "[OK]" >> "$log_status_dependencies"
dependencies_counter=$((dependencies_counter + 1))
fi
done
}