Skip to content
Snippets Groups Projects
Commit a9e1a6b8 authored by Tristan Laurent's avatar Tristan Laurent
Browse files

BUG: fix empty OS variable, fix osgeo finding on rhel-based OS

parent 4729b55a
No related branches found
No related tags found
1 merge request!1054BUG: fix empty OS variable, fix osgeo finding on rhel-based OS
Pipeline #16396 failed
...@@ -42,7 +42,7 @@ OS="$(lsb_release -is)" ...@@ -42,7 +42,7 @@ OS="$(lsb_release -is)"
# path may differ # path may differ
if [ -n "${BASH}" ]; then if [ -n "${BASH}" ]; then
# dirname does not exists on RH-based OS # dirname does not exists on RH-based OS
if [ $OS = "RedHatEnterprise" ] || [ $OS = "Fedora" ] || [ $OS = "RockyLinux" ]; then if [ "$OS" = "RedHatEnterprise" ] || [ "$OS" = "Fedora" ] || [ "$OS" = "RockyLinux" ]; then
OTB_INSTALL_DIR="$(realpath $(dirname "${BASH_SOURCE[0]}"))" OTB_INSTALL_DIR="$(realpath $(dirname "${BASH_SOURCE[0]}"))"
elif [ -n "${BASH}" ]; then elif [ -n "${BASH}" ]; then
OTB_INSTALL_DIR="$( dirname -- "$( readlink -f -- "${BASH_SOURCE[0]}"; )"; )" OTB_INSTALL_DIR="$( dirname -- "$( readlink -f -- "${BASH_SOURCE[0]}"; )"; )"
...@@ -51,7 +51,7 @@ else ...@@ -51,7 +51,7 @@ else
# non-bash shell # non-bash shell
OTB_INSTALL_DIR="$( dirname -- "$( readlink -f -- "$0"; )"; )" OTB_INSTALL_DIR="$( dirname -- "$( readlink -f -- "$0"; )"; )"
fi fi
CMAKE_PREFIX_PATH=$OTB_INSTALL_DIR CMAKE_PREFIX_PATH="$OTB_INSTALL_DIR"
export CMAKE_PREFIX_PATH export CMAKE_PREFIX_PATH
# check and set OTB_APPLICATION_PATH # check and set OTB_APPLICATION_PATH
...@@ -62,7 +62,7 @@ PATH=$(cat_path "$OTB_INSTALL_DIR/bin" "$PATH") ...@@ -62,7 +62,7 @@ PATH=$(cat_path "$OTB_INSTALL_DIR/bin" "$PATH")
# export PYTHONPATH to import otbApplication.py # export PYTHONPATH to import otbApplication.py
PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/otb/python" "$PYTHONPATH") PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/otb/python" "$PYTHONPATH")
if [ $OS = "RedHatEnterprise" ] || [ $OS = "Fedora" ] || [ $OS = "RockyLinux" ]; then if [ "$OS" = "RedHatEnterprise" ] || [ "$OS" = "Fedora" ] || [ "$OS" = "RockyLinux" ]; then
PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/python3.8/site-packages" "$PYTHONPATH") PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/python3.8/site-packages" "$PYTHONPATH")
else else
PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/python3/dist-packages" "$PYTHONPATH") PYTHONPATH=$(cat_path "$OTB_INSTALL_DIR/lib/python3/dist-packages" "$PYTHONPATH")
...@@ -76,7 +76,7 @@ GDAL_DATA="$OTB_INSTALL_DIR/share/gdal" ...@@ -76,7 +76,7 @@ GDAL_DATA="$OTB_INSTALL_DIR/share/gdal"
PROJ_LIB="$OTB_INSTALL_DIR/share/proj" PROJ_LIB="$OTB_INSTALL_DIR/share/proj"
export GDAL_DRIVER_PATH=disable export GDAL_DRIVER_PATH="disable"
export LD_LIBRARY_PATH="$OTB_INSTALL_DIR/lib:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$OTB_INSTALL_DIR/lib:$LD_LIBRARY_PATH"
......
...@@ -33,25 +33,28 @@ sed -i "s/\/builds\/otb\/xdk/\$OTB_INSTALL_DIR/g" "$OTB_INSTALL_DIR"/bin/gdal-co ...@@ -33,25 +33,28 @@ sed -i "s/\/builds\/otb\/xdk/\$OTB_INSTALL_DIR/g" "$OTB_INSTALL_DIR"/bin/gdal-co
sed -i "s/\/builds\/otb\/xdk/\$OTB_INSTALL_DIR/g" "$OTB_INSTALL_DIR"/bin/curl-config sed -i "s/\/builds\/otb\/xdk/\$OTB_INSTALL_DIR/g" "$OTB_INSTALL_DIR"/bin/curl-config
sh "$OTB_INSTALL_DIR"/tools/sanitize_rpath.sh sh "$OTB_INSTALL_DIR"/tools/sanitize_rpath.sh
pyversion="$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]*\).*/\1\2/')" concatpyversion="$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]*\).*/\1\2/')"
ostype="$(lsb_release -is)" ostype="$(lsb_release -is)"
# Recompile OTB Python bindings # Recompile OTB Python bindings. By default on non RHEL OS, the packaged
if [ "$pyversion" -ne "310" ] && [ $ostype != "RedHatEnterprise" ] ; then # bindings are compiled for version 3.10
if [ "$concatpyversion" -ne "310" ] && [ $ostype != "RedHatEnterprise" ] ; then
sh "$OTB_INSTALL_DIR"/recompile_bindings.sh sh "$OTB_INSTALL_DIR"/recompile_bindings.sh
fi fi
# Check python version, if python 3.12 (ubuntu 24 and debian > 12) download and extract the gdal bindings for python 3.12 # Check python version, if python 3.12 (ubuntu 24 and debian > 12) download and extract the gdal bindings for python 3.12
# In case your install is from compiled code, the gdal bindings will be already there in the installation # In case your install is from compiled code, the gdal bindings will be already there in the installation
python_distpackage_path="$OTB_INSTALL_DIR/lib/python3/dist-packages/osgeo/" # Note that the install path differs from RHEL to debian based OS. To handle it,
gdal_python_found="$(find $python_distpackage_path -name "*$pyversion-x86_64-linux*")" # check before the folder name (always prefixed of python3)
osgeo_pkg_path=$(find "$OTB_INSTALL_DIR/lib" -mindepth 3 -maxdepth 3 -type d -name "osgeo")
gdal_python_found="$(find $osgeo_pkg_path -name "*$concatpyversion-x86_64-linux*")"
if [ -z "$gdal_python_found" ]; then if [ -z "$gdal_python_found" ]; then
echo "***** Python $pyversion detected, downloading gdal bindings compiled for this Python version *****" echo "***** Python $concatpyversion detected, downloading gdal bindings compiled for this Python version *****"
HTTP_STATUS=$(curl -s -o "$OTB_INSTALL_DIR"/tools/gdal-py$pyversion.tar.gz -w "%{response_code}\n" https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_SHORT_VERSION-GDAL-bindings-py$pyversion.tar.gz) HTTP_STATUS=$(curl -s -o "$OTB_INSTALL_DIR"/tools/gdal-py$concatpyversion.tar.gz -w "%{response_code}\n" https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_SHORT_VERSION-GDAL-bindings-py$concatpyversion.tar.gz)
if [ $HTTP_STATUS -eq 200 ]; then if [ $HTTP_STATUS -eq 200 ]; then
tar -xf "$OTB_INSTALL_DIR"/tools/gdal-py$pyversion.tar.gz -C $python_distpackage_path tar -xf "$OTB_INSTALL_DIR"/tools/gdal-py$concatpyversion.tar.gz -C $python_distpackage_path
rm "$OTB_INSTALL_DIR"/tools/gdal-py$pyversion.tar.gz rm "$OTB_INSTALL_DIR"/tools/gdal-py$concatpyversion.tar.gz
echo "***** GDAL bindings for python $pyversion successfully installed *****" echo "***** GDAL bindings for python $concatpyversion successfully installed *****"
else else
echo "Can not find GDAL bindings at https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_SHORT_VERSION-GDAL-bindings-py$pyversion.tar.gz" echo "Can not find GDAL bindings at https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_SHORT_VERSION-GDAL-bindings-py$concatpyversion.tar.gz"
return -1 return -1
fi fi
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment