Commit aeea0d4f authored by Guillaume Pasero's avatar Guillaume Pasero

PKG: detect if env variables are empty or not

parent 59524864
......@@ -18,6 +18,22 @@
# limitations under the License.
#
cat_path()
{
if [ $# -eq 0 ]; then exit 0; fi
if [ $# -eq 1 ]; then echo "$1"; exit 0; fi
cur="$1"
shift 1
next="$(cat_path $@)"
if [ -z "$cur" ]; then
echo "$next"
elif [ -z "$next" ]; then
echo "$cur"
else
echo "$cur:$next"
fi
}
# The below environment variables only affect current shell
# So if you run again from a terminal. you need to run the script again
# see how this is sourced in monteverdi.sh and mapla.sh
......@@ -26,11 +42,11 @@ CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P
unset LD_LIBRARY_PATH
PATH=$CURRENT_DIR/bin:$PATH
PATH=$(cat_path "$CURRENT_DIR/bin" "$PATH")
GDAL_DATA=$CURRENT_DIR/share/data
GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv
PYTHONPATH=$CURRENT_DIR/lib/python:$PYTHONPATH
OTB_APPLICATION_PATH=$CURRENT_DIR/lib/otb/applications
PYTHONPATH=$(cat_path "$CURRENT_DIR/lib/python" "$PYTHONPATH")
OTB_APPLICATION_PATH=$(cat_path "$CURRENT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH")
GDAL_DRIVER_PATH="disable"
LC_NUMERIC=C
......
......@@ -20,11 +20,23 @@
:: Setup environment for OTB package
set CURRENT_SCRIPT_DIR=%~dp0
set PATH=%CURRENT_SCRIPT_DIR%bin;%PATH%
call :prefix_path PATH "%CURRENT_SCRIPT_DIR%bin"
call :prefix_path PYTHONPATH "%CURRENT_SCRIPT_DIR%lib\python"
call :prefix_path OTB_APPLICATION_PATH "%CURRENT_SCRIPT_DIR%lib\otb\applications"
set GDAL_DATA=%CURRENT_SCRIPT_DIR%share\data
set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv
set PYTHONPATH=%CURRENT_SCRIPT_DIR%lib\python;%PYTHONPATH%
set OTB_APPLICATION_PATH=%CURRENT_SCRIPT_DIR%lib\otb\applications
set GDAL_DRIVER_PATH=disable
:: Set numeric locale to C
set LC_NUMERIC=C
goto :eof
:prefix_path
setlocal enabledelayedexpansion
set output=%~2
set var=%1
set content=
if defined %var% ( set content=!%var%! )
if not "%content%" == "" ( set output=%output%;%content% )
endlocal & set %1=%output%
goto :eof
......@@ -19,6 +19,22 @@
# limitations under the License.
#
cat_path()
{
if [ $# -eq 0 ]; then exit 0; fi
if [ $# -eq 1 ]; then echo "$1"; exit 0; fi
cur="$1"
shift 1
next="$(cat_path $@)"
if [ -z "$cur" ]; then
echo "$next"
elif [ -z "$next" ]; then
echo "$cur"
else
echo "$cur:$next"
fi
}
# The below environment variables only affect current shell
# So if you run again from a terminal. you need to run the script again
# see how this is sourced in monteverdi.sh and mapla.sh
......@@ -27,17 +43,13 @@ CMAKE_PREFIX_PATH=OUT_DIR
export CMAKE_PREFIX_PATH
# check and set OTB_APPLICATION_PATH
if [ -z "$OTB_APPLICATION_PATH" ] || [ "$OTB_APPLICATION_PATH" = "" ]; then
OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications
else
OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications:$OTB_APPLICATION_PATH
fi
OTB_APPLICATION_PATH=$(cat_path "OUT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH")
# Add bin direcotory to system PATH
PATH=OUT_DIR/bin:$PATH
PATH=$(cat_path "OUT_DIR/bin" "$PATH")
# export PYTHONPATH to import otbApplication.py
PYTHONPATH=OUT_DIR/lib/python:$PYTHONPATH
PYTHONPATH=$(cat_path "OUT_DIR/lib/python" "$PYTHONPATH")
# set numeric locale to C
LC_NUMERIC=C
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment