diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-12-17 23:36:02 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-12-18 01:17:17 +0100 |
| commit | 9b6703eabee07068328a5e489deb3d532f242daa (patch) | |
| tree | 8a452ea6ad6e13260832f1f180cbdd1a26fff57d | |
| parent | a8f9579348aae58b68b25004cfd28aa7407db802 (diff) | |
installer: final: Stop guix-daemon before accessing store database.
As part of fixing <https://issues.guix.gnu.org/59784>, 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.
| -rw-r--r-- | gnu/installer/final.scm | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gnu/installer/final.scm b/gnu/installer/final.scm index 044f79372b1..f5601d86497 100644 --- a/gnu/installer/final.scm +++ b/gnu/installer/final.scm | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com> | 2 | ;;; Copyright © 2018, 2020 Mathieu Othacehe <m.othacehe@gmail.com> |
| 3 | ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org> | 3 | ;;; Copyright © 2019, 2020, 2022 Ludovic Courtès <ludo@gnu.org> |
| 4 | ;;; | 4 | ;;; |
| 5 | ;;; This file is part of GNU Guix. | 5 | ;;; This file is part of GNU Guix. |
| 6 | ;;; | 6 | ;;; |
| @@ -114,6 +114,8 @@ it can interact with the rest of the system." | |||
| 114 | ;; Catch SIGINT and kill the container process. | 114 | ;; Catch SIGINT and kill the container process. |
| 115 | (sigaction SIGINT | 115 | (sigaction SIGINT |
| 116 | (lambda (signum) | 116 | (lambda (signum) |
| 117 | ;: FIXME: Use of SIGKILL prevents the dynamic-wind exit handler of | ||
| 118 | ;; THUNK to run. | ||
| 117 | (false-if-exception | 119 | (false-if-exception |
| 118 | (kill pid SIGKILL)))) | 120 | (kill pid SIGKILL)))) |
| 119 | 121 | ||
| @@ -196,14 +198,16 @@ or #f. Return #t on success and #f on failure." | |||
| 196 | ;; the loaded cow-store locale files will prevent umounting. | 198 | ;; the loaded cow-store locale files will prevent umounting. |
| 197 | (install-locale locale) | 199 | (install-locale locale) |
| 198 | 200 | ||
| 199 | ;; Save the database, so that it can be restored once the | 201 | ;; Stop the daemon and save the database, so that it can be |
| 200 | ;; cow-store is umounted. | 202 | ;; restored once the cow-store is umounted. |
| 203 | (stop-service 'guix-daemon) | ||
| 201 | (copy-file database-file saved-database) | 204 | (copy-file database-file saved-database) |
| 205 | |||
| 206 | (installer-log-line "mounting copy-on-write store") | ||
| 202 | (mount-cow-store (%installer-target-dir) backing-directory)) | 207 | (mount-cow-store (%installer-target-dir) backing-directory)) |
| 203 | (lambda () | 208 | (lambda () |
| 204 | ;; We need to drag the guix-daemon to the container MNT | 209 | ;; We need to drag the guix-daemon to the container MNT |
| 205 | ;; namespace, so that it can operate on the cow-store. | 210 | ;; namespace, so that it can operate on the cow-store. |
| 206 | (stop-service 'guix-daemon) | ||
| 207 | (start-service 'guix-daemon (list (number->string (getpid)))) | 211 | (start-service 'guix-daemon (list (number->string (getpid)))) |
| 208 | 212 | ||
| 209 | (setvbuf (current-output-port) 'none) | 213 | (setvbuf (current-output-port) 'none) |
| @@ -213,11 +217,17 @@ or #f. Return #t on success and #f on failure." | |||
| 213 | 217 | ||
| 214 | (set! ret (run-command install-command #:tty? #t))) | 218 | (set! ret (run-command install-command #:tty? #t))) |
| 215 | (lambda () | 219 | (lambda () |
| 216 | ;; Restart guix-daemon so that it does no keep the MNT namespace | 220 | ;; Stop guix-daemon so that it does no keep the MNT namespace |
| 217 | ;; alive. | 221 | ;; alive. |
| 218 | (restart-service 'guix-daemon) | 222 | (stop-service 'guix-daemon) |
| 223 | |||
| 224 | ;; Restore the database and restart it. | ||
| 225 | (installer-log-line "restoring store database from '~a'" | ||
| 226 | saved-database) | ||
| 219 | (copy-file saved-database database-file) | 227 | (copy-file saved-database database-file) |
| 228 | (start-service 'guix-daemon) | ||
| 220 | 229 | ||
| 221 | ;; Finally umount the cow-store and exit the container. | 230 | ;; Finally umount the cow-store and exit the container. |
| 231 | (installer-log-line "unmounting copy-on-write store") | ||
| 222 | (unmount-cow-store (%installer-target-dir) backing-directory) | 232 | (unmount-cow-store (%installer-target-dir) backing-directory) |
| 223 | (assert-exit ret)))))))) | 233 | (assert-exit ret)))))))) |
