aboutsummaryrefslogtreecommitdiff
path: root/guix/build/utils.scm
diff options
context:
space:
mode:
authorArun Isaac <arunisaac@systemreboot.net>2022-06-13 16:57:40 +0530
committerArun Isaac <arunisaac@systemreboot.net>2022-06-25 01:43:04 +0530
commit2c05a6112b40c85dd0509052a6a6b97fa127f1c6 (patch)
tree4c0a52244ca7522c98428f14d6e30fae6a278bb4 /guix/build/utils.scm
parent22aeda1bcc15db33f021c344a95d75984449d72a (diff)
downloadguix-2c05a6112b40c85dd0509052a6a6b97fa127f1c6.tar
guix-2c05a6112b40c85dd0509052a6a6b97fa127f1c6.tar.gz
utils: Move switch-symlinks to (guix build utils).
* guix/utils.scm (switch-symlinks): Move to ... * guix/build/utils.scm (switch-symlinks): ... here. * guix/profiles.scm, guix/scripts/home.scm, guix/scripts/package.scm: Import switch-symlinks from (guix build utils). * guix/scripts/system/reconfigure.scm (switch-system-program): Import (guix build utils) in G-expression.
Diffstat (limited to 'guix/build/utils.scm')
-rw-r--r--guix/build/utils.scm8
1 files changed, 8 insertions, 0 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index b822caf619..ce7bdb2024 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -60,6 +60,7 @@
directory-exists?
executable-file?
symbolic-link?
+ switch-symlinks
call-with-temporary-output-file
call-with-ascii-input-file
file-header-match
@@ -240,6 +241,13 @@ introduce the version part."
"Return #t if FILE is a symbolic link (aka. \"symlink\".)"
(eq? (stat:type (lstat file)) 'symlink))
+(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 (call-with-temporary-output-file proc)
"Call PROC with a name of a temporary file and open output port to that
file; close the file and delete it when leaving the dynamic extent of this