summaryrefslogtreecommitdiff
path: root/guix/build/gnu-build-system.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-11-05 21:32:02 +0100
committerLudovic Courtès <ludo@gnu.org>2017-11-08 22:43:56 +0100
commita864d563025f7408204af8540f8611a56bd3c939 (patch)
tree8e8ecc1efa95cc3ffb1ae0cc6875e86321d152a0 /guix/build/gnu-build-system.scm
parentdcc00f54c619118d11982383102d2e9a1b86d080 (diff)
downloadguix-patches-a864d563025f7408204af8540f8611a56bd3c939.tar
guix-patches-a864d563025f7408204af8540f8611a56bd3c939.tar.gz
build-system/gnu: Add 'install-license-files' phase.
Suggested by Dave Love <fx@gnu.org>. * guix/build-system/gnu.scm (%license-file-regexp): New variable. (gnu-build): Add #:license-file-regexp and use it. (gnu-cross-build): Likewise. * guix/build/gnu-build-system.scm (%license-file-regexp): New variable. (install-license-files): New procedure. (%standard-phases): Add it.
Diffstat (limited to 'guix/build/gnu-build-system.scm')
-rw-r--r--guix/build/gnu-build-system.scm27
1 files changed, 27 insertions, 0 deletions
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index e37b751403..7b43361f99 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -29,6 +29,7 @@
#:use-module (srfi srfi-26)
#:use-module (rnrs io ports)
#:export (%standard-phases
+ %license-file-regexp
gnu-build))
;; Commentary:
@@ -641,6 +642,31 @@ which cannot be found~%"
outputs)
#t)
+(define %license-file-regexp
+ ;; Regexp matching license files.
+ "^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\.(txt|md))?)$")
+
+(define* (install-license-files #:key outputs
+ (license-file-regexp %license-file-regexp)
+ #:allow-other-keys)
+ "Install license files matching LICENSE-FILE-REGEXP to 'share/doc'."
+ (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))
+ (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)
+ #t))
+
(define %standard-phases
;; Standard build phases, as a list of symbol/procedure pairs.
(let-syntax ((phases (syntax-rules ()
@@ -654,6 +680,7 @@ which cannot be found~%"
validate-documentation-location
delete-info-dir-file
patch-dot-desktop-files
+ install-license-files
reset-gzip-timestamps
compress-documentation)))