Subject: [bug#38178] [WIP v2] gnu: Add grass.

From: Guillaume Le Vaillant <[email-masked]>
Date: Sun, 22 Mar 2020 09:57:24 +0100

Marius Bakke <[email-masked]> skribis:

> Wiktor Żelazny <[email-masked]> writes:
>
>> A new version of GRASS GIS got released, which gave me an opportunity
>> to bump the version in the old definition and recompile. The errors are
>> there, but do not hinder the successful build. Apparently, they have
>> been there from the beginning; I just didn’t notice — both bad and
>> good news.
>>
>> The real error (for now) is
>>
>>    In unknown file:
>>             0 (%resolve-variable (7 . wxpython) #<directory (g…>)
>>
>>    ERROR: In procedure %resolve-variable:
>>    Unbound variable: wxpython
>>
>> I tried changing “wxpython” to “python-wxpython”, but this also
>> is not recognized. So there’s something wrong with the way I defined
>> the wrapping.
>
> Did you get anywhere with this patch?  Can you rebase it on the current
> master branch for easier testing?  TIA!
>
> By the way, sorry for the sloooooow responses...

I have a patch for grass (it compiles, but I have not tested all its
functionalities). If I had searched in the issues and found Wiktor's
patch, I wouldn't have had to write one from scratch, but well... here
it is:

From 59894e2bd8cfd1086abd7630d998f29351c88565 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <[email-masked]>
Date: Sun, 22 Mar 2020 00:03:41 +0100
Subject: [PATCH] gnu: Add grass.

* gnu/packages/geo.scm (grass): New variable.
---
 gnu/packages/geo.scm | 122 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 122 insertions(+)

diff --git a/gnu/packages/geo.scm b/gnu/packages/geo.scm
index bc870f9620..b244e49a92 100644
--- a/gnu/packages/geo.scm
+++ b/gnu/packages/geo.scm
@@ -46,10 +46,13 @@
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (gnu packages)
+  #:use-module (gnu packages algebra)
   #:use-module (gnu packages astronomy)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages backup)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages bison)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
@@ -58,6 +61,7 @@
   #:use-module (gnu packages datastructures)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages elf)
+  #:use-module (gnu packages flex)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gettext)
@@ -80,8 +84,10 @@
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages qt)
+  #:use-module (gnu packages readline)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages textutils)
+  #:use-module (gnu packages time)
   #:use-module (gnu packages web)
   #:use-module (gnu packages webkit)
   #:use-module (gnu packages wxwidgets)
@@ -1629,3 +1635,119 @@ track your position right from your laptop.")
                    license:lgpl3+
                    license:sgifreeb2.0
                    license:zlib))))
+
+(define-public grass
+  (let* ((version "7.8.2")
+         (majorminor (string-join (list-head (string-split version #\.) 2) ""))
+         (grassxx (string-append "grass" majorminor)))
+    (package
+      (name "grass")
+      (version version)
+      (source
+       (origin
+         (method url-fetch)
+         (uri (string-append "https://grass.osgeo.org/" grassxx
+                             "/source/grass-" version ".tar.gz"))
+         (sha256
+          (base32 "1fwsm99kz0bxvjk7442qq1h45ikrmhba8bqclafb61gqg1q6ymrk"))))
+      (build-system gnu-build-system)
+      (inputs
+       `(("bzip2", bzip2)
+         ("cairo" ,cairo)
+         ("fftw" ,fftw)
+         ("freetype" ,freetype)
+         ("gdal" ,gdal)
+         ("geos" ,geos)
+         ("glu" ,glu)
+         ("lapack" ,lapack)
+         ("libpng" ,libpng)
+         ("libtiff" ,libtiff)
+         ("mesa" ,mesa)
+         ("mariadb-dev" ,mariadb "dev")
+         ("mariadb-lib" ,mariadb "lib")
+         ("netcdf" ,netcdf)
+         ("openblas" ,openblas)
+         ("perl" ,perl)
+         ("postgresql" ,postgresql)
+         ("proj.4" ,proj.4)
+         ("python" ,python)
+         ("python-dateutil" ,python-dateutil)
+         ("python-numpy" ,python-numpy)
+         ("python-wxpython" ,python-wxpython)
+         ("readline" ,readline)
+         ("sqlite" ,sqlite)
+         ("wxwidgets" ,wxwidgets)
+         ("zlib" ,zlib)
+         ("zstd" ,zstd "lib")))
+      (native-inputs
+       `(("bash" ,bash-minimal)
+         ("bison" ,bison)
+         ("flex" ,flex)
+         ("pkg-config" ,pkg-config)))
+      (arguments
+       `(#:tests? #f ; No tests
+         #:modules ((guix build gnu-build-system)
+                    ((guix build python-build-system) #:prefix python:)
+                    (guix build utils))
+         #:imported-modules (,@%gnu-build-system-modules
+                             (guix build python-build-system))
+         #:phases
+         (modify-phases %standard-phases
+           (replace 'configure
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let ((shell (string-append (assoc-ref inputs "bash")
+                                           "/bin/bash")))
+                 (setenv "SHELL" shell)
+                 (setenv "CONFIG_SHELL" shell)
+                 (setenv "LDFLAGS" (string-append "-Wl,-rpath -Wl,"
+                                                  (assoc-ref outputs "out")
+                                                  "/" ,grassxx "/lib")))
+               (invoke "./configure"
+                       (string-append "--prefix="
+                                      (assoc-ref outputs "out"))
+                       "--with-blas"
+                       "--with-bzlib"
+                       (string-append "--with-freetype-includes="
+                                      (assoc-ref inputs "freetype")
+                                      "/include/freetype2")
+                       (string-append "--with-freetype-libs="
+                                      (assoc-ref inputs "freetype")
+                                      "/lib")
+                       "--with-geos"
+                       "--with-lapack"
+                       "--with-mysql"
+                       (string-append "--with-mysql-includes="
+                                      (assoc-ref inputs "mariadb-dev")
+                                      "/include/mysql")
+                       (string-append "--with-mysql-libs="
+                                      (assoc-ref inputs "mariadb-lib")
+                                      "/lib")
+                       "--with-netcdf"
+                       "--with-postgres"
+                       (string-append "--with-proj-share="
+                                      (assoc-ref inputs "proj.4")
+                                      "/share/proj")
+                       "--with-pthread"
+                       "--with-readline"
+                       "--with-sqlite"
+                       "--with-wxwidgets")))
+           (add-after 'install 'install-links
+             (lambda* (#:key outputs #:allow-other-keys)
+               ;; Put links for includes and libraries in the standard places.
+               (let* ((out (assoc-ref outputs "out"))
+                      (dir (string-append out "/" ,grassxx)))
+                 (symlink (string-append dir "/include")
+                          (string-append out "/include"))
+                 (symlink (string-append dir "/lib")
+                          (string-append out "/lib")))
+               #t))
+           (add-after 'install-links 'wrap-python
+             (assoc-ref python:%standard-phases 'wrap)))))
+      (synopsis "GRASS Geographic Information System")
+      (description
+       "GRASS (Geographic Resources Analysis Support System), is a Geographic
+Information System (GIS) software suite used for geospatial data management and
+analysis, image processing, graphics and maps production, spatial modeling, and
+visualization.")
+      (home-page "https://grass.osgeo.org/")
+      (license license:gpl2+))))
-- 
2.25.2