guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

05/06: utils: Add 'strip-store-file-name'.


From: Ludovic Courtès
Subject: 05/06: utils: Add 'strip-store-file-name'.
Date: Sun, 30 Aug 2015 17:10:09 +0000

civodul pushed a commit to branch core-updates
in repository guix.

commit b7c7c03eb5e37fc3455e4e17b0898ffc4bca29c3
Author: Ludovic Courtès <address@hidden>
Date:   Sun Aug 30 14:38:10 2015 +0200

    utils: Add 'strip-store-file-name'.
    
    * guix/build/utils.scm (strip-store-file-name): New procedure.
    * guix/build/emacs-build-system.scm (store-directory->name-version):
      Remove.  Update callers to use 'strip-store-file-name'.
    * gnu/packages/gcc.scm (make-libstdc++-doc)[arguments]: Use
      'strip-store-file-name' instead of 'string-drop'.
---
 gnu/packages/gcc.scm              |    6 +-----
 guix/build/emacs-build-system.scm |   17 +++++------------
 guix/build/utils.scm              |    7 +++++++
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 761d3a6..dcac16d 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -578,11 +578,7 @@ using compilers other than GCC."
                                     (("@XSL_STYLE_DIR@")
                                      (string-append
                                       docbook "/xml/xsl/"
-                                      (string-drop
-                                       docbook
-                                       (+ 34
-                                          (string-length
-                                           (%store-directory))))))))))
+                                      (strip-store-file-name docbook)))))))
                   (replace 'build
                            (lambda _
                              ;; XXX: There's also a 'doc-info' target, but it
diff --git a/guix/build/emacs-build-system.scm 
b/guix/build/emacs-build-system.scm
index f18db0a..1c48a1a 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -83,7 +83,7 @@ store in '.el' files."
   (let* ((out (assoc-ref outputs "out"))
          (elpa-name-ver (store-directory->elpa-name-version out))
          (el-dir (string-append out %install-suffix "/" elpa-name-ver))
-         (name-ver (store-directory->name-version out))
+         (name-ver (strip-store-file-name out))
          (info-dir (string-append out "/share/info/" name-ver))
          (info-files (find-files el-dir "\\.info$")))
     (unless (null? info-files)
@@ -116,7 +116,7 @@ store in '.el' files."
   (filter (match-lambda
             ((label . directory)
              (emacs-package? ((compose package-name->name+version
-                                       store-directory->name-version)
+                                       strip-store-file-name)
                               directory)))
             (_ #f))
           inputs))
@@ -138,25 +138,18 @@ DIRS."
 (define (package-name-version->elpa-name-version name-ver)
   "Convert the Guix package NAME-VER to the corresponding ELPA name-version
 format.  Essnetially drop the prefix used in Guix."
-  (let ((name (store-directory->name-version name-ver)))
+  (let ((name (strip-store-file-name name-ver)))
     (if (emacs-package? name-ver)
-        (store-directory->name-version name-ver)
+        (strip-store-file-name name-ver)
         name-ver)))
 
 (define (store-directory->elpa-name-version store-dir)
   "Given a store directory STORE-DIR return the part of the basename after the
 second hyphen.  This corresponds to 'name-version' as used in ELPA packages."
   ((compose package-name-version->elpa-name-version
-            store-directory->name-version)
+            strip-store-file-name)
    store-dir))
 
-(define (store-directory->name-version store-dir)
-  "Given a store directory STORE-DIR return the part of the basename
-after the first hyphen.  This corresponds to 'name-version' of the package."
-  (let* ((base (basename store-dir)))
-    (string-drop base
-                 (+ 1 (string-index base #\-)))))
-
 ;; from (guix utils).  Should we put it in (guix build utils)?
 (define (package-name->name+version name)
   "Given NAME, a package name like \"foo-0.9.1b\", return two values:
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 1640693..b0abc69 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -33,6 +33,7 @@
                alist-delete)
   #:export (%store-directory
             store-file-name?
+            strip-store-file-name
             parallel-job-count
 
             directory-exists?
@@ -87,6 +88,12 @@
   "Return true if FILE is in the store."
   (string-prefix? (%store-directory) file))
 
+(define (strip-store-file-name file)
+  "Strip the '/gnu/store' and hash from FILE, a store file name.  The result
+is typically a \"PACKAGE-VERSION\" string."
+  (string-drop file
+               (+ 34 (string-length (%store-directory)))))
+
 (define parallel-job-count
   ;; Number of processes to be passed next to GNU Make's `-j' argument.
   (make-parameter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]