diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-07-27 11:03:14 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-07-27 12:06:35 +0200 |
| commit | a396dd01bc6e90ae512001350d1afa471e01661d (patch) | |
| tree | 40aecd0a2915f01736e4ee94a7b965e801b292f9 /gnu/services.scm | |
| parent | 9296a2e511311d23dc49c4e4b3cbb9341ea82bb3 (diff) | |
machine: ssh: Check for potential system downgrades.
This is a followup to 8e31736b0a60919cc1bfc5dc22c395b09243484a.
* guix/scripts/system/reconfigure.scm (check-forward-update): Add
#:current-channels. Use it instead of OLD.
* gnu/services.scm (sexp->system-provenance): New procedure.
(system-provenance): Use it.
* gnu/machine/ssh.scm (<machine-ssh-configuration>)[allow-downgrades?]:
New field.
(machine-check-forward-update): New procedure.
(check-deployment-sanity)[assertions]: Call it.
* doc/guix.texi (Invoking guix deploy): Document 'allow-downgrades?'
field.
Diffstat (limited to 'gnu/services.scm')
| -rw-r--r-- | gnu/services.scm | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/gnu/services.scm b/gnu/services.scm index 399a432e3f9..11ba21e8245 100644 --- a/gnu/services.scm +++ b/gnu/services.scm | |||
| @@ -89,6 +89,7 @@ | |||
| 89 | 89 | ||
| 90 | system-service-type | 90 | system-service-type |
| 91 | provenance-service-type | 91 | provenance-service-type |
| 92 | sexp->system-provenance | ||
| 92 | system-provenance | 93 | system-provenance |
| 93 | boot-service-type | 94 | boot-service-type |
| 94 | cleanup-service-type | 95 | cleanup-service-type |
| @@ -488,6 +489,19 @@ channels in use and CONFIG-FILE, if it is true." | |||
| 488 | itself: the channels used when building the system, and its configuration | 489 | itself: the channels used when building the system, and its configuration |
| 489 | file, when available."))) | 490 | file, when available."))) |
| 490 | 491 | ||
| 492 | (define (sexp->system-provenance sexp) | ||
| 493 | "Parse SEXP, an s-expression read from /run/current-system/provenance or | ||
| 494 | similar, and return two values: the list of channels listed therein, and the | ||
| 495 | OS configuration file or #f." | ||
| 496 | (match sexp | ||
| 497 | (('provenance ('version 0) | ||
| 498 | ('channels channels ...) | ||
| 499 | ('configuration-file config-file)) | ||
| 500 | (values (map sexp->channel channels) | ||
| 501 | config-file)) | ||
| 502 | (_ | ||
| 503 | (values '() #f)))) | ||
| 504 | |||
| 491 | (define (system-provenance system) | 505 | (define (system-provenance system) |
| 492 | "Given SYSTEM, the file name of a system generation, return two values: the | 506 | "Given SYSTEM, the file name of a system generation, return two values: the |
| 493 | list of channels SYSTEM is built from, and its configuration file. If that | 507 | list of channels SYSTEM is built from, and its configuration file. If that |
| @@ -495,15 +509,9 @@ information is missing, return the empty list (for channels) and possibly | |||
| 495 | #false (for the configuration file)." | 509 | #false (for the configuration file)." |
| 496 | (catch 'system-error | 510 | (catch 'system-error |
| 497 | (lambda () | 511 | (lambda () |
| 498 | (match (call-with-input-file (string-append system "/provenance") | 512 | (sexp->system-provenance |
| 499 | read) | 513 | (call-with-input-file (string-append system "/provenance") |
| 500 | (('provenance ('version 0) | 514 | read))) |
| 501 | ('channels channels ...) | ||
| 502 | ('configuration-file config-file)) | ||
| 503 | (values (map sexp->channel channels) | ||
| 504 | config-file)) | ||
| 505 | (_ | ||
| 506 | (values '() #f)))) | ||
| 507 | (lambda _ | 515 | (lambda _ |
| 508 | (values '() #f)))) | 516 | (values '() #f)))) |
| 509 | 517 | ||
