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.
This commit is contained in:
		
							parent
							
								
									09cc7729d0
								
							
						
					
					
						commit
						df2d51f025
					
				
					 1 changed files with 8 additions and 31 deletions
				
			
		|  | @ -717,32 +717,11 @@ and in the current monad setting (system type, etc.)" | ||||||
| ;;; Module handling. | ;;; Module handling. | ||||||
| ;;; | ;;; | ||||||
| 
 | 
 | ||||||
| (define %mkdir-p-definition | (define %utils-module | ||||||
|   ;; The code for 'mkdir-p' is copied from (guix build utils).  We use it in |   ;; This file provides 'mkdir-p', needed to implement 'imported-files' and | ||||||
|   ;; derivations that cannot use the #:modules argument of 'gexp->derivation' |   ;; other primitives below. | ||||||
|   ;; precisely because they implement that functionality. |   (local-file (search-path %load-path "guix/build/utils.scm") | ||||||
|   (gexp |               "build-utils.scm")) | ||||||
|    (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* (imported-files files | (define* (imported-files files | ||||||
|                          #:key (name "file-import") |                          #:key (name "file-import") | ||||||
|  | @ -763,10 +742,9 @@ system, imported, and appears under FINAL-PATH in the resulting store path." | ||||||
|     (define build |     (define build | ||||||
|       (gexp |       (gexp | ||||||
|        (begin |        (begin | ||||||
|  |          (primitive-load (ungexp %utils-module))  ;for 'mkdir-p' | ||||||
|          (use-modules (ice-9 match)) |          (use-modules (ice-9 match)) | ||||||
| 
 | 
 | ||||||
|          (ungexp %mkdir-p-definition) |  | ||||||
| 
 |  | ||||||
|          (mkdir (ungexp output)) (chdir (ungexp output)) |          (mkdir (ungexp output)) (chdir (ungexp output)) | ||||||
|          (for-each (match-lambda |          (for-each (match-lambda | ||||||
|                     ((final-path store-path) |                     ((final-path store-path) | ||||||
|  | @ -822,13 +800,12 @@ they can refer to each other." | ||||||
|     (define build |     (define build | ||||||
|       (gexp |       (gexp | ||||||
|        (begin |        (begin | ||||||
|  |          (primitive-load (ungexp %utils-module))  ;for 'mkdir-p' | ||||||
|  | 
 | ||||||
|          (use-modules (ice-9 ftw) |          (use-modules (ice-9 ftw) | ||||||
|                       (ice-9 match) |  | ||||||
|                       (srfi srfi-26) |                       (srfi srfi-26) | ||||||
|                       (system base compile)) |                       (system base compile)) | ||||||
| 
 | 
 | ||||||
|          (ungexp %mkdir-p-definition) |  | ||||||
| 
 |  | ||||||
|          (define (regular? file) |          (define (regular? file) | ||||||
|            (not (member file '("." "..")))) |            (not (member file '("." "..")))) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Reference in a new issue