From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBRi9-0005Vn-9G for guix-patches@gnu.org; Sun, 05 Nov 2017 15:40:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBRi6-0002L1-53 for guix-patches@gnu.org; Sun, 05 Nov 2017 15:40:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:43977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBRi5-0002Kt-W8 for guix-patches@gnu.org; Sun, 05 Nov 2017 15:40:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eBRi5-00005i-P1 for guix-patches@gnu.org; Sun, 05 Nov 2017 15:40:01 -0500 Subject: [bug#29161] [PATCH core-updates] build-system/gnu: Add 'install-license-files' phase. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBRhZ-0005VU-MO for guix-patches@gnu.org; Sun, 05 Nov 2017 15:39:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBRhY-0002A7-7Y for guix-patches@gnu.org; Sun, 05 Nov 2017 15:39:29 -0500 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Date: Sun, 05 Nov 2017 21:39:18 +0100 Message-ID: <87ineoo3yh.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29161@debbugs.gnu.org Cc: Dave Love --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Guix, This patch adds an =E2=80=98install-license-files=E2=80=99 phase to =E2=80= =98gnu-build-system=E2=80=99 and to all the build systems that inherit from it. It is a followup to the discussion with Dave Love: https://lists.gnu.org/archive/html/guix-devel/2017-09/msg00097.html It=E2=80=99s an improvement over what we have now, although it=E2=80=99s ru= dimentary: it copies to share/doc/PACKAGE-VERSION any file from the top-level source directory that matches a regexp. Thoughts? Ideally we could apply it in this =E2=80=98core-updates=E2=80=99 cycle if t= hat=E2=80=99s fine with you. Thanks in advance, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-build-system-gnu-Add-install-license-files-phase.patch >From bcdfb1a89b82c9c10e80f1a5d6aadc0620e81156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 5 Nov 2017 21:32:02 +0100 Subject: [PATCH] build-system/gnu: Add 'install-license-files' phase. Suggested by Dave Love . * 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. --- guix/build-system/gnu.scm | 8 ++++++++ guix/build/gnu-build-system.scm | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index 047ace7e6..f54afe167 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -273,6 +273,10 @@ standard packages used as implicit inputs of the GNU build system." (build (if target gnu-cross-build gnu-build)) (arguments (strip-keyword-arguments private-keywords arguments)))) +(define %license-file-regexp + ;; Regexp matching license files. + "^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\.(txt|md))?)$") + (define* (gnu-build store name input-drvs #:key (guile #f) (outputs '("out")) @@ -291,6 +295,7 @@ standard packages used as implicit inputs of the GNU build system." (strip-directories ''("lib" "lib64" "libexec" "bin" "sbin")) (validate-runpath? #t) + (license-file-regexp %license-file-regexp) (phases '%standard-phases) (locale "en_US.utf8") (system (%current-system)) @@ -358,6 +363,7 @@ packages that must not be referenced." #:patch-shebangs? ,patch-shebangs? #:strip-binaries? ,strip-binaries? #:validate-runpath? ,validate-runpath? + #:license-file-regexp ,license-file-regexp #:strip-flags ,strip-flags #:strip-directories ,strip-directories))) @@ -432,6 +438,7 @@ is one of `host' or `target'." (strip-directories ''("lib" "lib64" "libexec" "bin" "sbin")) (validate-runpath? #t) + (license-file-regexp %license-file-regexp) (phases '%standard-phases) (locale "en_US.utf8") (system (%current-system)) @@ -509,6 +516,7 @@ platform." #:patch-shebangs? ,patch-shebangs? #:strip-binaries? ,strip-binaries? #:validate-runpath? ,validate-runpath? + #:license-file-regexp ,license-file-regexp #:strip-flags ,strip-flags #:strip-directories ,strip-directories)))) diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index e37b75140..eb247ae0c 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,29 @@ 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") + (car (first outputs)))) + (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 +678,7 @@ which cannot be found~%" validate-documentation-location delete-info-dir-file patch-dot-desktop-files + install-license-files reset-gzip-timestamps compress-documentation))) -- 2.14.2 --=-=-=--