[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#53063] [PATCH v2 wip-harden-installer 02/18] installer: Generalize
From: |
Josselin Poiret |
Subject: |
[bug#53063] [PATCH v2 wip-harden-installer 02/18] installer: Generalize logging facility. |
Date: |
Sat, 15 Jan 2022 14:49:55 +0100 |
* gnu/installer/utils.scm (%syslog-line-hook, open-new-log-port,
installer-log-port, %installer-log-line-hook, %display-line-hook,
%default-installer-line-hooks, installer-log-line): Add new
variables.
---
gnu/installer/utils.scm | 45 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm
index 9bd41e2ca0..b1b6f8b23f 100644
--- a/gnu/installer/utils.scm
+++ b/gnu/installer/utils.scm
@@ -37,7 +37,12 @@ (define-module (gnu installer utils)
run-command
syslog-port
+ %syslog-line-hook
syslog
+ installer-log-port
+ %installer-log-line-hook
+ %default-installer-line-hooks
+ installer-log-line
call-with-time
let/time
@@ -142,6 +147,9 @@ (define syslog-port
(set! port (open-syslog-port)))
(or port (%make-void-port "w")))))
+(define (%syslog-line-hook line)
+ (format (syslog-port) "installer[~d]: ~a~%" (getpid) line))
+
(define-syntax syslog
(lambda (s)
"Like 'format', but write to syslog."
@@ -152,6 +160,43 @@ (define-syntax syslog
(syntax->datum #'fmt))))
#'(format (syslog-port) fmt (getpid) args ...))))))
+(define (open-new-log-port)
+ (define now (localtime (time-second (current-time))))
+ (define filename
+ (format #f "/tmp/installer.~a.log"
+ (strftime "%F.%T" now)))
+ (open filename (logior O_RDWR
+ O_CREAT)))
+
+(define installer-log-port
+ (let ((port #f))
+ (lambda ()
+ "Return an input and output port to the installer log."
+ (unless port
+ (set! port (open-new-log-port)))
+ port)))
+
+(define (%installer-log-line-hook line)
+ (format (installer-log-port) "~a~%" line))
+
+(define (%display-line-hook line)
+ (display line)
+ (newline))
+
+(define %default-installer-line-hooks
+ (list %syslog-line-hook
+ %installer-log-line-hook))
+
+(define-syntax installer-log-line
+ (lambda (s)
+ "Like 'format', but uses the default line hooks, and only formats one
line."
+ (syntax-case s ()
+ ((_ fmt args ...)
+ (string? (syntax->datum #'fmt))
+ #'(let ((formatted (format #f fmt args ...)))
+ (for-each (lambda (f) (f formatted))
+ %default-installer-line-hooks))))))
+
;;;
;;; Client protocol.
--
2.34.0
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., (continued)
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., Mathieu Othacehe, 2022/01/07
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., Josselin Poiret, 2022/01/07
- [bug#53063] [PATCH v2 wip-harden-installer 00/18] General improvements to the installer, Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 04/18] installer: Un-export syslog syntax., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 03/18] installer: Use new installer-log-line everywhere., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 08/18] installer: Add installer-specific run command process., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 06/18] installer: Remove specific logging code., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 13/18] installer: Add nano to PATH., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 12/18] installer: Replace run-command by invoke in newt/page.scm., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 09/18] installer: Use run-command-in-installer in (gnu installer parted)., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 02/18] installer: Generalize logging facility.,
Josselin Poiret <=
- [bug#53063] [PATCH v2 wip-harden-installer 07/18] installer: Capture external commands output., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 05/18] installer: Keep PATH inside the install container., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 10/18] installer: Raise condition when mklabel fails., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 11/18] installer: Fix run-file-textbox-page when edit-button is #f., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 14/18] installer: Use named prompt to abort or break installer steps., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 15/18] installer: Add error page when running external commands., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 18/18] installer: Make dump archive creation optional and selective., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 01/18] installer: Use define instead of let at top-level., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 16/18] installer: Use dynamic-wind to setup installer., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 17/18] installer: Turn passwords into opaque records., Josselin Poiret, 2022/01/15