guix-commits
[Top][All Lists]
Advanced

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

04/04: gexp: Remove duplicate 'mkdir-p' definition.


From: Ludovic Courtès
Subject: 04/04: gexp: Remove duplicate 'mkdir-p' definition.
Date: Wed, 02 Sep 2015 12:14:11 +0000

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

commit df2d51f025fc7d106f837da3a2426bb7eddc76a9
Author: Ludovic Courtès <address@hidden>
Date:   Sun Aug 30 22:52:49 2015 +0200

    gexp: Remove duplicate 'mkdir-p' definition.
    
    * guix/gexp.scm (%mkdir-p-definition): Remove.
      (%utils-module): New variable.
      (imported-files, compiled-modules): Have gexp load %UTILS-MODULE
      instead of using %MKDIR-P-DEFINITION.
---
 guix/gexp.scm |   39 ++++++++-------------------------------
 1 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index 63af40a..de49fef 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -717,32 +717,11 @@ and in the current monad setting (system type, etc.)"
 ;;; Module handling.
 ;;;
 
-(define %mkdir-p-definition
-  ;; The code for 'mkdir-p' is copied from (guix build utils).  We use it in
-  ;; derivations that cannot use the #:modules argument of 'gexp->derivation'
-  ;; precisely because they implement that functionality.
-  (gexp
-   (define (mkdir-p dir)
-     (define absolute?
-       (string-prefix? "/" dir))
-
-     (define not-slash
-       (char-set-complement (char-set #\/)))
-
-     (let loop ((components (string-tokenize dir not-slash))
-                (root       (if absolute? "" ".")))
-       (match components
-         ((head tail ...)
-          (let ((path (string-append root "/" head)))
-            (catch 'system-error
-              (lambda ()
-                (mkdir path)
-                (loop tail path))
-              (lambda args
-                (if (= EEXIST (system-error-errno args))
-                    (loop tail path)
-                    (apply throw args))))))
-         (() #t))))))
+(define %utils-module
+  ;; This file provides 'mkdir-p', needed to implement 'imported-files' and
+  ;; other primitives below.
+  (local-file (search-path %load-path "guix/build/utils.scm")
+              "build-utils.scm"))
 
 (define* (imported-files files
                          #:key (name "file-import")
@@ -763,10 +742,9 @@ system, imported, and appears under FINAL-PATH in the 
resulting store path."
     (define build
       (gexp
        (begin
+         (primitive-load (ungexp %utils-module))  ;for 'mkdir-p'
          (use-modules (ice-9 match))
 
-         (ungexp %mkdir-p-definition)
-
          (mkdir (ungexp output)) (chdir (ungexp output))
          (for-each (match-lambda
                     ((final-path store-path)
@@ -822,13 +800,12 @@ they can refer to each other."
     (define build
       (gexp
        (begin
+         (primitive-load (ungexp %utils-module))  ;for 'mkdir-p'
+
          (use-modules (ice-9 ftw)
-                      (ice-9 match)
                       (srfi srfi-26)
                       (system base compile))
 
-         (ungexp %mkdir-p-definition)
-
          (define (regular? file)
            (not (member file '("." ".."))))
 



reply via email to

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