[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/05: scripts: Do not create the config directory.
From: |
Ludovic Courtès |
Subject: |
04/05: scripts: Do not create the config directory. |
Date: |
Fri, 12 May 2017 18:03:55 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit e06ca952ed150c50109b1a29cd0e3645a80023a2
Author: Ludovic Courtès <address@hidden>
Date: Fri May 12 22:39:33 2017 +0200
scripts: Do not create the config directory.
This fixes runs of 'guix package' and 'guix system' tests in
environments where $HOME is read-only.
* guix/ui.scm (config-directory): Add #:ensure? parameter and honor it.
* guix/scripts.scm (warn-about-old-distro): Pass #:ensure? #f to
'config-directory'.
---
guix/scripts.scm | 3 ++-
guix/ui.scm | 7 ++++---
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/guix/scripts.scm b/guix/scripts.scm
index d5c53de..9ff7f25 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -165,7 +165,8 @@ Show what and how will/would be built."
(define age
(match (false-if-not-found
- (lstat (string-append (config-directory) "/latest")))
+ (lstat (string-append (config-directory #:ensure? #f)
+ "/latest")))
(#f #f)
(stat (- (time-second (current-time time-utc))
(stat:mtime stat)))))
diff --git a/guix/ui.scm b/guix/ui.scm
index e7cb409..edd04da 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -775,9 +775,9 @@ replacement if PORT is not Unicode-capable."
(($ <location> file line column)
(format #f "~a:~a:~a" file line column))))
-(define (config-directory)
+(define* (config-directory #:key (ensure? #t))
"Return the name of the configuration directory, after making sure that it
-exists. Honor the XDG specs,
+exists if ENSURE? is true. Honor the XDG specs,
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>."
(let ((dir (and=> (or (getenv "XDG_CONFIG_HOME")
(and=> (getenv "HOME")
@@ -785,7 +785,8 @@ exists. Honor the XDG specs,
(cut string-append <> "/guix"))))
(catch 'system-error
(lambda ()
- (mkdir-p dir)
+ (when ensure?
+ (mkdir-p dir))
dir)
(lambda args
(let ((err (system-error-errno args)))