1
0
Fork 0

download_and_compile.sh: use _printLog() wherever appropriate

This is a logical follow-up for commit
8a7fd33b2b, which introduced the
_printLog() function.
This commit is contained in:
Florent Rougon 2018-10-11 11:47:39 +02:00
parent 77384be44a
commit 6520925c5b

View file

@ -169,20 +169,19 @@ function _mandatory_pkg_alternative(){
local pkg local pkg
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo "Empty package alternative: this is a bug in the script, aborting." \ _printLog \
| tee -a "$LOGFILE" "Empty package alternative: this is a bug in the script, aborting."
exit 1 exit 1
fi fi
echo "Considering a package alternative:" "$@" | tee -a "$LOGFILE" _printLog "Considering a package alternative: $*"
pkg=$(_find_package_alternative "$@") pkg=$(_find_package_alternative "$@")
if [[ -n "$pkg" ]]; then if [[ -n "$pkg" ]]; then
echo "Package alternative matched for $pkg" | tee -a "$LOGFILE" _printLog "Package alternative matched for $pkg"
PKG="$PKG $pkg" PKG="$PKG $pkg"
else else
echo "No match found for the package alternative, aborting." \ _printLog "No match found for the package alternative, aborting."
| tee -a "$LOGFILE"
exit 1 exit 1
fi fi
@ -198,20 +197,20 @@ function _optional_pkg_alternative(){
local pkg local pkg
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 ]]; then
echo "Empty optional package alternative: this is a bug in the script," \ _printLog "Empty optional package alternative: this is a bug in the" \
"aborting." | tee -a "$LOGFILE" "script, aborting."
exit 1 exit 1
fi fi
echo "Considering an optional package alternative:" "$@" | tee -a "$LOGFILE" _printLog "Considering an optional package alternative: $*"
pkg=$(_find_package_alternative "$@") pkg=$(_find_package_alternative "$@")
if [[ -n "$pkg" ]]; then if [[ -n "$pkg" ]]; then
echo "Optional package alternative matched for $pkg" | tee -a "$LOGFILE" _printLog "Optional package alternative matched for $pkg"
PKG="$PKG $pkg" PKG="$PKG $pkg"
else else
echo "No match found for the optional package alternative, continuing" \ _printLog "No match found for the optional package alternative," \
"anyway." | tee -a "$LOGFILE" "continuing anyway."
# "$*" so that we only add one element to the array in this line # "$*" so that we only add one element to the array in this line
UNMATCHED_OPTIONAL_PKG_ALTERNATIVES+=("$*") UNMATCHED_OPTIONAL_PKG_ALTERNATIVES+=("$*")
fi fi
@ -639,9 +638,9 @@ CMAKE_INSTALL_DIR=cmake
INSTALL_DIR_CMAKE=$INSTALL_DIR/$CMAKE_INSTALL_DIR INSTALL_DIR_CMAKE=$INSTALL_DIR/$CMAKE_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "CMAKE" "${WHATTOBUILD[@]}"; then if _elementIn "CMAKE" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "*************** CMAKE ******************" | tee -a $LOGFILE _printLog "*************** CMAKE ******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "cmake" mkdir -p "cmake"
cd "$CBD"/cmake cd "$CBD"/cmake
@ -651,7 +650,7 @@ if _elementIn "CMAKE" "${WHATTOBUILD[@]}"; then
if [ "$RECONFIGURE" = "y" ]; then if [ "$RECONFIGURE" = "y" ]; then
cd "$CBD" cd "$CBD"
mkdir -p build/cmake mkdir -p build/cmake
echo "CONFIGURING cmake" >> $LOGFILE _printLog "CONFIGURING CMake"
cd "$CBD"/build/cmake cd "$CBD"/build/cmake
../../cmake/configure --prefix="$INSTALL_DIR_CMAKE" \ ../../cmake/configure --prefix="$INSTALL_DIR_CMAKE" \
2>&1 | tee -a $LOGFILE 2>&1 | tee -a $LOGFILE
@ -674,9 +673,9 @@ PLIB_INSTALL_DIR=plib
INSTALL_DIR_PLIB=$INSTALL_DIR/$PLIB_INSTALL_DIR INSTALL_DIR_PLIB=$INSTALL_DIR/$PLIB_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "PLIB" "${WHATTOBUILD[@]}"; then if _elementIn "PLIB" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** PLIB ******************" | tee -a $LOGFILE _printLog "**************** PLIB ******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "plib" mkdir -p "plib"
cd "$CBD"/plib cd "$CBD"/plib
@ -703,9 +702,9 @@ OPENRTI_INSTALL_DIR=openrti
INSTALL_DIR_OPENRTI=$INSTALL_DIR/$OPENRTI_INSTALL_DIR INSTALL_DIR_OPENRTI=$INSTALL_DIR/$OPENRTI_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "OPENRTI" "${WHATTOBUILD[@]}"; then if _elementIn "OPENRTI" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** OPENRTI ***************" | tee -a $LOGFILE _printLog "**************** OPENRTI ***************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "openrti" mkdir -p "openrti"
cd "$CBD"/openrti cd "$CBD"/openrti
@ -738,9 +737,10 @@ INSTALL_DIR_OSG=$INSTALL_DIR/$OSG_INSTALL_DIR
cd "$CBD" cd "$CBD"
mkdir -p "openscenegraph" mkdir -p "openscenegraph"
if _elementIn "OSG" "${WHATTOBUILD[@]}"; then if _elementIn "OSG" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** OSG *******************" | tee -a $LOGFILE _printLog "**************** OSG *******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
cd "$CBD"/openscenegraph cd "$CBD"/openscenegraph
_gitDownload OSG _gitDownload OSG
_gitUpdate OpenSceneGraph-3.4 _gitUpdate OpenSceneGraph-3.4
@ -777,9 +777,9 @@ SIMGEAR_INSTALL_DIR=simgear
INSTALL_DIR_SIMGEAR=$INSTALL_DIR/$SIMGEAR_INSTALL_DIR INSTALL_DIR_SIMGEAR=$INSTALL_DIR/$SIMGEAR_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then if _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** SIMGEAR ***************" | tee -a $LOGFILE _printLog "**************** SIMGEAR ***************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "simgear" mkdir -p "simgear"
cd "$CBD"/simgear cd "$CBD"/simgear
@ -813,9 +813,9 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
cd "$INSTALL_DIR_FGFS"/fgdata cd "$INSTALL_DIR_FGFS"/fgdata
if _elementIn "DATA" "${WHATTOBUILD[@]}"; then if _elementIn "DATA" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** DATA ******************" | tee -a $LOGFILE _printLog "**************** DATA ******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
_gitDownload DATA _gitDownload DATA
_gitUpdate $FGVERSION _gitUpdate $FGVERSION
@ -825,9 +825,9 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
cd "$CBD"/flightgear cd "$CBD"/flightgear
if _elementIn "FGFS" "${WHATTOBUILD[@]}"; then if _elementIn "FGFS" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "************** FLIGHTGEAR **************" | tee -a $LOGFILE _printLog "************** FLIGHTGEAR **************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
_gitDownload FGFS _gitDownload FGFS
_gitUpdate $FGVERSION _gitUpdate $FGVERSION
@ -881,9 +881,9 @@ FGRUN_INSTALL_DIR=fgrun
INSTALL_DIR_FGRUN=$INSTALL_DIR/$FGRUN_INSTALL_DIR INSTALL_DIR_FGRUN=$INSTALL_DIR/$FGRUN_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "FGRUN" "${WHATTOBUILD[@]}"; then if _elementIn "FGRUN" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** FGRUN *****************" | tee -a $LOGFILE _printLog "**************** FGRUN *****************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "fgrun" mkdir -p "fgrun"
cd "$CBD"/fgrun cd "$CBD"/fgrun
@ -921,9 +921,9 @@ FGO_INSTALL_DIR=fgo
INSTALL_DIR_FGO=$INSTALL_DIR/$FGO_INSTALL_DIR INSTALL_DIR_FGO=$INSTALL_DIR/$FGO_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "FGO" "${WHATTOBUILD[@]}"; then if _elementIn "FGO" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "***************** FGO ******************" | tee -a $LOGFILE _printLog "***************** FGO ******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
if [ "$DOWNLOAD" = "y" ]; then if [ "$DOWNLOAD" = "y" ]; then
rm -rf fgo*.tar.gz rm -rf fgo*.tar.gz
@ -952,9 +952,9 @@ FGX_INSTALL_DIR=fgx
INSTALL_DIR_FGX=$INSTALL_DIR/$FGX_INSTALL_DIR INSTALL_DIR_FGX=$INSTALL_DIR/$FGX_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "FGX" "${WHATTOBUILD[@]}"; then if _elementIn "FGX" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "***************** FGX ******************" | tee -a $LOGFILE _printLog "***************** FGX ******************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "fgx" mkdir -p "fgx"
cd "$CBD"/fgx cd "$CBD"/fgx
@ -1009,9 +1009,9 @@ ATCPIE_INSTALL_DIR=atc-pie
INSTALL_DIR_ATCPIE=$INSTALL_DIR/$ATCPIE_INSTALL_DIR INSTALL_DIR_ATCPIE=$INSTALL_DIR/$ATCPIE_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "ATCPIE" "${WHATTOBUILD[@]}"; then if _elementIn "ATCPIE" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "**************** ATCPIE ***************" | tee -a $LOGFILE _printLog "**************** ATCPIE ***************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "$INSTALL_DIR_ATCPIE" mkdir -p "$INSTALL_DIR_ATCPIE"
cd $INSTALL_DIR_ATCPIE cd $INSTALL_DIR_ATCPIE
@ -1035,9 +1035,9 @@ OR_INSTALL_DIR=openradar
INSTALL_DIR_OR=$INSTALL_DIR/$OR_INSTALL_DIR INSTALL_DIR_OR=$INSTALL_DIR/$OR_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "OPENRADAR" "${WHATTOBUILD[@]}"; then if _elementIn "OPENRADAR" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "************** OPENRADAR ***************" | tee -a $LOGFILE _printLog "************** OPENRADAR ***************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
if [ "$DOWNLOAD" = "y" ]; then if [ "$DOWNLOAD" = "y" ]; then
wget http://wagnerw.de/OpenRadar.zip -O OpenRadar.zip wget http://wagnerw.de/OpenRadar.zip -O OpenRadar.zip
@ -1062,9 +1062,9 @@ TG_INSTALL_DIR=terragear
INSTALL_DIR_TG=$INSTALL_DIR/$TG_INSTALL_DIR INSTALL_DIR_TG=$INSTALL_DIR/$TG_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "TERRAGEAR" "${WHATTOBUILD[@]}"; then if _elementIn "TERRAGEAR" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "*************** TERRAGEAR **************" | tee -a $LOGFILE _printLog "*************** TERRAGEAR **************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "terragear" mkdir -p "terragear"
cd "$CBD"/terragear cd "$CBD"/terragear
@ -1113,9 +1113,9 @@ TGGUI_INSTALL_DIR=terrageargui
INSTALL_DIR_TGGUI=$INSTALL_DIR/$TGGUI_INSTALL_DIR INSTALL_DIR_TGGUI=$INSTALL_DIR/$TGGUI_INSTALL_DIR
cd "$CBD" cd "$CBD"
if _elementIn "TERRAGEARGUI" "${WHATTOBUILD[@]}"; then if _elementIn "TERRAGEARGUI" "${WHATTOBUILD[@]}"; then
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
echo "************* TERRAGEAR GUI ************" | tee -a $LOGFILE _printLog "************* TERRAGEAR GUI ************"
echo "****************************************" | tee -a $LOGFILE _printLog "****************************************"
mkdir -p "terrageargui" mkdir -p "terrageargui"
cd "$CBD"/terrageargui cd "$CBD"/terrageargui
@ -1156,20 +1156,21 @@ fi
# Print optional package alternatives that didn't match (this helps with # Print optional package alternatives that didn't match (this helps with
# troubleshooting) # troubleshooting)
if [[ ${#UNMATCHED_OPTIONAL_PKG_ALTERNATIVES[@]} -gt 0 ]]; then if [[ ${#UNMATCHED_OPTIONAL_PKG_ALTERNATIVES[@]} -gt 0 ]]; then
echo | tee -a "$LOGFILE" _printLog
printf "The following optional package alternative(s) didn't match:\n\n" \ _printLog "The following optional package alternative(s) didn't match:"
| tee -a "$LOGFILE" _printLog
for alt in "${UNMATCHED_OPTIONAL_PKG_ALTERNATIVES[@]}"; do for alt in "${UNMATCHED_OPTIONAL_PKG_ALTERNATIVES[@]}"; do
printf " %s\n" "$alt" | tee -a "$LOGFILE" _printLog " $alt"
done done
printf "\nThis could explain missing optional features in FlightGear or \ _printLog
other software\ninstalled by $PROGNAME.\n" | tee -a "$LOGFILE" _printLog "This could explain missing optional features in FlightGear" \
"or other software"
_printLog "installed by $PROGNAME."
else else
printf "All optional package alternatives have found a matching package.\n" \ _printLog "All optional package alternatives have found a matching package."
| tee -a "$LOGFILE"
fi fi
echo _printLog
echo "download_and_compile.sh has finished to work" _printLog "$PROGNAME has finished to work."