diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-07-03 11:24:32 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-07-03 17:50:04 +0200 |
commit | f3f1d0a5578b4ad6d85494283eedfaa62b28fe2c (patch) | |
tree | 7fb0f73afbfe4e6efb5db521d735fbdd011291f1 | |
parent | 90b144d22d001a832a8fb345a7d71e9c657c0c86 (diff) | |
download | guix-f3f1d0a5578b4ad6d85494283eedfaa62b28fe2c.tar guix-f3f1d0a5578b4ad6d85494283eedfaa62b28fe2c.tar.gz |
guix system: Make 'init' idempotent again.
This fixes a regression introduced in
df2f6400b1fbc282ef4d6dd7124ea1c17adc23c2: since the new
'register-path' (actually 'reset-timestamps') would make files
read-only, 'delete-file-recursively' would fail to delete them. Thus,
re-running 'guix system init' on an already-populated store would fail
with a 'delete-file' EPERM.
* guix/scripts/system.scm (copy-item): Use 'lstat' instead of
'file-exists?'. Call 'make-file-writable' on each directory below
DEST.
-rw-r--r-- | guix/scripts/system.scm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 92e92237b6..69bd05b516 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -126,7 +126,11 @@ REFERENCES as its set of references." ;; Remove DEST if it exists to make sure that (1) we do not fail badly ;; while trying to overwrite it (see <http://bugs.gnu.org/20722>), and ;; (2) we end up with the right contents. - (when (file-exists? dest) + (when (false-if-exception (lstat dest)) + (for-each make-file-writable + (find-files dest (lambda (file stat) + (eq? 'directory (stat:type stat))) + #:directories? #t)) (delete-file-recursively dest)) (copy-recursively item dest |