[PATCH 0/2] Activate system when switching generations.

DoneSubmitted by Brice Waegeneire.
Details
2 participants
  • Brice Waegeneire
  • Ludovic Courtès
Owner
unassigned
Severity
normal
B
B
Brice Waegeneire wrote on 16 Feb 13:35 +0100
(address . guix-patches@gnu.org)
87czx06ubt.fsf@waegenei.re
Hello,
As reported on previous bug report, rolling-back or switching generationdoesn't activate the system as a system reconfiguration would do. This isespecially problematic when modifying in /run/setuid-programs, as it can't bereverted easily. Also it hinder modification in the activation script sinceit's not straight forward to revert change made by those script without afunctional roll-back mechanism.
I'm not sure it's the right approach but at least it work: it add theactivate.scm script to the system profile and then load it whenswitching-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
B
B
Brice Waegeneire wrote on 16 Feb 14:22 +0100
[PATCH 1/2] gnu: services: Add activate script to the profile system directory.
(address . 46560@debbugs.gnu.org)
20210216132235.15811-1-brice@waegenei.re
* gnu/services.scm (activation-profile-entry): New procedure...(activation-service-type): ... use it.--- gnu/services.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Toggle diff (29 lines)diff --git a/gnu/services.scm b/gnu/services.scmindex 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
B
B
Brice Waegeneire wrote on 16 Feb 14:22 +0100
[PATCH 2/2] scripts: system: Activate system when switching generations.
(address . 46560@debbugs.gnu.org)
20210216132235.15811-2-brice@waegenei.re
Fixes #38884.
* guix/scripts/system.scm (switch-to-system-generation): Load theactivate script for that generation.--- guix/scripts/system.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Toggle diff (31 lines)diff --git a/guix/scripts/system.scm b/guix/scripts/system.scmindex 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
L
L
Ludovic Courtès wrote on 1 Mar 16:55 +0100
Re: bug#46560: [PATCH 0/2] Activate system when switching generations.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 46560@debbugs.gnu.org)
87mtvmrhqm.fsf_-_@gnu.org
Hi,
Brice Waegeneire <brice@waegenei.re> skribis:
Toggle quote (3 lines)> * gnu/services.scm (activation-profile-entry): New procedure...> (activation-service-type): ... use it.
[...]
Toggle quote (17 lines)> +(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!
L
L
Ludovic Courtès wrote on 1 Mar 16:56 +0100
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 46560@debbugs.gnu.org)
87im6arhoj.fsf_-_@gnu.org
Brice Waegeneire <brice@waegenei.re> skribis:
Toggle quote (2 lines)> Fixes #38884.
Nitpick: “Fixes https://bugs.gnu.org/38884.”
Toggle quote (3 lines)> * guix/scripts/system.scm (switch-to-system-generation): Load the> activate script for that generation.
[...]
Toggle quote (3 lines)> + (switch-to-generation* %system-profile number)> + (primitive-load activate))
I suppose you need to wrap catch 'system-error here and to keep goingupon ENOENT.
Could you send an updated patch?
Thanks!
Ludo’.
B
B
Brice Waegeneire wrote on 4 Mar 07:57 +0100
[PATCH v2 0/2] Activate system when switching generations.
(address . 46560@debbugs.gnu.org)(address . ludo@gnu.org)
20210304065754.18619-1-brice@waegenei.re
Hello Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
Toggle quote (17 lines)> 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
B
B
Brice Waegeneire wrote on 4 Mar 07:57 +0100
[PATCH v2 1/2] gnu: services: Add activate script to the profile system directory.
(address . 46560@debbugs.gnu.org)(address . ludo@gnu.org)
20210304065754.18619-2-brice@waegenei.re
* gnu/services.scm (activation-profile-entry): New procedure...(activation-service-type): ... use it.--- gnu/services.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Toggle diff (29 lines)diff --git a/gnu/services.scm b/gnu/services.scmindex 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
B
B
Brice Waegeneire wrote on 4 Mar 07:57 +0100
[PATCH v2 2/2] scripts: system: Activate system when switching generations.
(address . 46560@debbugs.gnu.org)(address . ludo@gnu.org)
20210304065754.18619-3-brice@waegenei.re
Fixes https://bugs.gnu.org/38884.
* guix/scripts/system.scm (switch-to-system-generation): Load theactivate script for that generation.
squash! scripts: system: Activate system when switching generations.--- guix/scripts/system.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Toggle diff (31 lines)diff --git a/guix/scripts/system.scm b/guix/scripts/system.scmindex 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
L
L
Ludovic Courtès wrote on 8 Mar 15:15 +0100
Re: [PATCH v2 0/2] Activate system when switching generations.
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 46560@debbugs.gnu.org)
87blbtd95l.fsf@gnu.org
Hi Brice,
Brice Waegeneire <brice@waegenei.re> skribis:
Toggle quote (4 lines)> Brice Waegeneire (2):> gnu: services: Add activate script to the profile system directory.> scripts: system: Activate system when switching generations.
LGTM, thanks!
Ludo’.
B
B
Brice Waegeneire wrote on 9 Mar 07:12 +0100
Re: bug#46560: [PATCH 0/2] Activate system when switching generations.
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 46560-done@debbugs.gnu.org)
87k0qgzwh3.fsf_-_@waegenei.re
Hello Ludo,
Ludovic Courtès <ludo@gnu.org> writes:
Toggle quote (8 lines)> 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 newfeature.
Cheers,- Brice.
Closed
?