>From 3fdef27c8f11b6a0f013afa9b6e619659ce78dec Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Mon, 26 Nov 2018 22:38:18 +1100 Subject: [PATCH 2/3] system: Add --restart-services flag for reconfigure * guix/scripts/system.scm (upgrade-shepherd-services): Add parameter to automatically restart services marked as needing manual restart. (switch-to-system): Pass through restart-services? flag. (perform-action): Pass through restart-services? flag. (%options): Add --restart-services flag. (%default-options): Add #f as default value for --restart-services flag. (process-action): Pass through restart-services? flag. --- guix/scripts/system.scm | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 6f14b1395..bf632c534 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -333,7 +333,7 @@ unload." (warning (G_ "failed to obtain list of shepherd services~%")) (return #f))))) -(define (upgrade-shepherd-services os) +(define (upgrade-shepherd-services os restart-services?) "Upgrade the Shepherd (PID 1) by unloading obsolete services and loading new services specified in OS and not currently running. @@ -360,6 +360,10 @@ bring the system down." (to-start-names (map shepherd-service-canonical-name (filter shepherd-service-auto-start? new-services))) (to-automatically-restart-names (map shepherd-service-canonical-name to-automatically-restart)) (to-manually-restart-names (map shepherd-service-canonical-name to-manually-restart))) + (when restart-services? + (set! to-automatically-restart-names (append to-automatically-restart-names + to-manually-restart-names)) + (set! to-manually-restart-names '())) (set! to-start-names (remove (lambda (name) (or (member name to-automatically-restart-names) @@ -389,7 +393,7 @@ bring the system down." to-manually-restart-names)) (return #t))))))))) -(define* (switch-to-system os +(define* (switch-to-system os restart-services? #:optional (profile %system-profile)) "Make a new generation of PROFILE pointing to the directory of OS, switch to it atomically, and then run OS's activation script." @@ -417,7 +421,7 @@ it atomically, and then run OS's activation script." (primitive-load (derivation->output-path script)))) ;; Finally, try to update system services. - (upgrade-shepherd-services os)))) + (upgrade-shepherd-services os restart-services?)))) (define-syntax-rule (unless-file-not-found exp) (catch 'system-error @@ -825,7 +829,8 @@ and TARGET arguments." use-substitutes? bootloader-target target image-size file-system-type full-boot? (mappings '()) - (gc-root #f)) + (gc-root #f) + (restart-services? #f)) "Perform ACTION for OS. INSTALL-BOOTLOADER? specifies whether to install bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the target root directory; IMAGE-SIZE is the size of the image to be built, for @@ -907,7 +912,7 @@ static checks." (case action ((reconfigure) (mbegin %store-monad - (switch-to-system os) + (switch-to-system os restart-services?) (mwhen install-bootloader? (install-bootloader bootloader-script #:bootcfg bootcfg @@ -1090,6 +1095,9 @@ Some ACTIONS support additional ARGS.\n")) (option '(#\r "root") #t #f (lambda (opt name arg result) (alist-cons 'gc-root arg result))) + (option '("restart-services") #f #f + (lambda (opt name arg result) + (alist-cons 'restart-services? #t result))) %standard-build-options)) (define %default-options @@ -1104,7 +1112,8 @@ Some ACTIONS support additional ARGS.\n")) (verbosity . 0) (file-system-type . "ext4") (image-size . guess) - (install-bootloader? . #t))) + (install-bootloader? . #t) + (restart-services? . #f))) ;;; @@ -1177,7 +1186,8 @@ resulting from command-line parsing." #:install-bootloader? bootloader? #:target target #:bootloader-target bootloader-target - #:gc-root (assoc-ref opts 'gc-root))))) + #:gc-root (assoc-ref opts 'gc-root) + #:restart-services? (assoc-ref opts 'restart-services?))))) #:system system)) (warn-about-disk-space))) -- 2.19.1