download_and_compile.sh: improve management of intercomponent dependencies
- new function _depends() to allow declaring intercomponent dependencies using a declarative style; - declare that FGFS depends on SIMGEAR (TERRAGEAR depends on SIMGEAR as well, but this was already there---just not in the new, declarative style); - print and log automatically-added components; when this happens, give a hint about --ignore-intercomponent-deps; - log the value of IGNORE_INTERCOMPONENT_DEPS, which reflects whether --ignore-intercomponent-deps was used.
This commit is contained in:
parent
f190773790
commit
39c1754a7f
1 changed files with 41 additions and 4 deletions
|
@ -278,6 +278,23 @@ function _find_package_alternative(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If component $1 is in WHATTOBUILD, add components $2, $3, etc., to
|
||||||
|
# WHATTOBUILD unless they are already there.
|
||||||
|
function _depends(){
|
||||||
|
local component="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if _elementIn "$component" "${WHATTOBUILD[@]}"; then
|
||||||
|
for dependency in "$@"; do
|
||||||
|
if ! _elementIn "$dependency" "${WHATTOBUILD[@]}"; then
|
||||||
|
_printLog "$component: adding depended-on component $dependency"
|
||||||
|
WHATTOBUILD+=("$dependency")
|
||||||
|
nb_added_intercomponent_deps=$((nb_added_intercomponent_deps + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _printVersion(){
|
function _printVersion(){
|
||||||
echo "$PROGNAME version $VERSION"
|
echo "$PROGNAME version $VERSION"
|
||||||
echo
|
echo
|
||||||
|
@ -392,6 +409,10 @@ JOPTION=""
|
||||||
OOPTION=""
|
OOPTION=""
|
||||||
BUILD_TYPE="RelWithDebInfo"
|
BUILD_TYPE="RelWithDebInfo"
|
||||||
|
|
||||||
|
# Non user-exposed variable used to decide whether to print a “helpful”
|
||||||
|
# message
|
||||||
|
declare -i nb_added_intercomponent_deps=0
|
||||||
|
|
||||||
declare -a UNMATCHED_OPTIONAL_PKG_ALTERNATIVES
|
declare -a UNMATCHED_OPTIONAL_PKG_ALTERNATIVES
|
||||||
|
|
||||||
# Will hold the per-repository download settings.
|
# Will hold the per-repository download settings.
|
||||||
|
@ -576,6 +597,7 @@ echo '* *'
|
||||||
echo '* download_and_compile.sh -j$(nproc) *'
|
echo '* download_and_compile.sh -j$(nproc) *'
|
||||||
echo '* *'
|
echo '* *'
|
||||||
echo '**********************************************************************'
|
echo '**********************************************************************'
|
||||||
|
echo
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
#######################################################
|
#######################################################
|
||||||
|
@ -584,6 +606,7 @@ echo "$0 $*" > "$LOGFILE"
|
||||||
_log "VERSION=$VERSION"
|
_log "VERSION=$VERSION"
|
||||||
_log "APT_GET_UPDATE=$APT_GET_UPDATE"
|
_log "APT_GET_UPDATE=$APT_GET_UPDATE"
|
||||||
_log "DOWNLOAD_PACKAGES=$DOWNLOAD_PACKAGES"
|
_log "DOWNLOAD_PACKAGES=$DOWNLOAD_PACKAGES"
|
||||||
|
_log "IGNORE_INTERCOMPONENT_DEPS=$IGNORE_INTERCOMPONENT_DEPS"
|
||||||
_log "COMPILE=$COMPILE"
|
_log "COMPILE=$COMPILE"
|
||||||
_log "RECONFIGURE=$RECONFIGURE"
|
_log "RECONFIGURE=$RECONFIGURE"
|
||||||
_log "DOWNLOAD=$DOWNLOAD"
|
_log "DOWNLOAD=$DOWNLOAD"
|
||||||
|
@ -610,10 +633,25 @@ _logSep
|
||||||
# ****************************************************************************
|
# ****************************************************************************
|
||||||
|
|
||||||
if [ "$IGNORE_INTERCOMPONENT_DEPS" = "n" ]; then
|
if [ "$IGNORE_INTERCOMPONENT_DEPS" = "n" ]; then
|
||||||
|
# FlightGear requires SimGear
|
||||||
|
_depends FGFS SIMGEAR
|
||||||
# TerraGear requires SimGear
|
# TerraGear requires SimGear
|
||||||
if _elementIn "TERRAGEAR" "${WHATTOBUILD[@]}" && \
|
_depends TERRAGEAR SIMGEAR
|
||||||
! _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then
|
|
||||||
WHATTOBUILD+=(SIMGEAR)
|
# Print a helpful message if some components were automatically added
|
||||||
|
if (( nb_added_intercomponent_deps > 0 )); then
|
||||||
|
if (( nb_added_intercomponent_deps > 1 )); then
|
||||||
|
comp_word='components'
|
||||||
|
else
|
||||||
|
comp_word='component'
|
||||||
|
fi
|
||||||
|
_printLog "$PROGNAME: automatically added $nb_added_intercomponent_deps" \
|
||||||
|
"$comp_word based on"
|
||||||
|
_printLog "intercomponent dependencies. Use option" \
|
||||||
|
"--ignore-intercomponent-deps if you"
|
||||||
|
_printLog "want to disable this behavior."
|
||||||
|
_printLog
|
||||||
|
unset -v comp_word
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -707,7 +745,6 @@ if [[ "$DOWNLOAD_PACKAGES" = "y" ]]; then
|
||||||
|
|
||||||
_aptInstall "${PKG[@]}"
|
_aptInstall "${PKG[@]}"
|
||||||
else
|
else
|
||||||
_printLog
|
|
||||||
_printLog "Note: option -p of $PROGNAME set to 'n' (no), therefore no"
|
_printLog "Note: option -p of $PROGNAME set to 'n' (no), therefore no"
|
||||||
_printLog " package will be installed via ${PKG_MGR}. Compilation of" \
|
_printLog " package will be installed via ${PKG_MGR}. Compilation of" \
|
||||||
"some components"
|
"some components"
|
||||||
|
|
Loading…
Reference in a new issue