mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 13:28:12 -05:00
services: guix: Gracefully handle dangling symlink for ‘machines.scm’.
Previously, if /etc/guix/machines.scm was a dangling symlink, it would be kept (because ‘file-exists?’ would return #f) and thus the following ‘symlink’ call would throw with EEXIST. * gnu/services/base.scm (guix-machines-files-installation): Use ‘lstat’ rather than ‘file-exists?’. Change-Id: I07c7eed842dacabbd19ae2a17ac3e59cf26e46b2
This commit is contained in:
parent
0b941ea062
commit
91e1a457b5
1 changed files with 8 additions and 7 deletions
|
@ -1790,13 +1790,14 @@ (define machines-file
|
|||
;; If MACHINES-FILE already exists, move it out of the way.
|
||||
;; Create a backup if it's a regular file: it's likely that the
|
||||
;; user manually updated it.
|
||||
(if (file-exists? machines-file)
|
||||
(if (and (symbolic-link? machines-file)
|
||||
(store-file-name? (readlink machines-file)))
|
||||
(delete-file machines-file)
|
||||
(rename-file machines-file
|
||||
(string-append machines-file ".bak")))
|
||||
(mkdir-p (dirname machines-file)))
|
||||
(let ((stat (false-if-exception (lstat machines-file))))
|
||||
(if stat
|
||||
(if (and (eq? 'symlink (stat:type stat))
|
||||
(store-file-name? (readlink machines-file)))
|
||||
(delete-file machines-file)
|
||||
(rename-file machines-file
|
||||
(string-append machines-file ".bak")))
|
||||
(mkdir-p (dirname machines-file))))
|
||||
|
||||
;; Installed the declared machines file.
|
||||
(symlink #+(scheme-file "machines.scm"
|
||||
|
|
Loading…
Reference in a new issue