unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#46560] [PATCH 0/2] Activate system when switching generations.
@ 2021-02-16 12:35 Brice Waegeneire
  2021-02-16 13:22 ` [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Brice Waegeneire @ 2021-02-16 12:35 UTC (permalink / raw)
  To: 46560

Hello,

As reported on previous bug report, rolling-back or switching generation
doesn't activate the system as a system reconfiguration would do.  This is
especially problematic when modifying in /run/setuid-programs, as it can't be
reverted easily.  Also it hinder modification in the activation script since
it's not straight forward to revert change made by those script without a
functional roll-back mechanism.

I'm not sure it's the right approach but at least it work: it add the
activate.scm script to the system profile and then load it when
switching-generation.

This is related to issues:
- #37596 and #38884 (they are duplicate)
- #36855 a more wider discussion

Cheers,
- Brice

Brice Waegeneire (2):
  gnu: services: Add activate script to the profile system directory.
  scripts: system: Activate system when switching generations.

 gnu/services.scm        | 10 +++++++++-
 guix/scripts/system.scm |  8 ++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

-- 
2.30.1





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

* [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory.
  2021-02-16 12:35 [bug#46560] [PATCH 0/2] Activate system when switching generations Brice Waegeneire
@ 2021-02-16 13:22 ` Brice Waegeneire
  2021-03-01 15:55   ` [bug#46560] [PATCH 0/2] Activate system when switching generations Ludovic Courtès
  2021-02-16 13:22 ` [bug#46560] [PATCH 2/2] scripts: system: " Brice Waegeneire
  2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
  2 siblings, 1 reply; 10+ messages in thread
From: Brice Waegeneire @ 2021-02-16 13:22 UTC (permalink / raw)
  To: 46560

* gnu/services.scm (activation-profile-entry): New procedure...
(activation-service-type): ... use it.
---
 gnu/services.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 13259dfaee..ddd1bac30c 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -617,13 +617,21 @@ ACTIVATION-SCRIPT-TYPE."
   "Return a gexp that runs the activation script containing GEXPS."
   #~(primitive-load #$(activation-script gexps)))
 
+(define (activation-profile-entry gexps)
+  "Return, as a monadic value, an entry for the activation script in the
+system directory."
+  (mlet %store-monad ((activate (lower-object (activation-script gexps))))
+    (return `(("activate" ,activate)))))
+
 (define (second-argument a b) b)
 
 (define activation-service-type
   (service-type (name 'activate)
                 (extensions
                  (list (service-extension boot-service-type
-                                          gexps->activation-gexp)))
+                                          gexps->activation-gexp)
+                       (service-extension system-service-type
+                                          activation-profile-entry)))
                 (compose identity)
                 (extend second-argument)
                 (description
-- 
2.30.1





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

* [bug#46560] [PATCH 2/2] scripts: system: Activate system when switching generations.
  2021-02-16 12:35 [bug#46560] [PATCH 0/2] Activate system when switching generations Brice Waegeneire
  2021-02-16 13:22 ` [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
@ 2021-02-16 13:22 ` Brice Waegeneire
  2021-03-01 15:56   ` [bug#46560] [PATCH 0/2] " Ludovic Courtès
  2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
  2 siblings, 1 reply; 10+ messages in thread
From: Brice Waegeneire @ 2021-02-16 13:22 UTC (permalink / raw)
  To: 46560

Fixes #38884.

* guix/scripts/system.scm (switch-to-system-generation): Load the
activate script for that generation.
---
 guix/scripts/system.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 19b8c5163c..4c7af52ad5 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -363,11 +364,14 @@ connection to the store."
   "Switch the system profile to the generation specified by SPEC, and
 re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
-  (let ((number (relative-generation-spec->number %system-profile spec)))
+  (let* ((number (relative-generation-spec->number %system-profile spec))
+         (generation (generation-file-name %system-profile number))
+         (activate (string-append generation "/activate")))
     (if number
         (begin
           (reinstall-bootloader store number)
-          (switch-to-generation* %system-profile number))
+          (switch-to-generation* %system-profile number)
+          (primitive-load activate))
         (leave (G_ "cannot switch to system generation '~a'~%") spec))))
 
 (define* (system-bootloader-name #:optional (system %system-profile))
-- 
2.30.1





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

* [bug#46560] [PATCH 0/2] Activate system when switching generations.
  2021-02-16 13:22 ` [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
@ 2021-03-01 15:55   ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2021-03-01 15:55 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 46560

Hi,

Brice Waegeneire <brice@waegenei.re> skribis:

> * gnu/services.scm (activation-profile-entry): New procedure...
> (activation-service-type): ... use it.

[...]

> +(define (activation-profile-entry gexps)
> +  "Return, as a monadic value, an entry for the activation script in the
> +system directory."
> +  (mlet %store-monad ((activate (lower-object (activation-script gexps))))
> +    (return `(("activate" ,activate)))))
> +
>  (define (second-argument a b) b)
>  
>  (define activation-service-type
>    (service-type (name 'activate)
>                  (extensions
>                   (list (service-extension boot-service-type
> -                                          gexps->activation-gexp)))
> +                                          gexps->activation-gexp)
> +                       (service-extension system-service-type
> +                                          activation-profile-entry)))

Good idea, LGTM!




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

* [bug#46560] [PATCH 0/2] Activate system when switching generations.
  2021-02-16 13:22 ` [bug#46560] [PATCH 2/2] scripts: system: " Brice Waegeneire
@ 2021-03-01 15:56   ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2021-03-01 15:56 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 46560

Brice Waegeneire <brice@waegenei.re> skribis:

> Fixes #38884.

Nitpick: “Fixes <https://bugs.gnu.org/38884>.”

> * guix/scripts/system.scm (switch-to-system-generation): Load the
> activate script for that generation.

[...]

> +          (switch-to-generation* %system-profile number)
> +          (primitive-load activate))

I suppose you need to wrap catch 'system-error here and to keep going
upon ENOENT.

Could you send an updated patch?

Thanks!

Ludo’.




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

* [bug#46560] [PATCH v2 0/2] Activate system when switching generations.
  2021-02-16 12:35 [bug#46560] [PATCH 0/2] Activate system when switching generations Brice Waegeneire
  2021-02-16 13:22 ` [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
  2021-02-16 13:22 ` [bug#46560] [PATCH 2/2] scripts: system: " Brice Waegeneire
@ 2021-03-04  6:57 ` Brice Waegeneire
  2021-03-04  6:57   ` [bug#46560] [PATCH v2 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
                     ` (2 more replies)
  2 siblings, 3 replies; 10+ messages in thread
From: Brice Waegeneire @ 2021-03-04  6:57 UTC (permalink / raw)
  To: 46560; +Cc: ludo

Hello Ludovic,

Ludovic Courtès <ludo@gnu.org> writes:

> Brice Waegeneire <brice@waegenei.re> skribis:
>
> > Fixes #38884.
>
> Nitpick: “Fixes <https://bugs.gnu.org/38884>.”
>
> > * guix/scripts/system.scm (switch-to-system-generation): Load the
> > activate script for that generation.
>
> [...]
>
> > +          (switch-to-generation* %system-profile number)
> > +          (primitive-load activate))
>
> I suppose you need to wrap catch 'system-error here and to keep going
> upon ENOENT.

This patch set fixes both issues.

Cheers,
- Brice

Brice Waegeneire (2):
  gnu: services: Add activate script to the profile system directory.
  scripts: system: Activate system when switching generations.

 gnu/services.scm        | 10 +++++++++-
 guix/scripts/system.scm |  8 ++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

-- 
2.30.1





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

* [bug#46560] [PATCH v2 1/2] gnu: services: Add activate script to the profile system directory.
  2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
@ 2021-03-04  6:57   ` Brice Waegeneire
  2021-03-04  6:57   ` [bug#46560] [PATCH v2 2/2] scripts: system: Activate system when switching generations Brice Waegeneire
  2021-03-08 14:15   ` [bug#46560] [PATCH v2 0/2] " Ludovic Courtès
  2 siblings, 0 replies; 10+ messages in thread
From: Brice Waegeneire @ 2021-03-04  6:57 UTC (permalink / raw)
  To: 46560; +Cc: ludo

* gnu/services.scm (activation-profile-entry): New procedure...
(activation-service-type): ... use it.
---
 gnu/services.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gnu/services.scm b/gnu/services.scm
index 13259dfaee..ddd1bac30c 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -617,13 +617,21 @@ ACTIVATION-SCRIPT-TYPE."
   "Return a gexp that runs the activation script containing GEXPS."
   #~(primitive-load #$(activation-script gexps)))
 
+(define (activation-profile-entry gexps)
+  "Return, as a monadic value, an entry for the activation script in the
+system directory."
+  (mlet %store-monad ((activate (lower-object (activation-script gexps))))
+    (return `(("activate" ,activate)))))
+
 (define (second-argument a b) b)
 
 (define activation-service-type
   (service-type (name 'activate)
                 (extensions
                  (list (service-extension boot-service-type
-                                          gexps->activation-gexp)))
+                                          gexps->activation-gexp)
+                       (service-extension system-service-type
+                                          activation-profile-entry)))
                 (compose identity)
                 (extend second-argument)
                 (description
-- 
2.30.1





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

* [bug#46560] [PATCH v2 2/2] scripts: system: Activate system when switching generations.
  2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
  2021-03-04  6:57   ` [bug#46560] [PATCH v2 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
@ 2021-03-04  6:57   ` Brice Waegeneire
  2021-03-08 14:15   ` [bug#46560] [PATCH v2 0/2] " Ludovic Courtès
  2 siblings, 0 replies; 10+ messages in thread
From: Brice Waegeneire @ 2021-03-04  6:57 UTC (permalink / raw)
  To: 46560; +Cc: ludo

Fixes <https://bugs.gnu.org/38884>.

* guix/scripts/system.scm (switch-to-system-generation): Load the
activate script for that generation.

squash! scripts: system: Activate system when switching generations.
---
 guix/scripts/system.scm | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index e3cf99acc6..c226f08371 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -363,11 +364,14 @@ connection to the store."
   "Switch the system profile to the generation specified by SPEC, and
 re-install bootloader with a configuration file that uses the specified system
 generation as its default entry.  STORE is an open connection to the store."
-  (let ((number (relative-generation-spec->number %system-profile spec)))
+  (let* ((number (relative-generation-spec->number %system-profile spec))
+         (generation (generation-file-name %system-profile number))
+         (activate (string-append generation "/activate")))
     (if number
         (begin
           (reinstall-bootloader store number)
-          (switch-to-generation* %system-profile number))
+          (switch-to-generation* %system-profile number)
+          (unless-file-not-found (primitive-load activate)))
         (leave (G_ "cannot switch to system generation '~a'~%") spec))))
 
 (define* (system-bootloader-name #:optional (system %system-profile))
-- 
2.30.1





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

* [bug#46560] [PATCH v2 0/2] Activate system when switching generations.
  2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
  2021-03-04  6:57   ` [bug#46560] [PATCH v2 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
  2021-03-04  6:57   ` [bug#46560] [PATCH v2 2/2] scripts: system: Activate system when switching generations Brice Waegeneire
@ 2021-03-08 14:15   ` Ludovic Courtès
  2021-03-09  6:12     ` bug#46560: [PATCH " Brice Waegeneire
  2 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2021-03-08 14:15 UTC (permalink / raw)
  To: Brice Waegeneire; +Cc: 46560

Hi Brice,

Brice Waegeneire <brice@waegenei.re> skribis:

> Brice Waegeneire (2):
>   gnu: services: Add activate script to the profile system directory.
>   scripts: system: Activate system when switching generations.

LGTM, thanks!

Ludo’.




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

* bug#46560: [PATCH 0/2] Activate system when switching generations.
  2021-03-08 14:15   ` [bug#46560] [PATCH v2 0/2] " Ludovic Courtès
@ 2021-03-09  6:12     ` Brice Waegeneire
  0 siblings, 0 replies; 10+ messages in thread
From: Brice Waegeneire @ 2021-03-09  6:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 46560-done


Hello Ludo,

Ludovic Courtès <ludo@gnu.org> writes:

> Brice Waegeneire <brice@waegenei.re> skribis:
>
>> Brice Waegeneire (2):
>>   gnu: services: Add activate script to the profile system directory.
>>   scripts: system: Activate system when switching generations.
>
> LGTM, thanks!

Pushed as df138dc20858725b90ed77be85f3318cbe1be73a and later. I'll close
#38884 and will do the same or comment #36855 and #37596 about the new
feature.

Cheers,
- Brice.




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

end of thread, other threads:[~2021-03-09  6:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-16 12:35 [bug#46560] [PATCH 0/2] Activate system when switching generations Brice Waegeneire
2021-02-16 13:22 ` [bug#46560] [PATCH 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
2021-03-01 15:55   ` [bug#46560] [PATCH 0/2] Activate system when switching generations Ludovic Courtès
2021-02-16 13:22 ` [bug#46560] [PATCH 2/2] scripts: system: " Brice Waegeneire
2021-03-01 15:56   ` [bug#46560] [PATCH 0/2] " Ludovic Courtès
2021-03-04  6:57 ` [bug#46560] [PATCH v2 " Brice Waegeneire
2021-03-04  6:57   ` [bug#46560] [PATCH v2 1/2] gnu: services: Add activate script to the profile system directory Brice Waegeneire
2021-03-04  6:57   ` [bug#46560] [PATCH v2 2/2] scripts: system: Activate system when switching generations Brice Waegeneire
2021-03-08 14:15   ` [bug#46560] [PATCH v2 0/2] " Ludovic Courtès
2021-03-09  6:12     ` bug#46560: [PATCH " Brice Waegeneire

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).