diff options
Diffstat (limited to 'gnu/machine/ssh.scm')
| -rw-r--r-- | gnu/machine/ssh.scm | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index fa942169c4c..93b0a007dab 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm | |||
| @@ -38,6 +38,9 @@ | |||
| 38 | #:use-module (guix store) | 38 | #:use-module (guix store) |
| 39 | #:use-module (guix utils) | 39 | #:use-module (guix utils) |
| 40 | #:use-module ((guix self) #:select (make-config.scm)) | 40 | #:use-module ((guix self) #:select (make-config.scm)) |
| 41 | #:use-module ((guix inferior) | ||
| 42 | #:select (inferior-exception? | ||
| 43 | inferior-exception-arguments)) | ||
| 41 | #:use-module (gcrypt pk-crypto) | 44 | #:use-module (gcrypt pk-crypto) |
| 42 | #:use-module (ice-9 format) | 45 | #:use-module (ice-9 format) |
| 43 | #:use-module (ice-9 match) | 46 | #:use-module (ice-9 match) |
| @@ -443,17 +446,46 @@ have you run 'guix archive --generate-key?'") | |||
| 443 | (mlet %store-monad ((_ (check-deployment-sanity machine)) | 446 | (mlet %store-monad ((_ (check-deployment-sanity machine)) |
| 444 | (boot-parameters (machine-boot-parameters machine))) | 447 | (boot-parameters (machine-boot-parameters machine))) |
| 445 | (let* ((os (machine-operating-system machine)) | 448 | (let* ((os (machine-operating-system machine)) |
| 449 | (host (machine-ssh-configuration-host-name | ||
| 450 | (machine-configuration machine))) | ||
| 446 | (eval (cut machine-remote-eval machine <>)) | 451 | (eval (cut machine-remote-eval machine <>)) |
| 447 | (menu-entries (map boot-parameters->menu-entry boot-parameters)) | 452 | (menu-entries (map boot-parameters->menu-entry boot-parameters)) |
| 448 | (bootloader-configuration (operating-system-bootloader os)) | 453 | (bootloader-configuration (operating-system-bootloader os)) |
| 449 | (bootcfg (operating-system-bootcfg os menu-entries))) | 454 | (bootcfg (operating-system-bootcfg os menu-entries))) |
| 455 | (define-syntax-rule (eval/error-handling condition handler ...) | ||
| 456 | ;; Return a wrapper around EVAL such that HANDLER is evaluated if an | ||
| 457 | ;; exception is raised. | ||
| 458 | (lambda (exp) | ||
| 459 | (lambda (store) | ||
| 460 | (guard (condition ((inferior-exception? condition) | ||
| 461 | (values (begin handler ...) store))) | ||
| 462 | (run-with-store store (eval exp)))))) | ||
| 463 | |||
| 450 | (mbegin %store-monad | 464 | (mbegin %store-monad |
| 451 | (with-roll-back #f | 465 | (with-roll-back #f |
| 452 | (switch-to-system eval os)) | 466 | (switch-to-system (eval/error-handling c |
| 467 | (raise (formatted-message | ||
| 468 | (G_ "\ | ||
| 469 | failed to switch systems while deploying '~a':~%~{~s ~}") | ||
| 470 | host | ||
| 471 | (inferior-exception-arguments c)))) | ||
| 472 | os)) | ||
| 453 | (with-roll-back #t | 473 | (with-roll-back #t |
| 454 | (mbegin %store-monad | 474 | (mbegin %store-monad |
| 455 | (upgrade-shepherd-services eval os) | 475 | (upgrade-shepherd-services (eval/error-handling c |
| 456 | (install-bootloader eval bootloader-configuration bootcfg))))))) | 476 | (warning (G_ "\ |
| 477 | an error occurred while upgrading services on '~a':~%~{~s ~}~%") | ||
| 478 | host | ||
| 479 | (inferior-exception-arguments | ||
| 480 | c))) | ||
| 481 | os) | ||
| 482 | (install-bootloader (eval/error-handling c | ||
| 483 | (raise (formatted-message | ||
| 484 | (G_ "\ | ||
| 485 | failed to install bootloader on '~a':~%~{~s ~}~%") | ||
| 486 | host | ||
| 487 | (inferior-exception-arguments c)))) | ||
| 488 | bootloader-configuration bootcfg))))))) | ||
| 457 | 489 | ||
| 458 | 490 | ||
| 459 | ;;; | 491 | ;;; |
| @@ -540,4 +572,6 @@ for environment of type '~a'") | |||
| 540 | 572 | ||
| 541 | ;; Local Variables: | 573 | ;; Local Variables: |
| 542 | ;; eval: (put 'remote-let 'scheme-indent-function 1) | 574 | ;; eval: (put 'remote-let 'scheme-indent-function 1) |
| 575 | ;; eval: (put 'with-roll-back 'scheme-indent-function 1) | ||
| 576 | ;; eval: (put 'eval/error-handling 'scheme-indent-function 1) | ||
| 543 | ;; End: | 577 | ;; End: |
