scripts: system: Activate system when switching generations.

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.
This commit is contained in:
Brice Waegeneire 2021-01-30 21:46:57 +01:00
parent df138dc208
commit 236a882942
No known key found for this signature in database
GPG key ID: A94903A166A18FAE

View file

@ -8,6 +8,7 @@
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu> ;;; Copyright © 2020 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -363,11 +364,14 @@ (define (switch-to-system-generation store spec)
"Switch the system profile to the generation specified by SPEC, and "Switch the system profile to the generation specified by SPEC, and
re-install bootloader with a configuration file that uses the specified system 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." 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 (if number
(begin (begin
(reinstall-bootloader store number) (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)))) (leave (G_ "cannot switch to system generation '~a'~%") spec))))
(define* (system-bootloader-name #:optional (system %system-profile)) (define* (system-bootloader-name #:optional (system %system-profile))