build-system/gnu: Copy license files to all the outputs.

Fixes <https://bugs.gnu.org/34702>.
Reported by Leo Famulari <leo@famulari.name>.

* guix/build/gnu-build-system.scm (install-license-files)[copy-to-directories]:
New procedure.
Call it to copy license files to all the outputs.
This commit is contained in:
Ludovic Courtès 2019-03-10 22:16:14 +01:00
parent 278409e7e9
commit 6db044db45
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -758,13 +758,23 @@ (define (find-source-directory package)
(string-append "../" directory)))
directories))))
(define (copy-to-directories directories sub-directory)
(lambda (file)
(for-each (if (file-is-directory? file)
(cut copy-recursively file <>)
(cut install-file file <>))
(map (cut string-append <> "/" sub-directory)
directories))))
(let* ((regexp (make-regexp license-file-regexp))
(out (or (assoc-ref outputs "out")
(match outputs
(((_ . output) _ ...)
output))))
(package (strip-store-file-name out))
(directory (string-append out "/share/doc/" package))
(outputs (match outputs
(((_ . outputs) ...)
outputs)))
(source (if out-of-source?
(find-source-directory
(package-name->name+version package))
@ -777,10 +787,9 @@ (define (find-source-directory package)
(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)))
(for-each (copy-to-directories outputs
(string-append "share/doc/"
package))
(map (cut string-append source "/" <>) files)))
(format (current-error-port)
"failed to find license files~%"))