diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-03-04 23:16:17 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-03-04 23:16:17 +0100 |
commit | ebb7cf9e21060105d9950dd5142c0eb918083666 (patch) | |
tree | 36c1607b80d92e27fb9d09029d1d3b57a1fd5065 /gnu/installer | |
parent | 0b870f7915f5da43758753fd088a22033936dc50 (diff) | |
parent | c2d7e800e6788277bc56f31d5836f9d507dc1506 (diff) | |
download | guix-patches-ebb7cf9e21060105d9950dd5142c0eb918083666.tar guix-patches-ebb7cf9e21060105d9950dd5142c0eb918083666.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'gnu/installer')
-rw-r--r-- | gnu/installer/parted.scm | 7 | ||||
-rw-r--r-- | gnu/installer/steps.scm | 1 | ||||
-rw-r--r-- | gnu/installer/utils.scm | 47 |
3 files changed, 52 insertions, 3 deletions
diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index c2b02c9281..6c805cc053 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com> -;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr> ;;; ;;; This file is part of GNU Guix. @@ -1070,6 +1070,8 @@ USER-PARTITION if it is encrypted, or the plain file-name otherwise." (call-with-luks-key-file password (lambda (key-file) + (syslog "formatting and opening LUKS entry ~s at ~s~%" + label file-name) (system* "cryptsetup" "-q" "luksFormat" file-name key-file) (system* "cryptsetup" "open" "--type" "luks" "--key-file" key-file file-name label))))) @@ -1077,6 +1079,7 @@ USER-PARTITION if it is encrypted, or the plain file-name otherwise." (define (luks-close user-partition) "Close the encrypted partition pointed by USER-PARTITION." (let ((label (user-partition-crypt-label user-partition))) + (syslog "closing LUKS entry ~s~%" label) (system* "cryptsetup" "close" label))) (define (format-user-partitions user-partitions) @@ -1150,6 +1153,7 @@ respective mount-points." (file-name (user-partition-upper-file-name user-partition))) (mkdir-p target) + (syslog "mounting ~s on ~s~%" file-name target) (mount file-name target mount-type))) sorted-partitions))) @@ -1165,6 +1169,7 @@ respective mount-points." (target (string-append (%installer-target-dir) mount-point))) + (syslog "unmounting ~s~%" target) (umount target) (when crypt-label (luks-close user-partition)))) diff --git a/gnu/installer/steps.scm b/gnu/installer/steps.scm index 4e90f32f95..b2fc819d89 100644 --- a/gnu/installer/steps.scm +++ b/gnu/installer/steps.scm @@ -177,6 +177,7 @@ return the accumalated result so far." #:done-steps '()))))) ((installer-step-break? c) (reverse result))) + (syslog "running step '~a'~%" (installer-step-id step)) (let* ((id (installer-step-id step)) (compute (installer-step-compute step)) (res (compute result done-steps))) diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index ddb96bc338..842bd02ced 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe <m.othacehe@gmail.com> -;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -24,12 +24,16 @@ #:use-module (srfi srfi-34) #:use-module (ice-9 rdelim) #:use-module (ice-9 regex) + #:use-module (ice-9 format) #:use-module (ice-9 textual-ports) #:export (read-lines read-all nearest-exact-integer read-percentage - run-shell-command)) + run-shell-command + + syslog-port + syslog)) (define* (read-lines #:optional (port (current-input-port))) "Read lines from PORT and return them as a list." @@ -85,9 +89,48 @@ COMMAND exited successfully, #f otherwise." (format (current-error-port) (G_ "Command failed with exit code ~a.~%") (invoke-error-exit-status c)) + (syslog "command ~s failed with exit code ~a" + command (invoke-error-exit-status c)) (pause) #f)) + (syslog "running command ~s~%" command) (invoke "bash" "--init-file" file) + (syslog "command ~s succeeded~%" command) (newline) (pause) #t)))) + + +;;; +;;; Logging. +;;; + +(define (open-syslog-port) + "Return an open port (a socket) to /dev/log or #f if that wasn't possible." + (let ((sock (socket AF_UNIX SOCK_DGRAM 0))) + (catch 'system-error + (lambda () + (connect sock AF_UNIX "/dev/log") + (setvbuf sock 'line) + sock) + (lambda args + (close-port sock) + #f)))) + +(define syslog-port + (let ((port #f)) + (lambda () + "Return an output port to syslog." + (unless port + (set! port (open-syslog-port))) + (or port (%make-void-port "w"))))) + +(define-syntax syslog + (lambda (s) + "Like 'format', but write to syslog." + (syntax-case s () + ((_ fmt args ...) + (string? (syntax->datum #'fmt)) + (with-syntax ((fmt (string-append "installer[~d]: " + (syntax->datum #'fmt)))) + #'(format (syslog-port) fmt (getpid) args ...)))))) |