mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
utils: Add 'switch-symlinks', moved from (guix ui).
* guix/ui.scm (switch-symlinks): Move to... * guix/utils.scm: ... here. New procedure. * guix/scripts/pull.scm: Use it.
This commit is contained in:
parent
65797bfffd
commit
3bb168b099
3 changed files with 9 additions and 8 deletions
|
@ -74,6 +74,7 @@
|
|||
arguments-from-environment-variable
|
||||
file-extension
|
||||
file-sans-extension
|
||||
switch-symlinks
|
||||
call-with-temporary-output-file
|
||||
call-with-temporary-directory
|
||||
with-atomic-file-output
|
||||
|
@ -557,6 +558,13 @@ minor version numbers from version-string."
|
|||
(substring file 0 dot)
|
||||
file)))
|
||||
|
||||
(define (switch-symlinks link target)
|
||||
"Atomically switch LINK, a symbolic link, to point to TARGET. Works
|
||||
both when LINK already exists and when it does not."
|
||||
(let ((pivot (string-append link ".new")))
|
||||
(symlink target pivot)
|
||||
(rename-file pivot link)))
|
||||
|
||||
(define* (string-replace-substring str substr replacement
|
||||
#:optional
|
||||
(start 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue