From dc21b5d06b2ff8c151f6b89ce730e635637fc691 Mon Sep 17 00:00:00 2001
From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com>
Date: Wed, 16 Oct 2024 16:38:23 +0200
Subject: [PATCH] COMP: fix openjpeg path to lib for redhat package and update
 hdf5

---
 Documentation/Cookbook/rst/CompilingOTBFromSource.rst | 2 +-
 Packaging/Files/post_install.sh.in                    | 8 +++++---
 SuperBuild/CMake/External_hdf5.cmake                  | 4 ++--
 SuperBuild/CMake/External_openjpeg.cmake              | 1 +
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Documentation/Cookbook/rst/CompilingOTBFromSource.rst b/Documentation/Cookbook/rst/CompilingOTBFromSource.rst
index b358aebd1a..a514f3c9bc 100644
--- a/Documentation/Cookbook/rst/CompilingOTBFromSource.rst
+++ b/Documentation/Cookbook/rst/CompilingOTBFromSource.rst
@@ -37,7 +37,7 @@ process:
     +-------------------------------------------------------------------+-----------------------+----------------------------+--------------------------+
     | `HDF4 <https://www.hdfgroup.org/solutions/hdf4/>`_                | Yes                   |                            | 4.2.15                   |
     +-------------------------------------------------------------------+-----------------------+----------------------------+--------------------------+
-    | `HDF5 <https://www.hdfgroup.org/solutions/hdf5/>`_                | Yes                   |                            | 1.12.3                   |
+    | `HDF5 <https://www.hdfgroup.org/solutions/hdf5/>`_                | Yes                   |                            | 1.14.5                   |
     +-------------------------------------------------------------------+-----------------------+----------------------------+--------------------------+
     | `libgeotiff <http://trac.osgeo.org/geotiff/>`_                    | Yes                   |                            | 1.7.3                    |
     +-------------------------------------------------------------------+-----------------------+----------------------------+--------------------------+
diff --git a/Packaging/Files/post_install.sh.in b/Packaging/Files/post_install.sh.in
index df4affb99a..0dbb9f34ff 100644
--- a/Packaging/Files/post_install.sh.in
+++ b/Packaging/Files/post_install.sh.in
@@ -34,18 +34,20 @@ sed -i "s/\/builds\/otb\/xdk/\$OTB_INSTALL_DIR/g" "$OTB_INSTALL_DIR"/bin/curl-co
 sh "$OTB_INSTALL_DIR"/tools/sanitize_rpath.sh
 
 pyversion="$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]*\).*/\1\2/')"
+ostype="$(lsb_release -is)"
 # Recompile OTB Python bindings
-if [ "$pyversion" -ne "310" ]; then
+if [ "$pyversion" -ne "310" ] && [ $ostype -ne "RedHatEnterprise"] ; then
     sh "$OTB_INSTALL_DIR"/recompile_bindings.sh
 fi
 # 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
-gdal_python_found="$(find "$OTB_INSTALL_DIR"/lib/python3/dist-packages/osgeo/ -name "*$pyversion-x86_64-linux*")"
+python_distpackage_path="$OTB_INSTALL_DIR"/lib/python3/dist-packages/osgeo/
+gdal_python_found="$(find $python_distpackage_path -name "*$pyversion-x86_64-linux*")"
 if [ "$pyversion" = "312" ] && [ -z $gdal_python_found ]; then
     echo "***** Python 3.12 detected, downloading gdal bindings compiled for python 3.12 *****"
     HTTP_STATUS=$(curl -s -o "$OTB_INSTALL_DIR"/tools/py312.tar.gz -w "%{response_code}\n" https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_SHORT_VERSION-GDAL-bindings-py$pyversion.tar.gz)
     if [ $HTTP_STATUS -eq 200 ]; then
-        tar -xf "$OTB_INSTALL_DIR"/tools/gdal-py312.tar.gz -C "$OTB_INSTALL_DIR"/lib/python3/dist-packages/osgeo/
+        tar -xf "$OTB_INSTALL_DIR"/tools/gdal-py312.tar.gz -C $python_distpackage_path
         rm "$OTB_INSTALL_DIR"/tools/gdal-py312.tar.gz
         echo "***** GDAL bindings for python 3.12 successfully installed *****"
     else
diff --git a/SuperBuild/CMake/External_hdf5.cmake b/SuperBuild/CMake/External_hdf5.cmake
index 9fdc483c81..c23cac85dd 100644
--- a/SuperBuild/CMake/External_hdf5.cmake
+++ b/SuperBuild/CMake/External_hdf5.cmake
@@ -29,8 +29,8 @@ set(HDF5_SB_CONFIG)
 
 ExternalProject_Add(HDF5
   PREFIX HDF5
-  URL "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.3/src/hdf5-1.12.3.tar.gz"
-  URL_MD5 4da24fcd281b9eeb05dae9b258f72a72
+  URL "https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14.5.tar.gz"
+  URL_MD5 600d29af6ccb7f1e3401560e1422ba5e
   SOURCE_DIR ${HDF5_SB_SRC}
   BINARY_DIR ${HDF5_SB_BUILD_DIR}
   INSTALL_DIR ${SB_INSTALL_PREFIX}
diff --git a/SuperBuild/CMake/External_openjpeg.cmake b/SuperBuild/CMake/External_openjpeg.cmake
index 7c0a31b376..8959daa215 100644
--- a/SuperBuild/CMake/External_openjpeg.cmake
+++ b/SuperBuild/CMake/External_openjpeg.cmake
@@ -51,6 +51,7 @@ ExternalProject_Add(OPENJPEG
   -DBUILD_PKGCONFIG_FILES:BOOL=ON
   -DBUILD_THIRDPARTY:BOOL=OFF
   -DBUILD_THIRDPARTY_LCMS:BOOL=ON
+  -DCMAKE_INSTALL_LIBDIR:PATH=lib
   ${OPENJPEG_SB_CONFIG}
   DEPENDS ${OPENJPEG_DEPENDENCIES}
   CMAKE_COMMAND ${SB_CMAKE_COMMAND}
-- 
GitLab