Subject: [bug#76835] [PATCH v3 19/40] gnu: gdal: Update to 3.10.2.

From: Nicolas Graves <[email-masked]>
Date: Mon, 10 Mar 2025 03:16:24 +0100

* gnu/packages/geo.scm (gdal): Update to 3.10.2.
[source]: Bundle zlib back, as it's now using a custom fork.
[arguments]: Add 'patch-runpath phase and {modules} in order to patch
the runpaths of the swig generated python bindings. Improve style.
[inputs]: Add gcc:lib, hdf5, librasterlite2, libspatialite.
[native-inputs]: Add bison.
---
 gnu/packages/geo.scm | 66 ++++++++++++++++++++++++++++++--------------
 1 file changed, 45 insertions(+), 21 deletions(-)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index 251ef5ced9..7e9b1da2e3 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -1408,46 +1408,69 @@ (define-public pdal
 (define-public gdal
   (package
     (name "gdal")
-    (version "3.6.1")
+    (version "3.10.2")
     (source (origin
               (method url-fetch)
               (uri (string-append
-                     "http://download.osgeo.org/gdal/" version "/gdal-"
-                     version ".tar.gz"))
+                    "http://download.osgeo.org/gdal/" version "/gdal-"
+                    version ".tar.gz"))
               (sha256
                (base32
-                "1qckwnygszxkkq40bf87s3m1sab6jj9jyakdvskh0qf7dq8zjarf"))
+                "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"))))))
+               `(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"
+                              "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")))
+     (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 gremlin)
+                  (guix build utils)
+                  (srfi srfi-26))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'strip 'patch-runpath
+            (lambda* (#:key inputs #:allow-other-keys)
+              (for-each
+               (cut set-file-runpath <>
+                    (list (string-append #$output "/lib")
+                          (dirname (search-input-file
+                                    inputs "/lib/libgcc_s.so"))
+                          (dirname (search-input-file
+                                    inputs "/lib/libc.so.6"))))
+               (find-files
+                #$output
+                (lambda (file stat)
+                  (and (string-suffix? ".so" file)
+                       (string-contains file "site-packages"))))))))))
     (inputs
      (list curl
            expat
            freexl
+           `(,gcc "lib")
            geos
            giflib
+           hdf5
            json-c
            libgeotiff
            libjpeg-turbo
            libjxl
            libpng
+           librasterlite2
+           libspatialite
            libtiff
            libwebp
            lz4
@@ -1463,7 +1486,8 @@ (define-public gdal
            zlib
            zstd))
     (native-inputs
-     (list pkg-config
+     (list bison
+           pkg-config
            python))
     (propagated-inputs
      (list python-numpy))
-- 
2.48.1