summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-10-17 22:51:08 +0200
committerLudovic Courtès <ludo@gnu.org>2012-10-17 23:25:25 +0200
commit7da95264f196d1c5dfa01654e87a319bce458cc1 (patch)
treeab9eaeb03784986b18e28fa60898c32dd7342862 /guix/build
parent7172116ca5178d3bd1ff7590aca50033c57e8ea1 (diff)
utils: Add `mkdir-p'; use it.
* guix/build/utils.scm (mkdir-p): New procedure. * distro/packages/base.scm (gnu-make-boot0, gcc-boot0-wrapped, ld-wrapper-boot3, %static-binaries, %guile-static-stripped): Use it. * distro/packages/typesetting.scm (lout): Likewise.
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/utils.scm26
1 files changed, 26 insertions, 0 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index d1d3116c45..0543ab48d5 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -26,6 +26,7 @@
#:use-module (rnrs io ports)
#:export (directory-exists?
with-directory-excursion
+ mkdir-p
set-path-environment-variable
search-path-as-string->list
list->search-path-as-string
@@ -62,6 +63,31 @@
(lambda ()
(chdir init)))))
+(define (mkdir-p dir)
+ "Create directory DIR and all its ancestors."
+ (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))))
+
;;;
;;; Search paths.