Subject: [PATCH 2/2] gnu: r-haven: Unvendor readstat.

From: Lars-Dominik Braun <[email-masked]>
Date: Tue, 23 Feb 2021 14:07:14 +0100

* gnu/packages/cran.scm (r-haven) [snippet]: Remove bundled readstat.
[arguments]: Patch Makevars to use system readstat.
[inputs]: Replace zlib with readstat.
---
 gnu/packages/cran.scm | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/cran.scm b/gnu/packages/cran.scm
index 4a88cf1677..d675b7e37a 100644
--- a/gnu/packages/cran.scm
+++ b/gnu/packages/cran.scm
@@ -2309,10 +2309,25 @@ including functions for geolocation and routing.")
        (uri (cran-uri "haven" version))
        (sha256
         (base32
-         "03cypgqhdkrfbfpl1yx2wb7flczrbak1w654wkicmd5ajwr9zvkf"))))
+         "03cypgqhdkrfbfpl1yx2wb7flczrbak1w654wkicmd5ajwr9zvkf"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+            ;; unvendor readstat
+           (delete-file-recursively "src/readstat")
+           #t))))
     (build-system r-build-system)
+    (arguments
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'unbundle-readstat
+           (lambda _
+             ;; Not required, since we’re not building readstat.
+             (substitute* "src/Makevars"
+               (("-lz") "-lreadstat"))
+             #t)))))
     (inputs
-     `(("zlib" ,zlib)))
+     `(("readstat" ,readstat)))
     (native-inputs
      `(("r-knitr" ,r-knitr)))
     (propagated-inputs
-- 
2.26.2