Patchwork Odd behavior with --dry-run and --upgrade

login
register
mail settings
Submitter Ludovic Courtès
Date July 28, 2016, 1:01 p.m.
Message ID <87bn1hj4qs.fsf@gnu.org>
Download mbox | patch
Permalink /patch/14108/
State New
Headers show

Comments

Ludovic Courtès - July 28, 2016, 1:01 p.m.
Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-07-28 01:19 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:

[...]

>>> From d7747453bf31a616d414dce293fc0556d601abcb Mon Sep 17 00:00:00 2001
>>> From: Alex Kost <alezost@gmail.com>
>>> Date: Wed, 27 Jul 2016 14:55:50 +0300
>>> Subject: [PATCH] emacs: Disable grafts when dry-run is enabled.
>>>
>>> * emacs/guix-main.scm (process-package-actions): Set grafting according
>>> to 'dry-run?'.
>>> * guix/scripts.scm (build-package): Likewise.
>>
>> [...]
>>
>>>  (define-module (guix scripts)
>>> +  #:use-module (guix grafts)
>>>    #:use-module (guix utils)
>>>    #:use-module (guix ui)
>>>    #:use-module (guix store)
>>> @@ -106,6 +107,7 @@ true."
>>>    "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
>>>  Show what and how will/would be built."
>>>    (mbegin %store-monad
>>> +    (set-grafting (not dry-run?))
>>>      (apply set-build-options*
>>>             #:use-substitutes? use-substitutes?
>>>             (strip-keyword-arguments '(#:dry-run?) build-options))
>>
>> Here it might be best to do something like this:
>>
>>   (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
>>     (set-grafting (and (not dry-run?) grafting?))
>>     …)
>>
>> This would make sure we don’t enable grafting if it turned out to be
>> disabled.
>>
>> WDYT?
>
> OK, you know better :-)
>
> However, I tried it and it doesn't work for me (note: I know nothing
> about monads, gexps, etc.).  When I try this:
>
>    (mbegin %store-monad
>      (set-grafting #f)
>      …)
>
> the grafting doesn't happen, but when I try this:
>
>    (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
>      (set-grafting #f)
>      …)
>
> grafting happens anyway.  I have no idea what the problem is.

Hmm.  Not sure why.  What about this:
Using #:graft? is cleaner anyway.

Ludo’.
Alex Kost - July 30, 2016, 3:25 p.m.
Ludovic Courtès (2016-07-28 16:01 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> However, I tried it and it doesn't work for me (note: I know nothing
>> about monads, gexps, etc.).  When I try this:
>>
>>    (mbegin %store-monad
>>      (set-grafting #f)
>>      …)
>>
>> the grafting doesn't happen, but when I try this:
>>
>>    (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
>>      (set-grafting #f)
>>      …)
>>
>> grafting happens anyway.  I have no idea what the problem is.
>
> Hmm.  Not sure why.  What about this:

This approach works, thanks!

> --- a/guix/scripts.scm
> +++ b/guix/scripts.scm
> @@ -22,6 +22,7 @@
>    #:use-module (guix utils)
>    #:use-module (guix ui)
>    #:use-module (guix store)
> +  #:use-module (guix grafts)
>    #:use-module (guix monads)
>    #:use-module (guix packages)
>    #:use-module (guix derivations)
> @@ -105,11 +106,14 @@ true."
>                          #:rest build-options)
>    "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
>  Show what and how will/would be built."
> -  (mbegin %store-monad
> +  (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
>      (apply set-build-options*
>             #:use-substitutes? use-substitutes?
>             (strip-keyword-arguments '(#:dry-run?) build-options))
> -    (mlet %store-monad ((derivation (package->derivation package)))
> +    (mlet %store-monad ((derivation (package->derivation package
> +                                                         #:graft?
> +                                                         (and (not dry-run?)
> +                                                              grafting?))))
>        (mbegin %store-monad
>          (maybe-build (list derivation)
>                       #:use-substitutes? use-substitutes?
>
> Using #:graft? is cleaner anyway.

Indeed!  Since you said it's OK to make separate patches for this
"dry-run + no-grafts" change (for CLI and Emacs UI), I committed it as
a82a201.
Ludovic Courtès - July 30, 2016, 10:51 p.m.
Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2016-07-28 16:01 +0300) wrote:

[...]

>> --- a/guix/scripts.scm
>> +++ b/guix/scripts.scm
>> @@ -22,6 +22,7 @@
>>    #:use-module (guix utils)
>>    #:use-module (guix ui)
>>    #:use-module (guix store)
>> +  #:use-module (guix grafts)
>>    #:use-module (guix monads)
>>    #:use-module (guix packages)
>>    #:use-module (guix derivations)
>> @@ -105,11 +106,14 @@ true."
>>                          #:rest build-options)
>>    "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
>>  Show what and how will/would be built."
>> -  (mbegin %store-monad
>> +  (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
>>      (apply set-build-options*
>>             #:use-substitutes? use-substitutes?
>>             (strip-keyword-arguments '(#:dry-run?) build-options))
>> -    (mlet %store-monad ((derivation (package->derivation package)))
>> +    (mlet %store-monad ((derivation (package->derivation package
>> +                                                         #:graft?
>> +                                                         (and (not dry-run?)
>> +                                                              grafting?))))
>>        (mbegin %store-monad
>>          (maybe-build (list derivation)
>>                       #:use-substitutes? use-substitutes?
>>
>> Using #:graft? is cleaner anyway.
>
> Indeed!  Since you said it's OK to make separate patches for this
> "dry-run + no-grafts" change (for CLI and Emacs UI), I committed it as
> a82a201.

Perfect, thanks!

Ludo’.

Patch

--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -22,6 +22,7 @@ 
   #:use-module (guix utils)
   #:use-module (guix ui)
   #:use-module (guix store)
+  #:use-module (guix grafts)
   #:use-module (guix monads)
   #:use-module (guix packages)
   #:use-module (guix derivations)
@@ -105,11 +106,14 @@  true."
                         #:rest build-options)
   "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
 Show what and how will/would be built."
-  (mbegin %store-monad
+  (mlet %store-monad ((grafting? ((lift0 %graft? %store-monad))))
     (apply set-build-options*
            #:use-substitutes? use-substitutes?
            (strip-keyword-arguments '(#:dry-run?) build-options))
-    (mlet %store-monad ((derivation (package->derivation package)))
+    (mlet %store-monad ((derivation (package->derivation package
+                                                         #:graft?
+                                                         (and (not dry-run?)
+                                                              grafting?))))
       (mbegin %store-monad
         (maybe-build (list derivation)
                      #:use-substitutes? use-substitutes?