mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-27 04:59:27 -05: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
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
(define-module (guix scripts pull)
|
(define-module (guix scripts pull)
|
||||||
#:use-module (guix ui)
|
#:use-module (guix ui)
|
||||||
|
#:use-module (guix utils)
|
||||||
#:use-module (guix scripts)
|
#:use-module (guix scripts)
|
||||||
#:use-module (guix store)
|
#:use-module (guix store)
|
||||||
#:use-module (guix config)
|
#:use-module (guix config)
|
||||||
|
|
|
@ -73,7 +73,6 @@ (define-module (guix ui)
|
||||||
read/eval
|
read/eval
|
||||||
read/eval-package-expression
|
read/eval-package-expression
|
||||||
location->string
|
location->string
|
||||||
switch-symlinks
|
|
||||||
config-directory
|
config-directory
|
||||||
fill-paragraph
|
fill-paragraph
|
||||||
texi->plain-text
|
texi->plain-text
|
||||||
|
@ -715,13 +714,6 @@ (define (location->string loc)
|
||||||
(($ <location> file line column)
|
(($ <location> file line column)
|
||||||
(format #f "~a:~a:~a" file line column))))
|
(format #f "~a:~a:~a" file line column))))
|
||||||
|
|
||||||
(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 (config-directory)
|
(define (config-directory)
|
||||||
"Return the name of the configuration directory, after making sure that it
|
"Return the name of the configuration directory, after making sure that it
|
||||||
exists. Honor the XDG specs,
|
exists. Honor the XDG specs,
|
||||||
|
|
|
@ -74,6 +74,7 @@ (define-module (guix utils)
|
||||||
arguments-from-environment-variable
|
arguments-from-environment-variable
|
||||||
file-extension
|
file-extension
|
||||||
file-sans-extension
|
file-sans-extension
|
||||||
|
switch-symlinks
|
||||||
call-with-temporary-output-file
|
call-with-temporary-output-file
|
||||||
call-with-temporary-directory
|
call-with-temporary-directory
|
||||||
with-atomic-file-output
|
with-atomic-file-output
|
||||||
|
@ -557,6 +558,13 @@ (define (file-sans-extension file)
|
||||||
(substring file 0 dot)
|
(substring file 0 dot)
|
||||||
file)))
|
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
|
(define* (string-replace-substring str substr replacement
|
||||||
#:optional
|
#:optional
|
||||||
(start 0)
|
(start 0)
|
||||||
|
|
Loading…
Reference in a new issue