download_and_compile.sh: new function _log()
Introduce a new function _log() that allows one to factor out the remaining explicit appends to $LOGFILE. Summary: _log writes its arguments to $LOGFILE _printLog ditto, and also prints them to the terminal _logOutput echoes its standard input to the terminal and/or to $LOGFILE (depending on its first argument). Typically used in the last component of a pipeline.
This commit is contained in:
parent
2874e0eade
commit
141bb7dec4
1 changed files with 21 additions and 17 deletions
|
@ -57,6 +57,10 @@ _elementIn(){
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _log(){
|
||||||
|
echo "$@" >> "$LOGFILE"
|
||||||
|
}
|
||||||
|
|
||||||
function _printLog(){
|
function _printLog(){
|
||||||
# Possible special case for the terminal: echo "${PROGNAME}: $@"
|
# Possible special case for the terminal: echo "${PROGNAME}: $@"
|
||||||
# That would be more precise but rather verbose, and not all output uses
|
# That would be more precise but rather verbose, and not all output uses
|
||||||
|
@ -168,9 +172,9 @@ function _make(){
|
||||||
if [ "$COMPILE" = "y" ]; then
|
if [ "$COMPILE" = "y" ]; then
|
||||||
pkg=$1
|
pkg=$1
|
||||||
cd "$CBD"/build/$pkg
|
cd "$CBD"/build/$pkg
|
||||||
echo "MAKE $pkg" >> $LOGFILE
|
_printLog "MAKE $pkg"
|
||||||
make $JOPTION $OOPTION 2>&1 | _logOutput
|
make $JOPTION $OOPTION 2>&1 | _logOutput
|
||||||
echo "INSTALL $pkg" >> $LOGFILE
|
_printLog "INSTALL $pkg"
|
||||||
make install 2>&1 | _logOutput
|
make install 2>&1 | _logOutput
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -537,15 +541,15 @@ echo "**************************************"
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
||||||
echo $0 $* > $LOGFILE
|
echo $0 $* > $LOGFILE
|
||||||
echo "VERSION=$VERSION" >> $LOGFILE
|
_log "VERSION=$VERSION"
|
||||||
echo "APT_GET_UPDATE=$APT_GET_UPDATE" >> $LOGFILE
|
_log "APT_GET_UPDATE=$APT_GET_UPDATE"
|
||||||
echo "DOWNLOAD_PACKAGES=$DOWNLOAD_PACKAGES" >> $LOGFILE
|
_log "DOWNLOAD_PACKAGES=$DOWNLOAD_PACKAGES"
|
||||||
echo "COMPILE=$COMPILE" >> $LOGFILE
|
_log "COMPILE=$COMPILE"
|
||||||
echo "RECONFIGURE=$RECONFIGURE" >> $LOGFILE
|
_log "RECONFIGURE=$RECONFIGURE"
|
||||||
echo "DOWNLOAD=$DOWNLOAD" >> $LOGFILE
|
_log "DOWNLOAD=$DOWNLOAD"
|
||||||
echo "JOPTION=$JOPTION" >> $LOGFILE
|
_log "JOPTION=$JOPTION"
|
||||||
echo "OOPTION=$OOPTION" >> $LOGFILE
|
_log "OOPTION=$OOPTION"
|
||||||
echo "BUILD_TYPE=$BUILD_TYPE" >> $LOGFILE
|
_log "BUILD_TYPE=$BUILD_TYPE"
|
||||||
_logSep
|
_logSep
|
||||||
|
|
||||||
#######################################################
|
#######################################################
|
||||||
|
@ -616,7 +620,7 @@ fi
|
||||||
|
|
||||||
CBD=$(pwd)
|
CBD=$(pwd)
|
||||||
LOGFILE=$CBD/$LOGFILE
|
LOGFILE=$CBD/$LOGFILE
|
||||||
echo "DIRECTORY= $CBD" >> $LOGFILE
|
_log "DIRECTORY=$CBD"
|
||||||
_logSep
|
_logSep
|
||||||
mkdir -p install
|
mkdir -p install
|
||||||
SUB_INSTALL_DIR=install
|
SUB_INSTALL_DIR=install
|
||||||
|
@ -701,7 +705,7 @@ if _elementIn "PLIB" "${WHATTOBUILD[@]}"; then
|
||||||
if [ "$RECONFIGURE" = "y" ]; then
|
if [ "$RECONFIGURE" = "y" ]; then
|
||||||
cd "$CBD"
|
cd "$CBD"
|
||||||
mkdir -p build/plib
|
mkdir -p build/plib
|
||||||
echo "CONFIGURING plib" >> $LOGFILE
|
_log "CONFIGURING plib"
|
||||||
cd "$CBD"/build/plib
|
cd "$CBD"/build/plib
|
||||||
"$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
"$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
||||||
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_PLIB" \
|
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_PLIB" \
|
||||||
|
@ -1001,8 +1005,8 @@ if _elementIn "FGX" "${WHATTOBUILD[@]}"; then
|
||||||
|
|
||||||
if [ "$COMPILE" = "y" ]; then
|
if [ "$COMPILE" = "y" ]; then
|
||||||
cd $INSTALL_DIR_FGX
|
cd $INSTALL_DIR_FGX
|
||||||
echo "MAKE AND INSTALL FGX" >> $LOGFILE
|
_printLog "MAKE AND INSTALL FGX"
|
||||||
echo "make $JOPTION $OOPTION " >> $LOGFILE
|
_printLog "make $JOPTION $OOPTION"
|
||||||
make $JOPTION $OOPTION 2>&1 | _logOutput
|
make $JOPTION $OOPTION 2>&1 | _logOutput
|
||||||
cd ..
|
cd ..
|
||||||
fi
|
fi
|
||||||
|
@ -1155,14 +1159,14 @@ if _elementIn "TERRAGEARGUI" "${WHATTOBUILD[@]}"; then
|
||||||
cd "$CBD"
|
cd "$CBD"
|
||||||
# Fill TerraGear Root field
|
# Fill TerraGear Root field
|
||||||
if [ ! -f ~/.config/TerraGear/TerraGearGUI.conf ]; then
|
if [ ! -f ~/.config/TerraGear/TerraGearGUI.conf ]; then
|
||||||
echo "Fill TerraGear Root field" >> $LOGFILE
|
_log "Fill TerraGear Root field"
|
||||||
echo "[paths]" > TerraGearGUI.conf
|
echo "[paths]" > TerraGearGUI.conf
|
||||||
echo "terragear=$INSTALL_DIR_TG/bin" >> TerraGearGUI.conf
|
echo "terragear=$INSTALL_DIR_TG/bin" >> TerraGearGUI.conf
|
||||||
mkdir -p ~/.config/TerraGear
|
mkdir -p ~/.config/TerraGear
|
||||||
mv TerraGearGUI.conf ~/.config/TerraGear
|
mv TerraGearGUI.conf ~/.config/TerraGear
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Create run_terrageargui.sh" >> $LOGFILE
|
_log "Create run_terrageargui.sh"
|
||||||
echo "#!/bin/sh" > run_terrageargui.sh
|
echo "#!/bin/sh" > run_terrageargui.sh
|
||||||
echo "cd \$(dirname \$0)" >> run_terrageargui.sh
|
echo "cd \$(dirname \$0)" >> run_terrageargui.sh
|
||||||
echo "cd install/terrageargui/bin" >> run_terrageargui.sh
|
echo "cd install/terrageargui/bin" >> run_terrageargui.sh
|
||||||
|
|
Loading…
Add table
Reference in a new issue