Skip to content
Snippets Groups Projects
Commit aeea0d4f authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

PKG: detect if env variables are empty or not

parent 59524864
Branches
Tags
No related merge requests found
...@@ -18,6 +18,22 @@ ...@@ -18,6 +18,22 @@
# limitations under the License. # 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 # The below environment variables only affect current shell
# So if you run again from a terminal. you need to run the script again # 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 # 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 ...@@ -26,11 +42,11 @@ CURRENT_DIR=$(cd -P -- "$(dirname -- "$BASH_SOURCE")" && printf '%s\n' "$(pwd -P
unset LD_LIBRARY_PATH unset LD_LIBRARY_PATH
PATH=$CURRENT_DIR/bin:$PATH PATH=$(cat_path "$CURRENT_DIR/bin" "$PATH")
GDAL_DATA=$CURRENT_DIR/share/data GDAL_DATA=$CURRENT_DIR/share/data
GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv GEOTIFF_CSV=$CURRENT_DIR/share/epsg_csv
PYTHONPATH=$CURRENT_DIR/lib/python:$PYTHONPATH PYTHONPATH=$(cat_path "$CURRENT_DIR/lib/python" "$PYTHONPATH")
OTB_APPLICATION_PATH=$CURRENT_DIR/lib/otb/applications OTB_APPLICATION_PATH=$(cat_path "$CURRENT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH")
GDAL_DRIVER_PATH="disable" GDAL_DRIVER_PATH="disable"
LC_NUMERIC=C LC_NUMERIC=C
......
...@@ -20,11 +20,23 @@ ...@@ -20,11 +20,23 @@
:: Setup environment for OTB package :: Setup environment for OTB package
set CURRENT_SCRIPT_DIR=%~dp0 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 GDAL_DATA=%CURRENT_SCRIPT_DIR%share\data
set GEOTIFF_CSV=%CURRENT_SCRIPT_DIR%share\epsg_csv 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 GDAL_DRIVER_PATH=disable
:: Set numeric locale to C :: Set numeric locale to C
set LC_NUMERIC=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 @@ ...@@ -19,6 +19,22 @@
# limitations under the License. # 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 # The below environment variables only affect current shell
# So if you run again from a terminal. you need to run the script again # 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 # see how this is sourced in monteverdi.sh and mapla.sh
...@@ -27,17 +43,13 @@ CMAKE_PREFIX_PATH=OUT_DIR ...@@ -27,17 +43,13 @@ CMAKE_PREFIX_PATH=OUT_DIR
export CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH
# check and set OTB_APPLICATION_PATH # check and set OTB_APPLICATION_PATH
if [ -z "$OTB_APPLICATION_PATH" ] || [ "$OTB_APPLICATION_PATH" = "" ]; then OTB_APPLICATION_PATH=$(cat_path "OUT_DIR/lib/otb/applications" "$OTB_APPLICATION_PATH")
OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications
else
OTB_APPLICATION_PATH=OUT_DIR/lib/otb/applications:$OTB_APPLICATION_PATH
fi
# Add bin direcotory to system 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 # 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 # set numeric locale to C
LC_NUMERIC=C LC_NUMERIC=C
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment