guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/06: pull: Acquire a lock for the target profile.


From: guix-commits
Subject: 01/06: pull: Acquire a lock for the target profile.
Date: Tue, 19 Nov 2019 04:52:03 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 6fbd8fde2fad113dbfc90c8b1b55f7ead919a90a
Author: Ludovic Courtès <address@hidden>
Date:   Mon Nov 18 22:22:59 2019 +0100

    pull: Acquire a lock for the target profile.
    
    This is a followup to b1fb663404894268b5ee92c040f12c52c0bee425.
    
    * guix/scripts/pull.scm (guix-pull): Wrap 'run-with-store' call in
    'with-file-lock/no-wait'.
---
 .dir-locals.el        |  1 +
 guix/scripts/pull.scm | 19 +++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 22aac2c..e4947f5 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -35,6 +35,7 @@
    (eval . (put 'modify-services 'scheme-indent-function 1))
    (eval . (put 'with-directory-excursion 'scheme-indent-function 1))
    (eval . (put 'with-file-lock 'scheme-indent-function 1))
+   (eval . (put 'with-file-lock/no-wait 'scheme-indent-function 1))
 
    (eval . (put 'package 'scheme-indent-function 0))
    (eval . (put 'origin 'scheme-indent-function 0))
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 0ab688a..ef8d5c8 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -36,6 +36,8 @@
   #:autoload   (guix inferior) (open-inferior)
   #:use-module (guix scripts build)
   #:autoload   (guix build utils) (which)
+  #:use-module ((guix build syscalls)
+                #:select (with-file-lock/no-wait))
   #:use-module (guix git)
   #:use-module (git)
   #:use-module (gnu packages)
@@ -815,11 +817,16 @@ Use '~/.config/guix/channels.scm' instead."))
                                        (if (assoc-ref opts 'bootstrap?)
                                            %bootstrap-guile
                                            (canonical-package guile-2.2)))))
-                        (run-with-store store
-                          (build-and-install instances profile
-                                             #:dry-run?
-                                             (assoc-ref opts 'dry-run?)
-                                             #:use-substitutes?
-                                             (assoc-ref opts 
'substitutes?))))))))))))))
+                        (with-file-lock/no-wait (string-append profile ".lock")
+                          (lambda (key . args)
+                            (leave (G_ "profile ~a is locked by another 
process~%")
+                                   profile))
+
+                          (run-with-store store
+                            (build-and-install instances profile
+                                               #:dry-run?
+                                               (assoc-ref opts 'dry-run?)
+                                               #:use-substitutes?
+                                               (assoc-ref opts 
'substitutes?)))))))))))))))
 
 ;;; pull.scm ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]