Subject: [PATCH] gnu: gdal: Update to 3.10.2 and fix rpaths.
From: Lars Bilke <[email-masked]>
To: [email-masked]
Cc: Lars Bilke <[email-masked]>
Date: Tue, 04 Mar 2025 08:22:41 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/geo.scm (gdal): Update to 3.10.2.
* gnu/packages/geo.scm (gdal): Add fix-rpath phase from https://issues.guix.gnu.org/68606

Change-Id: I973e04af737d757329adfbfa37d255386143a21c
---
 gnu/packages/geo.scm | 124 ++++++++++++++++++++++++-------------------
 1 file changed, 68 insertions(+), 56 deletions(-)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 251ef5ced9..943de4586f 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -1408,68 +1408,80 @@ (define-public pdal
 (define-public gdal
   (package
     (name "gdal")
-    (version "3.6.1")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append
-                     "http://download.osgeo.org/gdal/" version "/gdal-"
-                     version ".tar.gz"))
-              (sha256
-               (base32
-                "1qckwnygszxkkq40bf87s3m1sab6jj9jyakdvskh0qf7dq8zjarf"))
-              (modules '((guix build utils)))
-              (snippet
-                `(begin
+    (version "3.10.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://download.osgeo.org/gdal/" version "/gdal-"
+                           version ".tar.gz"))
+       (sha256
+        (base32 "1nmh92vbcrp9qnld98vkxsvaw0mrska06kxxbn7n6kgbh6mhlwfa"))
+       (modules '((guix build utils)))
+       (snippet `(begin
                    ;; TODO: frmts contains a lot more bundled code.
                    (for-each delete-file-recursively
-                     ;; bundled code
-                     '("frmts/png/libpng"
-                       "frmts/gif/giflib"
-                       "frmts/jpeg/libjpeg"
-                       "frmts/jpeg/libjpeg12"
-                       "frmts/gtiff/libtiff"
-                       "frmts/gtiff/libgeotiff"
-                       "frmts/zlib"
-                       "ogr/ogrsf_frmts/geojson/libjson"))))))
+                             ;; bundled code
+                             '("frmts/png/libpng" "frmts/gif/giflib"
+                               "frmts/jpeg/libjpeg"
+                               "frmts/jpeg/libjpeg12"
+                               "frmts/gtiff/libtiff"
+                               "frmts/gtiff/libgeotiff"
+                               "ogr/ogrsf_frmts/geojson/libjson"))))))
     (build-system cmake-build-system)
     (arguments
-     `(#:tests? #f
-       #:configure-flags
-       (list "-DGDAL_USE_INTERNAL_LIBS=WHEN_NO_EXTERNAL"
-             "-DGDAL_USE_JPEG12_INTERNAL=OFF")))
-    (inputs
-     (list curl
-           expat
-           freexl
-           geos
-           giflib
-           json-c
-           libgeotiff
-           libjpeg-turbo
-           libjxl
-           libpng
-           libtiff
-           libwebp
-           lz4
-           netcdf
-           openssl
-           openjpeg
-           pcre2
-           postgresql ; libpq
-           proj
-           qhull
-           sqlite
-           swig
-           zlib
-           zstd))
-    (native-inputs
-     (list pkg-config
-           python))
-    (propagated-inputs
-     (list python-numpy))
+     (list
+      #:tests? #f
+      #:configure-flags
+      #~(list "-DGDAL_USE_INTERNAL_LIBS=WHEN_NO_EXTERNAL"
+              "-DGDAL_USE_JPEG12_INTERNAL=OFF")
+      #:modules '((guix build cmake-build-system)
+                  (guix build utils)
+                  (ice-9 rdelim)
+                  (ice-9 popen))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'fix-rpath
+            (lambda* (#:key outputs #:allow-other-keys)
+              (let ((libdir (string-append (assoc-ref outputs "out") "/lib")))
+                (for-each (lambda (file)
+                            (let* ((pipe (open-pipe* OPEN_READ "patchelf"
+                                                     "--print-rpath" file))
+                                   (line (read-line pipe)))
+                              (and (zero? (close-pipe pipe))
+                                   (invoke "patchelf" "--set-rpath"
+                                           (string-append libdir ":" line)
+                                           file))))
+                          (find-files libdir ".*\\.so$"))))))))
+    (inputs (list curl
+                  expat
+                  freexl
+                  geos
+                  giflib
+                  json-c
+                  libgeotiff
+                  libjpeg-turbo
+                  libjxl
+                  libpng
+                  libtiff
+                  libwebp
+                  lz4
+                  netcdf
+                  openssl
+                  openjpeg
+                  pcre2
+                  postgresql ;libpq
+                  proj
+                  qhull
+                  sqlite
+                  swig
+                  zlib
+                  zstd))
+    (native-inputs (list patchelf pkg-config python))
+    (propagated-inputs (list python-numpy))
     (home-page "https://gdal.org/")
     (synopsis "Raster and vector geospatial data format library")
-    (description "GDAL is a translator library for raster and vector geospatial
+    (description
+     "GDAL is a translator library for raster and vector geospatial
 data formats.  As a library, it presents a single raster abstract data model
 and single vector abstract data model to the calling application for all
 supported formats.  It also comes with a variety of useful command line

base-commit: f203028ef869945b3d44f0f2f7b16d61d064190c
-- 
2.46.1