gnu: r-minimal, r-with-tests: Use G-expressions.

* gnu/packages/statistics.scm (r-minimal, r-with-tests)[arguments]: Use
G-expressions.

Change-Id: I241297444cdb261dfc9901efd73c436a7ccf0acf
This commit is contained in:
Ricardo Wurmus 2024-01-30 12:51:40 +01:00
parent 9f1ab898c3
commit afe677a623
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC

View File

@ -228,157 +228,157 @@ This package also provides @command{xls2csv} to export Excel files to CSV.")
"0aj51j34q2b28y28xvlf0dwdj8vpnhjwpvqf7xm05s7fq857dxdk")))) "0aj51j34q2b28y28xvlf0dwdj8vpnhjwpvqf7xm05s7fq857dxdk"))))
(build-system gnu-build-system) (build-system gnu-build-system)
(arguments (arguments
`(#:disallowed-references (,tzdata-for-tests) (list
#:make-flags #:disallowed-references `(,tzdata-for-tests)
(list (string-append "LDFLAGS=-Wl,-rpath=" #:make-flags
(assoc-ref %outputs "out") #~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib/R/lib")
"/lib/R/lib") ;; This affects the embedded timestamp of only the core packages.
;; This affects the embedded timestamp of only the core packages. "PKG_BUILT_STAMP=1970-01-01")
"PKG_BUILT_STAMP=1970-01-01") #:phases
#:phases #~(modify-phases %standard-phases
(modify-phases %standard-phases (add-before 'configure 'do-not-compress-serialized-files
(add-before 'configure 'do-not-compress-serialized-files (lambda _
(lambda* (#:key inputs #:allow-other-keys) ;; This ensures that Guix can detect embedded store references;
;; This ensures that Guix can detect embedded store references; ;; see bug #28157 for details.
;; see bug #28157 for details. (substitute* "src/library/base/makebasedb.R"
(substitute* "src/library/base/makebasedb.R" (("compress = TRUE") "compress = FALSE"))))
(("compress = TRUE") "compress = FALSE")))) (add-before 'configure 'patch-coreutils-paths
(add-before 'configure 'patch-coreutils-paths (lambda* (#:key inputs #:allow-other-keys)
(lambda* (#:key inputs #:allow-other-keys) (let ((uname-bin (search-input-file inputs "/bin/uname"))
(let ((uname-bin (search-input-file inputs "/bin/uname")) (rm-bin (search-input-file inputs "/bin/rm")))
(rm-bin (search-input-file inputs "/bin/rm"))) (substitute* "src/scripts/R.sh.in"
(substitute* "src/scripts/R.sh.in" (("uname") uname-bin))
(("uname") uname-bin)) (substitute* "src/unix/sys-std.c"
(substitute* "src/unix/sys-std.c" (("rm -Rf ") (string-append rm-bin " -Rf ")))
(("rm -Rf ") (string-append rm-bin " -Rf "))) (substitute* "src/library/parallel/R/detectCores.R"
(substitute* "src/library/parallel/R/detectCores.R" (("'grep")
(("'grep") (string-append "'"
(string-append "'" (search-input-file inputs "/bin/grep")))
(search-input-file inputs "/bin/grep"))) (("\\| wc -l")
(("\\| wc -l") (string-append "| "
(string-append "| " (search-input-file inputs "/bin/wc")
(search-input-file inputs "/bin/wc") " -l"))))))
" -l")))))) (add-after 'unpack 'patch-tests
(add-after 'unpack 'patch-tests (lambda _
(lambda _ ;; This is needed because R is run during the check phase and
;; This is needed because R is run during the check phase and ;; /bin/sh doesn't exist in the build container.
;; /bin/sh doesn't exist in the build container. (substitute* "src/unix/sys-unix.c"
(substitute* "src/unix/sys-unix.c" (("\"/bin/sh\"")
(("\"/bin/sh\"") (string-append "\"" (which "sh") "\"")))
(string-append "\"" (which "sh") "\""))) ;; This test fails because line numbers are off by two.
;; This test fails because line numbers are off by two. (substitute* "tests/reg-packages.R"
(substitute* "tests/reg-packages.R" (("8 <= print" m) (string-append "## " m)))))
(("8 <= print" m) (string-append "## " m))))) (add-after 'unpack 'build-reproducibly
(add-after 'unpack 'build-reproducibly (lambda _
(lambda _ ;; The documentation contains time stamps to demonstrate
;; The documentation contains time stamps to demonstrate ;; documentation generation in different phases.
;; documentation generation in different phases. (substitute* "src/library/tools/man/Rd2HTML.Rd"
(substitute* "src/library/tools/man/Rd2HTML.Rd" (("\\\\%Y-\\\\%m-\\\\%d at \\\\%H:\\\\%M:\\\\%S")
(("\\\\%Y-\\\\%m-\\\\%d at \\\\%H:\\\\%M:\\\\%S") "(removed for reproducibility)"))
"(removed for reproducibility)"))
;; Remove timestamp from tracing environment. This fixes ;; Remove timestamp from tracing environment. This fixes
;; reproducibility of "methods.rd{b,x}". ;; reproducibility of "methods.rd{b,x}".
(substitute* "src/library/methods/R/trace.R" (substitute* "src/library/methods/R/trace.R"
(("dateCreated = Sys.time\\(\\)") (("dateCreated = Sys.time\\(\\)")
"dateCreated = as.POSIXct(\"1970-1-1 00:00:00\", tz = \"UTC\")")) "dateCreated = as.POSIXct(\"1970-1-1 00:00:00\", tz = \"UTC\")"))
;; Ensure that gzipped files are reproducible. ;; Ensure that gzipped files are reproducible.
(substitute* '("src/library/grDevices/Makefile.in" (substitute* '("src/library/grDevices/Makefile.in"
"doc/manual/Makefile.in") "doc/manual/Makefile.in")
(("R_GZIPCMD\\)" line) (("R_GZIPCMD\\)" line)
(string-append line " -n"))) (string-append line " -n")))
;; The "srcfile" procedure in "src/library/base/R/srcfile.R" ;; The "srcfile" procedure in "src/library/base/R/srcfile.R"
;; queries the mtime of a given file and records it in an object. ;; queries the mtime of a given file and records it in an object.
;; This is acceptable at runtime to detect stale source files, ;; This is acceptable at runtime to detect stale source files,
;; but it destroys reproducibility at build time. ;; but it destroys reproducibility at build time.
;; Similarly, the "srcfilecopy" procedure records the current ;; Similarly, the "srcfilecopy" procedure records the current
;; time. We change both of them to respect SOURCE_DATE_EPOCH. ;; time. We change both of them to respect SOURCE_DATE_EPOCH.
(substitute* "src/library/base/R/srcfile.R" (substitute* "src/library/base/R/srcfile.R"
(("timestamp <- (timestamp.*|file.mtime.*)" _ time) (("timestamp <- (timestamp.*|file.mtime.*)" _ time)
(string-append "timestamp <- \ (string-append "timestamp <- \
as.POSIXct(if (\"\" != Sys.getenv(\"SOURCE_DATE_EPOCH\")) {\ as.POSIXct(if (\"\" != Sys.getenv(\"SOURCE_DATE_EPOCH\")) {\
as.numeric(Sys.getenv(\"SOURCE_DATE_EPOCH\"))\ as.numeric(Sys.getenv(\"SOURCE_DATE_EPOCH\"))\
} else { " time "}, origin=\"1970-01-01\")\n"))) } else { " time "}, origin=\"1970-01-01\")\n")))
;; This library is installed using "install_package_description", ;; This library is installed using "install_package_description",
;; so we need to pass the "builtStamp" argument. ;; so we need to pass the "builtStamp" argument.
(substitute* "src/library/tools/Makefile.in" (substitute* "src/library/tools/Makefile.in"
(("(install_package_description\\(.*\"')\\)\"" line prefix) (("(install_package_description\\(.*\"')\\)\"" line prefix)
(string-append prefix ", builtStamp='1970-01-01')\""))) (string-append prefix ", builtStamp='1970-01-01')\"")))
(substitute* "src/library/Recommended/Makefile.in" (substitute* "src/library/Recommended/Makefile.in"
(("INSTALL_OPTS =" m) (("INSTALL_OPTS =" m)
(string-append m " --built-timestamp=1970-01-01" m))) (string-append m " --built-timestamp=1970-01-01" m)))
;; R bundles an older version of help2man, which does not respect ;; R bundles an older version of help2man, which does not respect
;; SOURCE_DATE_EPOCH. We cannot just use the latest help2man, ;; SOURCE_DATE_EPOCH. We cannot just use the latest help2man,
;; because that breaks a test. ;; because that breaks a test.
(with-fluids ((%default-port-encoding "ISO-8859-1")) (with-fluids ((%default-port-encoding "ISO-8859-1"))
(substitute* "tools/help2man.pl" (substitute* "tools/help2man.pl"
(("my \\$date = strftime \"%B %Y\", localtime" line) (("my \\$date = strftime \"%B %Y\", localtime" line)
(string-append line " 1")))) (string-append line " 1"))))
;; The "References" section of this file when converted to ;; The "References" section of this file when converted to
;; package.rds is sometimes stored with a newline, sometimes with ;; package.rds is sometimes stored with a newline, sometimes with
;; a space. We avoid this problem by removing the line break ;; a space. We avoid this problem by removing the line break
;; that is suspected to be the culprit. ;; that is suspected to be the culprit.
(substitute* "src/library/methods/DESCRIPTION.in" (substitute* "src/library/methods/DESCRIPTION.in"
(("\\(2008\\)\n") "(2008) ") (("\\(2008\\)\n") "(2008) ")
((" ``Software") "``Software") ((" ``Software") "``Software")
(("Data Analysis:.") "Data Analysis:\n") (("Data Analysis:.") "Data Analysis:\n")
(("Programming with R") " Programming with R")) (("Programming with R") " Programming with R"))
(substitute* "src/library/tools/DESCRIPTION.in" (substitute* "src/library/tools/DESCRIPTION.in"
(("codetools, methods, xml2, curl, commonmark, knitr, xfun, mathjaxr") (("codetools, methods, xml2, curl, commonmark, knitr, xfun, mathjaxr")
"codetools, methods, xml2, curl, commonmark, "codetools, methods, xml2, curl, commonmark,
knitr, xfun, mathjaxr")))) knitr, xfun, mathjaxr"))))
(add-before 'build 'set-locales (add-before 'build 'set-locales
(lambda _ (lambda _
(setlocale LC_ALL "C") (setlocale LC_ALL "C")
(setenv "LC_ALL" "C"))) (setenv "LC_ALL" "C")))
(add-before 'configure 'set-default-pager (add-before 'configure 'set-default-pager
;; Set default pager to "cat", because otherwise it is "false", ;; Set default pager to "cat", because otherwise it is "false",
;; making "help()" print nothing at all. ;; making "help()" print nothing at all.
(lambda _ (setenv "PAGER" "cat"))) (lambda _ (setenv "PAGER" "cat")))
(add-before 'configure 'set-timezone (add-before 'configure 'set-timezone
;; Some tests require the timezone to be set. However, the ;; Some tests require the timezone to be set. However, the
;; timezone may not just be "UTC", or else a brittle regression ;; timezone may not just be "UTC", or else a brittle regression
;; test in reg-tests-1d will fail. ;; test in reg-tests-1d will fail.
;; We also need TZ during the configure step. ;; We also need TZ during the configure step.
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(setenv "TZ" "UTC+1") (setenv "TZ" "UTC+1")
(setenv "TZDIR" (setenv "TZDIR"
(search-input-directory inputs (search-input-directory inputs
"share/zoneinfo")))) "share/zoneinfo"))))
(add-before 'check 'set-home (add-before 'check 'set-home
;; Some tests require that HOME be set. ;; Some tests require that HOME be set.
(lambda _ (setenv "HOME" "/tmp"))) (lambda _ (setenv "HOME" "/tmp")))
(add-after 'build 'make-info (add-after 'build 'make-info
(lambda _ (invoke "make" "info"))) (lambda _ (invoke "make" "info")))
(add-after 'build 'install-info (add-after 'build 'install-info
(lambda _ (invoke "make" "install-info")))) (lambda _ (invoke "make" "install-info"))))
#:configure-flags #:configure-flags
`(;; We build the recommended packages here, because they are needed in #~(list
;; order to run the test suite. We disable them in the r-minimal ;; We build the recommended packages here, because they are needed in
;; package. ;; order to run the test suite. We disable them in the r-minimal
"--with-cairo" ;; package.
"--with-blas=-lopenblas" "--with-cairo"
"--with-libpng" "--with-blas=-lopenblas"
"--with-jpeglib" "--with-libpng"
"--with-libtiff" "--with-jpeglib"
"--with-ICU" "--with-libtiff"
"--with-tcltk" "--with-ICU"
,(string-append "--with-tcl-config=" "--with-tcltk"
(assoc-ref %build-inputs "tcl") (string-append "--with-tcl-config="
#$(this-package-input "tcl")
"/lib/tclConfig.sh") "/lib/tclConfig.sh")
,(string-append "--with-tk-config=" (string-append "--with-tk-config="
(assoc-ref %build-inputs "tk") #$(this-package-input "tk")
"/lib/tkConfig.sh") "/lib/tkConfig.sh")
"--enable-R-shlib" "--enable-R-shlib"
"--enable-BLAS-shlib" "--enable-BLAS-shlib"
"--with-system-tre"))) "--with-system-tre")))
;; R has some support for Java. When the JDK is available at configure ;; R has some support for Java. When the JDK is available at configure
;; time environment variables pointing to the JDK will be recorded under ;; time environment variables pointing to the JDK will be recorded under
;; $R_HOME/etc and ./tools/getsp.java will be compiled which is used by "R ;; $R_HOME/etc and ./tools/getsp.java will be compiled which is used by "R
@ -443,45 +443,44 @@ available, greatly increasing its breadth and scope.")
(package (inherit r-with-tests) (package (inherit r-with-tests)
(name "r-minimal") (name "r-minimal")
(arguments (arguments
`(#:tests? #f (substitute-keyword-arguments (package-arguments r-with-tests)
,@(substitute-keyword-arguments (package-arguments r-with-tests) ((#:tests? #f #f) #f)
((#:disallowed-references refs '()) ((#:disallowed-references refs '())
(cons perl refs)) (cons perl refs))
((#:configure-flags flags) ((#:configure-flags flags)
;; Do not build the recommended packages. The build system creates ;; Do not build the recommended packages. The build system creates
;; random temporary directories and embeds their names in some ;; random temporary directories and embeds their names in some
;; package files. We build these packages with the r-build-system ;; package files. We build these packages with the r-build-system
;; instead. ;; instead.
`(cons "--without-recommended-packages" ,flags)) #~(cons "--without-recommended-packages" #$flags))
((#:phases phases '%standard-phases) ((#:phases phases '%standard-phases)
`(modify-phases ,phases #~(modify-phases #$phases
(add-after 'install 'remove-extraneous-references (add-after 'install 'remove-extraneous-references
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))) (substitute* (string-append #$output "/lib/R/etc/Makeconf")
(substitute* (string-append out "/lib/R/etc/Makeconf") (("^# configure.*")
(("^# configure.*") "# Removed to avoid extraneous references\n"))
"# Removed to avoid extraneous references\n")) (substitute* (string-append #$output "/lib/R/bin/libtool")
(substitute* (string-append out "/lib/R/bin/libtool") (((string-append
(((string-append "(-L)?("
"(-L)?(" (format #false
(format #false "~a/[^-]+-(~{~a~^|~})-[^/]+"
"~a/[^-]+-(~{~a~^|~})-[^/]+" (%store-directory)
(%store-directory) '("bzip2"
'("bzip2" "file"
"file" "glibc-utf8-locales"
"glibc-utf8-locales" "graphite2"
"graphite2" "libselinux"
"libselinux" "libsepol"
"libsepol" "perl"
"perl" "texinfo"
"texinfo" "texlive-bin"
"texlive-bin" "util-macros"
"util-macros" "xz"))
"xz")) "|"
"|" (format #false "~a/[^-]+-glibc-[^-]+-static"
(format #false "~a/[^-]+-glibc-[^-]+-static" (%store-directory))
(%store-directory)) ")/lib")) ""))))))))))
")/lib")) ""))))))))))))
(define-public rmath-standalone (define-public rmath-standalone
(package (inherit r-minimal) (package (inherit r-minimal)