GNU bug report logs - #26559
[PATCH] build: emacs: Install only a subset of files.

Previous Next

Package: guix-patches;

Reported by: Arun Isaac <arunisaac <at> systemreboot.net>

Date: Wed, 19 Apr 2017 07:37:01 UTC

Severity: normal

Tags: patch

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Arun Isaac <arunisaac <at> systemreboot.net>
To: 26559 <at> debbugs.gnu.org
Cc: Arun Isaac <arunisaac <at> systemreboot.net>
Subject: bug#26559: [PATCH 1/3] build: emacs: Install only a subset of files.
Date: Wed, 26 Apr 2017 19:39:27 +0530
* guix/build/emacs-build-system.scm (install): Install files matching
  #:include while excluding files matching #:exclude.
* guix/build-system/emacs.scm (emacs-build): Add keyword arguments #:include
  and #:exclude.
---
 guix/build-system/emacs.scm       |  4 ++++
 guix/build/emacs-build-system.scm | 25 +++++++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/guix/build-system/emacs.scm b/guix/build-system/emacs.scm
index a7982002b..9a46ecfd2 100644
--- a/guix/build-system/emacs.scm
+++ b/guix/build-system/emacs.scm
@@ -83,6 +83,8 @@
                       (phases '(@ (guix build emacs-build-system)
                                   %standard-phases))
                       (outputs '("out"))
+                      (include ''("^[^/]*\\.el$" "^[^/]*\\.info$" "^doc/.*\\.info$"))
+                      (exclude ''("^\\.dir-locals\\.el$" "-pkg\\.el$" "^[^/]*tests?\\.el$"))
                       (search-paths '())
                       (system (%current-system))
                       (guile #f)
@@ -108,6 +110,8 @@
                     #:tests? ,tests?
                     #:phases ,phases
                     #:outputs %outputs
+                    #:include ,include
+                    #:exclude ,exclude
                     #:search-paths ',(map search-path-specification->sexp
                                           search-paths)
                     #:inputs %build-inputs)))
diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm
index 44e8b0d31..fefdbb96e 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -28,6 +28,7 @@
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 regex)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 ftw)
   #:export (%standard-phases
             emacs-build))
 
@@ -93,14 +94,30 @@ store in '.el' files."
           (substitute-cmd))))
     #t))
 
-(define* (install #:key outputs #:allow-other-keys)
+(define* (install #:key outputs
+                  (include '("^[^/]*\\.el$" "^[^/]*\\.info$" "^doc/.*\\.info$"))
+                  (exclude '("^\\.dir-locals\\.el$" "-pkg\\.el$" "^[^/]*tests?\\.el$"))
+                  #:allow-other-keys)
   "Install the package contents."
+
+  (define src-dir (getcwd))
+
+  (define (install-file? file stat)
+    (let ((stripped-file (string-trim (substring file (string-length src-dir)) #\/)))
+      (and (any (cut string-match <> stripped-file) include)
+           (not (any (cut string-match <> stripped-file) exclude)))))
+
   (let* ((out (assoc-ref outputs "out"))
          (elpa-name-ver (store-directory->elpa-name-version out))
-         (src-dir (getcwd))
          (tgt-dir (string-append out %install-suffix "/" elpa-name-ver)))
-    (copy-recursively src-dir tgt-dir)
-    #t))
+    (for-each
+     (lambda (file)
+       (let* ((stripped-file (substring file (string-length src-dir)))
+              (tgt-file (string-append tgt-dir stripped-file)))
+         (format #t "`~a' -> `~a'~%" file tgt-file)
+         (install-file file (dirname tgt-file))))
+     (find-files src-dir install-file?)))
+  #t)
 
 (define* (move-doc #:key outputs #:allow-other-keys)
   "Move info files from the ELPA package directory to the info directory."
-- 
2.12.2





This bug report was last modified 8 years and 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.