diff options
author | Arun Isaac <arunisaac@systemreboot.net> | 2022-06-13 16:57:40 +0530 |
---|---|---|
committer | Arun Isaac <arunisaac@systemreboot.net> | 2022-06-25 01:43:04 +0530 |
commit | 2c05a6112b40c85dd0509052a6a6b97fa127f1c6 (patch) | |
tree | 4c0a52244ca7522c98428f14d6e30fae6a278bb4 /guix | |
parent | 22aeda1bcc15db33f021c344a95d75984449d72a (diff) |
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')
-rw-r--r-- | guix/build/utils.scm | 8 | ||||
-rw-r--r-- | guix/profiles.scm | 3 | ||||
-rw-r--r-- | guix/scripts/home.scm | 3 | ||||
-rw-r--r-- | guix/scripts/package.scm | 3 | ||||
-rw-r--r-- | guix/scripts/system/reconfigure.scm | 4 | ||||
-rw-r--r-- | guix/utils.scm | 8 |
6 files changed, 17 insertions, 12 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 diff --git a/guix/profiles.scm b/guix/profiles.scm index bf50c00a1e..d3ff8379ad 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org> ;;; Copyright © 2014 David Thompson <davet@gnu.org> +;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,7 +33,7 @@ #:use-module ((guix config) #:select (%state-directory)) #:use-module ((guix utils) #:hide (package-name->name+version)) #:use-module ((guix build utils) - #:select (package-name->name+version mkdir-p)) + #:select (package-name->name+version mkdir-p switch-symlinks)) #:use-module ((guix diagnostics) #:select (&fix-hint formatted-message)) #:use-module (guix i18n) #:use-module (guix records) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 0f5c3388a1..8ba7693a83 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2021 Pierre Langlois <pierre.langlois@gmx.com> ;;; Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> ;;; Copyright © 2022 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -63,7 +64,7 @@ #:autoload (guix scripts home edit) (guix-home-edit) #:autoload (guix scripts home import) (import-manifest) #:use-module ((guix status) #:select (with-status-verbosity)) - #:use-module ((guix build utils) #:select (mkdir-p)) + #:use-module ((guix build utils) #:select (mkdir-p switch-symlinks)) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (srfi srfi-1) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 99a6cfaa29..14a8e1f5e8 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2018 Steve Sprang <scs@stevesprang.com> ;;; Copyright © 2022 Josselin Poiret <dev@jpoiret.xyz> +;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -49,7 +50,7 @@ #:autoload (guix channels) (channel-name channel-commit channel->code) #:autoload (guix store roots) (gc-roots user-owned?) #:use-module ((guix build utils) - #:select (directory-exists? mkdir-p)) + #:select (directory-exists? mkdir-p switch-symlinks)) #:use-module (ice-9 format) #:use-module (ice-9 match) #:autoload (ice-9 pretty-print) (pretty-print) diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm index 9ca66687ee..a173e011b4 100644 --- a/guix/scripts/system/reconfigure.scm +++ b/guix/scripts/system/reconfigure.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2019 Christopher Baines <mail@cbaines.net> ;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.org> +;;; Copyright © 2022 Arun Isaac <arunisaac@systemreboot.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -94,7 +95,8 @@ atomically, and run OS's activation script." #:select? not-config?) ((guix config) => ,(make-config.scm))) #~(begin - (use-modules (guix config) + (use-modules (guix build utils) + (guix config) (guix profiles) (guix utils)) diff --git a/guix/utils.scm b/guix/utils.scm index 5c36b15cfe..e7a576091e 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -121,7 +121,6 @@ file-sans-extension tarball-sans-extension compressed-file? - switch-symlinks call-with-temporary-directory with-atomic-file-output @@ -895,13 +894,6 @@ VERSIONS. For example: (->bool (member (file-extension file) '("gz" "bz2" "xz" "lz" "lzma" "tgz" "tbz2" "zip")))) -(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) |