summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-03-09 15:08:11 +0100
committerLudovic Courtès <ludo@gnu.org>2019-03-10 22:24:08 +0100
commit278409e7e9ad63b80afa0a40c220dedd78c0aa54 (patch)
tree31b778880827dcfaa30b7686d46ad4d82ce6b382 /guix/build
parent5a457656284cfb25e9305362e18adf4aff13f91a (diff)
build-system/gnu: Always look for license files in the source tree.
Fixes <https://bugs.gnu.org/31103>. * guix/build/gnu-build-system.scm (install-license-files): Add #:out-of-source?. [find-source-directory]: New procedure. Use it to Determine the source directory and look for license files there.
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/gnu-build-system.scm48
1 files changed, 40 insertions, 8 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 3f68ad52ed..f62e96112d 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -735,8 +735,29 @@ which cannot be found~%"
(define* (install-license-files #:key outputs
(license-file-regexp %license-file-regexp)
+ out-of-source?
#:allow-other-keys)
"Install license files matching LICENSE-FILE-REGEXP to 'share/doc'."
+ (define (find-source-directory package)
+ ;; For an out-of-source build, guess the source directory location
+ ;; relative to the current directory. Return #f on failure.
+ (match (scandir ".."
+ (lambda (file)
+ (and (not (member file '("." ".." "build")))
+ (file-is-directory?
+ (string-append "../" file)))))
+ (() ;hmm, no source
+ #f)
+ ((source) ;only one other file
+ (string-append "../" source))
+ ((directories ...) ;pick the most likely one
+ ;; This happens for example with libstdc++, which lives within the GCC
+ ;; source tree.
+ (any (lambda (directory)
+ (and (string-prefix? package directory)
+ (string-append "../" directory)))
+ directories))))
+
(let* ((regexp (make-regexp license-file-regexp))
(out (or (assoc-ref outputs "out")
(match outputs
@@ -744,14 +765,25 @@ which cannot be found~%"
output))))
(package (strip-store-file-name out))
(directory (string-append out "/share/doc/" package))
- (files (scandir "." (lambda (file)
- (regexp-exec regexp file)))))
- (format #t "installing ~a license files~%" (length files))
- (for-each (lambda (file)
- (if (file-is-directory? file)
- (copy-recursively file directory)
- (install-file file directory)))
- files)
+ (source (if out-of-source?
+ (find-source-directory
+ (package-name->name+version package))
+ "."))
+ (files (and source
+ (scandir source
+ (lambda (file)
+ (regexp-exec regexp file))))))
+ (if files
+ (begin
+ (format #t "installing ~a license files from '~a'~%"
+ (length files) source)
+ (for-each (lambda (file)
+ (if (file-is-directory? file)
+ (copy-recursively file directory)
+ (install-file file directory)))
+ (map (cut string-append source "/" <>) files)))
+ (format (current-error-port)
+ "failed to find license files~%"))
#t))
(define %standard-phases