summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2021-09-17 10:17:33 +0200
committerLars-Dominik Braun <lars@6xq.net>2021-10-08 09:13:52 +0200
commita01daed62c24d62e8350ce15d7a19aed37289807 (patch)
tree0ebfec170a1549bb5fc4ceab6860fdaa3ca14f2f /guix/build
parent7cdb65dc9cceebfd3a45eeb281530f91f1b43b81 (diff)
build-system/haskell: Accept line breaks in config files.
Long id’s will break to the next line. * guix/build/haskell-build-system.scm (grep): Remove. (register): Modify regular expression to account for newlines between key and value, fail if package id is empty.
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/haskell-build-system.scm24
1 files changed, 10 insertions, 14 deletions
diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm
index 7d50bae721..4d0bf6f38a 100644
--- a/guix/build/haskell-build-system.scm
+++ b/guix/build/haskell-build-system.scm
@@ -143,17 +143,6 @@ and parameters ~s~%"
(find-files lib "\\.a$"))))
#t)
-(define (grep rx port)
- "Given a regular-expression RX including a group, read from PORT until the
-first match and return the content of the group."
- (let ((line (read-line port)))
- (if (eof-object? line)
- #f
- (let ((rx-result (regexp-exec rx line)))
- (if rx-result
- (match:substring rx-result 1)
- (grep rx port))))))
-
(define* (setup-compiler #:key system inputs outputs #:allow-other-keys)
"Setup the compiler environment."
(let* ((haskell (assoc-ref inputs "haskell"))
@@ -242,7 +231,7 @@ given Haskell package."
(config-dir (string-append lib
"/ghc-" version
"/" name ".conf.d"))
- (id-rx (make-regexp "^id: *(.*)$"))
+ (id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
(config-file (string-append out "/" name ".conf"))
(params
(list (string-append "--gen-pkg-config=" config-file))))
@@ -250,8 +239,15 @@ given Haskell package."
;; The conf file is created only when there is a library to register.
(when (file-exists? config-file)
(mkdir-p config-dir)
- (let ((config-file-name+id
- (call-with-ascii-input-file config-file (cut grep id-rx <>))))
+ (let* ((contents (call-with-input-file config-file read-string))
+ (config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
+
+ (when (or
+ (and
+ (string? config-file-name+id)
+ (string-null? config-file-name+id))
+ (not config-file-name+id))
+ (error (format #f "The package id for ~a is empty. This is a bug." config-file)))
;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
;; "haddock-interfaces" field and removing the optional "haddock-html"