unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils)
@ 2022-06-13 12:13 Arun Isaac
  2022-06-13 12:15 ` [bug#55941] [PATCH core-updates 1/3] utils: " Arun Isaac
  2022-06-23 20:46 ` [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to " Ludovic Courtès
  0 siblings, 2 replies; 6+ messages in thread
From: Arun Isaac @ 2022-06-13 12:13 UTC (permalink / raw)
  To: 55941, maximedevos; +Cc: Arun Isaac

Hi,

As discussed on guix-devel, here are the patches moving switch-symlinks to
(guix build utils). I ran `make check'. I don't think this patchset introduces
any new failures, that is, other than those that are already failing on
core-updates.

Regards,
Arun

Arun Isaac (3):
  utils: Move switch-symlinks to (guix build utils).
  utils: Make switch-symlinks robust against interruption.
  services: pcscd: Use switch-symlinks from (guix build utils).

 gnu/services/security-token.scm     |  9 ++-------
 guix/build/utils.scm                | 24 ++++++++++++++++++++++--
 guix/profiles.scm                   |  3 ++-
 guix/scripts/home.scm               |  3 ++-
 guix/scripts/package.scm            |  3 ++-
 guix/scripts/system/reconfigure.scm |  4 +++-
 guix/utils.scm                      |  8 --------
 7 files changed, 33 insertions(+), 21 deletions(-)


base-commit: 0d09e2e29d1ef0afabebd843f51d41d6cfe340ee
-- 
2.36.1





^ permalink raw reply	[flat|nested] 6+ messages in thread

* [bug#55941] [PATCH core-updates 1/3] utils: Move switch-symlinks to (guix build utils).
  2022-06-13 12:13 [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils) Arun Isaac
@ 2022-06-13 12:15 ` Arun Isaac
  2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 2/3] utils: Make switch-symlinks robust against interruption Arun Isaac
  2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 3/3] services: pcscd: Use switch-symlinks from (guix build utils) Arun Isaac
  2022-06-23 20:46 ` [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to " Ludovic Courtès
  1 sibling, 2 replies; 6+ messages in thread
From: Arun Isaac @ 2022-06-13 12:15 UTC (permalink / raw)
  To: 55941, Maxime Devos; +Cc: Arun Isaac

* 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.
---
 guix/build/utils.scm                | 8 ++++++++
 guix/profiles.scm                   | 3 ++-
 guix/scripts/home.scm               | 3 ++-
 guix/scripts/package.scm            | 3 ++-
 guix/scripts/system/reconfigure.scm | 4 +++-
 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 @@ (define-module (guix build utils)
             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 @@ (define (symbolic-link? file)
   "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 @@ (define-module (guix profiles)
   #: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 @@ (define-module (guix scripts home)
   #: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 @@ (define-module (guix scripts package)
   #: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 @@ (define* (switch-system-program os #:optional profile)
                                  #: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 37b2e29800..ed791cce1c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -120,7 +120,6 @@ (define-module (guix utils)
             file-sans-extension
             tarball-sans-extension
             compressed-file?
-            switch-symlinks
             call-with-temporary-directory
             with-atomic-file-output
 
@@ -892,13 +891,6 @@ (define (compressed-file? file)
   (->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)

base-commit: 0d09e2e29d1ef0afabebd843f51d41d6cfe340ee
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#55941] [PATCH core-updates 2/3] utils: Make switch-symlinks robust against interruption.
  2022-06-13 12:15 ` [bug#55941] [PATCH core-updates 1/3] utils: " Arun Isaac
@ 2022-06-13 12:15   ` Arun Isaac
  2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 3/3] services: pcscd: Use switch-symlinks from (guix build utils) Arun Isaac
  1 sibling, 0 replies; 6+ messages in thread
From: Arun Isaac @ 2022-06-13 12:15 UTC (permalink / raw)
  To: 55941, Maxime Devos; +Cc: Arun Isaac

* guix/build/utils.scm (switch-symlinks): Delete pivot link if it already
exists.

Co-authored-by: Maxime Devos <maximedevos@telenet.be>
---
 guix/build/utils.scm | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index ce7bdb2024..5ea3b98353 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -3,11 +3,11 @@
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2015, 2018, 2021 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2018, 2022 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
-;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
 ;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -245,7 +245,19 @@ (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)
+    ;; Create pivot link, deleting it if it already exists. This can
+    ;; happen if a previous switch-symlinks was interrupted.
+    (let symlink/remove-old ()
+      (catch 'system-error
+        (lambda ()
+          (symlink target pivot))
+        (lambda args
+          (if (= (system-error-errno args) EEXIST)
+              (begin
+                ;; Remove old link and retry.
+                (delete-file pivot)
+                (symlink/remove-old))
+              (apply throw args)))))
     (rename-file pivot link)))
 
 (define (call-with-temporary-output-file proc)
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#55941] [PATCH core-updates 3/3] services: pcscd: Use switch-symlinks from (guix build utils).
  2022-06-13 12:15 ` [bug#55941] [PATCH core-updates 1/3] utils: " Arun Isaac
  2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 2/3] utils: Make switch-symlinks robust against interruption Arun Isaac
@ 2022-06-13 12:15   ` Arun Isaac
  1 sibling, 0 replies; 6+ messages in thread
From: Arun Isaac @ 2022-06-13 12:15 UTC (permalink / raw)
  To: 55941, Maxime Devos; +Cc: Arun Isaac

switch-symlinks has been moved to (guix build utils). We need not duplicate it
anymore.

* gnu/services/security-token.scm (pcscd-activation): Use switch-symlinks
from (guix build utils).
---
 gnu/services/security-token.scm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gnu/services/security-token.scm b/gnu/services/security-token.scm
index 52afad84a6..2356273398 100644
--- a/gnu/services/security-token.scm
+++ b/gnu/services/security-token.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2018, 2022 Arun Isaac <arunisaac@systemreboot.net>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;;
@@ -74,12 +74,7 @@ (define pcscd-activation
                              '((guix build utils)))
        #~(begin
            (use-modules (guix build utils))
-           ;; XXX: We can't use (guix utils) because it requires a
-           ;; dynamically-linked Guile, hence the duplicate switch-symlinks.
-           (define (switch-symlinks link target)
-             (let ((pivot (string-append link ".new")))
-               (symlink target pivot)
-               (rename-file pivot link)))
+
            (mkdir-p "/var/lib")
            (switch-symlinks "/var/lib/pcsc"
                             #$(directory-union
-- 
2.36.1





^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils)
  2022-06-13 12:13 [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils) Arun Isaac
  2022-06-13 12:15 ` [bug#55941] [PATCH core-updates 1/3] utils: " Arun Isaac
@ 2022-06-23 20:46 ` Ludovic Courtès
  2022-06-24 20:30   ` bug#55941: " Arun Isaac
  1 sibling, 1 reply; 6+ messages in thread
From: Ludovic Courtès @ 2022-06-23 20:46 UTC (permalink / raw)
  To: Arun Isaac; +Cc: maximedevos, 55941

Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> skribis:

>   utils: Move switch-symlinks to (guix build utils).
>   utils: Make switch-symlinks robust against interruption.
>   services: pcscd: Use switch-symlinks from (guix build utils).

LGTM, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#55941: [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils)
  2022-06-23 20:46 ` [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to " Ludovic Courtès
@ 2022-06-24 20:30   ` Arun Isaac
  0 siblings, 0 replies; 6+ messages in thread
From: Arun Isaac @ 2022-06-24 20:30 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: maximedevos, 55941-done


Thanks, pushed to core-updates!




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-24 20:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 12:13 [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to (guix build utils) Arun Isaac
2022-06-13 12:15 ` [bug#55941] [PATCH core-updates 1/3] utils: " Arun Isaac
2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 2/3] utils: Make switch-symlinks robust against interruption Arun Isaac
2022-06-13 12:15   ` [bug#55941] [PATCH core-updates 3/3] services: pcscd: Use switch-symlinks from (guix build utils) Arun Isaac
2022-06-23 20:46 ` [bug#55941] [PATCH core-updates 0/3] Move switch-symlinks to " Ludovic Courtès
2022-06-24 20:30   ` bug#55941: " Arun Isaac

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).