1
0
Fork 0

download_and_compile.sh: add quoting around variable expansions

Should behave better in case one of these variables contains whitespace.

Note: I didn't look inside the generated scripts such as run_fgfs.sh,
      they may have similar issues.
This commit is contained in:
Florent Rougon 2019-04-21 08:39:34 +02:00
parent 5e25bc9277
commit cd80fffbe2

View file

@ -118,18 +118,18 @@ function _gitUpdate(){
if [ "$DOWNLOAD" != "y" ]; then if [ "$DOWNLOAD" != "y" ]; then
return return
fi fi
branch=$1 branch="$1"
set +e set +e
git diff --exit-code 2>&1 > /dev/null git diff --exit-code 2>&1 > /dev/null
if [ $? != 1 ]; then if [ $? != 1 ]; then
set -e set -e
git pull -r git pull -r
git checkout -f $branch git checkout -f "$branch"
else else
set -e set -e
git stash save -u -q git stash save -u -q
git pull -r git pull -r
git checkout -f $branch git checkout -f "$branch"
git stash pop -q git stash pop -q
fi fi
} }
@ -186,8 +186,8 @@ function _gitDownload(){
function _make(){ function _make(){
if [ "$COMPILE" = "y" ]; then if [ "$COMPILE" = "y" ]; then
pkg=$1 pkg="$1"
cd "$CBD"/build/$pkg cd "$CBD/build/$pkg"
_printLog "MAKE $pkg" _printLog "MAKE $pkg"
make $JOPTION $OOPTION 2>&1 | _logOutput make $JOPTION $OOPTION 2>&1 | _logOutput
_printLog "INSTALL $pkg" _printLog "INSTALL $pkg"
@ -720,7 +720,7 @@ _printLog
# cmake # cmake
####################################################### #######################################################
CMAKE_INSTALL_DIR=cmake 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
_printLog "****************************************" _printLog "****************************************"
@ -755,7 +755,7 @@ fi
# PLIB # PLIB
####################################################### #######################################################
PLIB_INSTALL_DIR=plib 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
_printLog "****************************************" _printLog "****************************************"
@ -784,7 +784,7 @@ fi
# OPENRTI # OPENRTI
####################################################### #######################################################
OPENRTI_INSTALL_DIR=openrti 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
_printLog "****************************************" _printLog "****************************************"
@ -818,7 +818,7 @@ fi
# OpenSceneGraph # OpenSceneGraph
####################################################### #######################################################
OSG_INSTALL_DIR=openscenegraph OSG_INSTALL_DIR=openscenegraph
INSTALL_DIR_OSG=$INSTALL_DIR/$OSG_INSTALL_DIR INSTALL_DIR_OSG="$INSTALL_DIR/$OSG_INSTALL_DIR"
cd "$CBD" cd "$CBD"
if _elementIn "OSG" "${WHATTOBUILD[@]}"; then if _elementIn "OSG" "${WHATTOBUILD[@]}"; then
_printLog "****************************************" _printLog "****************************************"
@ -860,7 +860,7 @@ fi
# SIMGEAR # SIMGEAR
####################################################### #######################################################
SIMGEAR_INSTALL_DIR=simgear 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
_printLog "****************************************" _printLog "****************************************"
@ -870,7 +870,7 @@ if _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then
mkdir -p "simgear" mkdir -p "simgear"
cd "$CBD"/simgear cd "$CBD"/simgear
_gitDownload SIMGEAR _gitDownload SIMGEAR
_gitUpdate $FGVERSION _gitUpdate "$FGVERSION"
if [ "$RECONFIGURE" = "y" ]; then if [ "$RECONFIGURE" = "y" ]; then
cd "$CBD" cd "$CBD"
@ -891,7 +891,7 @@ fi
# FGFS # FGFS
####################################################### #######################################################
FGFS_INSTALL_DIR=flightgear FGFS_INSTALL_DIR=flightgear
INSTALL_DIR_FGFS=$INSTALL_DIR/$FGFS_INSTALL_DIR INSTALL_DIR_FGFS="$INSTALL_DIR/$FGFS_INSTALL_DIR"
cd "$CBD" cd "$CBD"
if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
_elementIn "DATA" "${WHATTOBUILD[@]}"; then _elementIn "DATA" "${WHATTOBUILD[@]}"; then
@ -904,7 +904,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
_printLog "****************************************" _printLog "****************************************"
_gitDownload DATA _gitDownload DATA
_gitUpdate $FGVERSION _gitUpdate "$FGVERSION"
fi fi
mkdir -p "$CBD"/flightgear mkdir -p "$CBD"/flightgear
@ -916,7 +916,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
_printLog "****************************************" _printLog "****************************************"
_gitDownload FGFS _gitDownload FGFS
_gitUpdate $FGVERSION _gitUpdate "$FGVERSION"
if [ "$RECONFIGURE" = "y" ]; then if [ "$RECONFIGURE" = "y" ]; then
cd "$CBD" cd "$CBD"
@ -966,7 +966,7 @@ fi
# FGRUN # FGRUN
####################################################### #######################################################
FGRUN_INSTALL_DIR=fgrun 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
_printLog "****************************************" _printLog "****************************************"
@ -976,7 +976,7 @@ if _elementIn "FGRUN" "${WHATTOBUILD[@]}"; then
mkdir -p "fgrun" mkdir -p "fgrun"
cd "$CBD"/fgrun cd "$CBD"/fgrun
_gitDownload FGRUN _gitDownload FGRUN
_gitUpdate $FGVERSION _gitUpdate "$FGVERSION"
if [ "$RECONFIGURE" = "y" ]; then if [ "$RECONFIGURE" = "y" ]; then
cd "$CBD" cd "$CBD"
@ -1007,7 +1007,7 @@ fi
# FGO! # FGO!
####################################################### #######################################################
FGO_INSTALL_DIR=fgo 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
_printLog "****************************************" _printLog "****************************************"
@ -1038,7 +1038,7 @@ fi
# FGx # FGx
####################################################### #######################################################
FGX_INSTALL_DIR=fgx 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
_printLog "****************************************" _printLog "****************************************"
@ -1066,13 +1066,13 @@ if _elementIn "FGX" "${WHATTOBUILD[@]}"; then
cd .. cd ..
if [ "$RECONFIGURE" = "y" ]; then if [ "$RECONFIGURE" = "y" ]; then
mkdir -p $INSTALL_DIR_FGX mkdir -p "$INSTALL_DIR_FGX"
cd $INSTALL_DIR_FGX cd "$INSTALL_DIR_FGX"
qmake ../../fgx/src qmake ../../fgx/src
fi fi
if [ "$COMPILE" = "y" ]; then if [ "$COMPILE" = "y" ]; then
cd $INSTALL_DIR_FGX cd "$INSTALL_DIR_FGX"
_printLog "MAKE AND INSTALL FGX" _printLog "MAKE AND INSTALL FGX"
_printLog "make $JOPTION $OOPTION" _printLog "make $JOPTION $OOPTION"
make $JOPTION $OOPTION 2>&1 | _logOutput make $JOPTION $OOPTION 2>&1 | _logOutput
@ -1095,7 +1095,7 @@ fi
# ATC-PIE # ATC-PIE
####################################################### #######################################################
ATCPIE_INSTALL_DIR=atc-pie 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
_printLog "****************************************" _printLog "****************************************"
@ -1103,7 +1103,7 @@ if _elementIn "ATCPIE" "${WHATTOBUILD[@]}"; then
_printLog "****************************************" _printLog "****************************************"
mkdir -p "$INSTALL_DIR_ATCPIE" mkdir -p "$INSTALL_DIR_ATCPIE"
cd $INSTALL_DIR_ATCPIE cd "$INSTALL_DIR_ATCPIE"
_gitDownload ATCPIE _gitDownload ATCPIE
_gitUpdate master _gitUpdate master
@ -1121,7 +1121,7 @@ fi
# OPENRADAR # OPENRADAR
####################################################### #######################################################
OR_INSTALL_DIR=openradar 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
_printLog "****************************************" _printLog "****************************************"
@ -1148,7 +1148,7 @@ fi
####################################################### #######################################################
TG_INSTALL_DIR=terragear 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
_printLog "****************************************" _printLog "****************************************"
@ -1202,7 +1202,7 @@ _logSep
####################################################### #######################################################
TGGUI_INSTALL_DIR=terrageargui 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
_printLog "****************************************" _printLog "****************************************"