From 96bb00d20336f43fac2c42662e4b1d300e624738 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 14 Oct 2022 17:28:27 +0200 Subject: installer: Run the "guix system init" command in a PTY. Fixes: * gnu/installer/utils.scm (run-external-command-with-handler/tty): New procedure. (run-external-command-with-line-hooks, run-command): Add a TTY? argument. * gnu/installer/final.scm (install-system): Call run-command with TTY? argument set to #true. --- gnu/installer/final.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/installer/final.scm') diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index 3f6dacc490..044f79372b 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -211,7 +211,7 @@ or #f. Return #t on success and #f on failure." (setenv "PATH" "/run/current-system/profile/bin/") - (set! ret (run-command install-command))) + (set! ret (run-command install-command #:tty? #t))) (lambda () ;; Restart guix-daemon so that it does no keep the MNT namespace ;; alive. -- cgit v1.2.3 From 9b6703eabee07068328a5e489deb3d532f242daa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 17 Dec 2022 23:36:02 +0100 Subject: installer: final: Stop guix-daemon before accessing store database. As part of fixing , make sure /var/guix/db.sqlite is only copied while guix-daemon is stopped. * gnu/installer/final.scm (call-with-mnt-container): Add FIXME comment. (install-system): Copy DATABASE-FILE and SAVED-DATABASE only when 'guix-daemon' is stopped. Add logging lines. --- gnu/installer/final.scm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'gnu/installer/final.scm') diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index 044f79372b..f5601d8649 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2020 Mathieu Othacehe -;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2019, 2020, 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -114,6 +114,8 @@ it can interact with the rest of the system." ;; Catch SIGINT and kill the container process. (sigaction SIGINT (lambda (signum) + ;: FIXME: Use of SIGKILL prevents the dynamic-wind exit handler of + ;; THUNK to run. (false-if-exception (kill pid SIGKILL)))) @@ -196,14 +198,16 @@ or #f. Return #t on success and #f on failure." ;; the loaded cow-store locale files will prevent umounting. (install-locale locale) - ;; Save the database, so that it can be restored once the - ;; cow-store is umounted. + ;; Stop the daemon and save the database, so that it can be + ;; restored once the cow-store is umounted. + (stop-service 'guix-daemon) (copy-file database-file saved-database) + + (installer-log-line "mounting copy-on-write store") (mount-cow-store (%installer-target-dir) backing-directory)) (lambda () ;; We need to drag the guix-daemon to the container MNT ;; namespace, so that it can operate on the cow-store. - (stop-service 'guix-daemon) (start-service 'guix-daemon (list (number->string (getpid)))) (setvbuf (current-output-port) 'none) @@ -213,11 +217,17 @@ or #f. Return #t on success and #f on failure." (set! ret (run-command install-command #:tty? #t))) (lambda () - ;; Restart guix-daemon so that it does no keep the MNT namespace + ;; Stop guix-daemon so that it does no keep the MNT namespace ;; alive. - (restart-service 'guix-daemon) + (stop-service 'guix-daemon) + + ;; Restore the database and restart it. + (installer-log-line "restoring store database from '~a'" + saved-database) (copy-file saved-database database-file) + (start-service 'guix-daemon) ;; Finally umount the cow-store and exit the container. + (installer-log-line "unmounting copy-on-write store") (unmount-cow-store (%installer-target-dir) backing-directory) (assert-exit ret)))))))) -- cgit v1.2.3 From 495c50008be91429ebea3805e161a1e385a2a572 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 18 Dec 2022 00:35:21 +0100 Subject: installer: final: Delete SQLite WAL and shm files upon completion. Previously, db.sqlite-{wal,shm} could be left behind after stopping guix-daemon. When resuming installation, SQLite could end up behaving as if transactions visible in the WAL file had been committed, in spite of having restored SAVED-DATABASE. Fixes . Reported by pelzflorian (Florian Pelz) . * gnu/installer/final.scm (install-system): Before restarting guix-daemon, delete db.sqlite-{wal,shm}. --- gnu/installer/final.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gnu/installer/final.scm') diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index f5601d8649..069426a3b8 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm @@ -221,10 +221,18 @@ or #f. Return #t on success and #f on failure." ;; alive. (stop-service 'guix-daemon) - ;; Restore the database and restart it. + ;; Restore the database and restart it. As part of restoring the + ;; database, remove the WAL and shm files in case they were left + ;; behind after guix-daemon was stopped. Failing to do so, + ;; sqlite might behave as if transactions that appear in the WAL + ;; file were committed. (See .) (installer-log-line "restoring store database from '~a'" saved-database) (copy-file saved-database database-file) + (for-each (lambda (suffix) + (false-if-exception + (delete-file (string-append database-file suffix)))) + '("-wal" "-shm")) (start-service 'guix-daemon) ;; Finally umount the cow-store and exit the container. -- cgit v1.2.3