mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 21:38:07 -05:00
guix gc: Add '--vacuum-database'.
* guix/scripts/gc.scm (show-help, %options): Add '--vacuum-database'. * guix/store/database.scm (vacuum-database): New procedure. * doc/guix.texi (Invoking guix gc): Document the option.
This commit is contained in:
parent
2bf8146e31
commit
97d565c786
3 changed files with 31 additions and 1 deletions
|
@ -4531,6 +4531,18 @@ import, unless it was started with @option{--disable-deduplication}
|
||||||
this option is primarily useful when the daemon was running with
|
this option is primarily useful when the daemon was running with
|
||||||
@option{--disable-deduplication}.
|
@option{--disable-deduplication}.
|
||||||
|
|
||||||
|
@item --vacuum-database
|
||||||
|
@cindex vacuum the store database
|
||||||
|
@comment Avoid words like 'repair,' 'compress,' and 'optimize.'
|
||||||
|
Guix uses an sqlite database to keep track of the items in (@pxref{The Store}).
|
||||||
|
Over time it is possible that the database may grow to a large size and become
|
||||||
|
fragmented. As a result, one may wish to clear the freed space and join the
|
||||||
|
partially used pages in the database left behind from removed packages or after
|
||||||
|
running the garbage collector. Running @command{sudo guix gc
|
||||||
|
--vacuum-database} will lock the database and @code{VACUUM} the store,
|
||||||
|
defragmenting the database and purging freed pages, unlocking the database when
|
||||||
|
it finishes.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@node Invoking guix pull
|
@node Invoking guix pull
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012-2013, 2015-2020, 2022 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012-2013, 2015-2020, 2022 Ludovic Courtès <ludo@gnu.org>
|
||||||
|
;;; Copyright © 2022 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -27,6 +28,7 @@ (define-module (guix scripts gc)
|
||||||
generation-number)
|
generation-number)
|
||||||
#:autoload (guix scripts package) (delete-generations)
|
#:autoload (guix scripts package) (delete-generations)
|
||||||
#:autoload (gnu home) (home-generation-base)
|
#:autoload (gnu home) (home-generation-base)
|
||||||
|
#:autoload (guix store database) (vacuum-database)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 regex)
|
#:use-module (ice-9 regex)
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
|
@ -86,6 +88,10 @@ (define (show-help)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
--clear-failures remove PATHS from the set of cached failures"))
|
--clear-failures remove PATHS from the set of cached failures"))
|
||||||
(newline)
|
(newline)
|
||||||
|
(display (G_ "
|
||||||
|
--vacuum-database repack the sqlite database tracking the store
|
||||||
|
using less space"))
|
||||||
|
(newline)
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
-h, --help display this help and exit"))
|
-h, --help display this help and exit"))
|
||||||
(display (G_ "
|
(display (G_ "
|
||||||
|
@ -131,6 +137,11 @@ (define %options
|
||||||
(lambda args
|
(lambda args
|
||||||
(show-version-and-exit "guix gc")))
|
(show-version-and-exit "guix gc")))
|
||||||
|
|
||||||
|
(option '("vacuum-database") #f #f
|
||||||
|
(lambda args
|
||||||
|
(vacuum-database)
|
||||||
|
(exit 0)))
|
||||||
|
|
||||||
(option '(#\C "collect-garbage") #f #t
|
(option '(#\C "collect-garbage") #f #t
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(let ((result (alist-cons 'action 'collect-garbage
|
(let ((result (alist-cons 'action 'collect-garbage
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
;;; Copyright © 2017, 2019 Caleb Ristvedt <caleb.ristvedt@cune.org>
|
;;; Copyright © 2017, 2019 Caleb Ristvedt <caleb.ristvedt@cune.org>
|
||||||
;;; Copyright © 2018, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2018, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
;;; Copyright © 2022 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -45,7 +46,8 @@ (define-module (guix store database)
|
||||||
sqlite-register
|
sqlite-register
|
||||||
register-items
|
register-items
|
||||||
%epoch
|
%epoch
|
||||||
reset-timestamps))
|
reset-timestamps
|
||||||
|
vacuum-database))
|
||||||
|
|
||||||
;;; Code for working with the store database directly.
|
;;; Code for working with the store database directly.
|
||||||
|
|
||||||
|
@ -438,3 +440,8 @@ (define real-file-name
|
||||||
(register db item)
|
(register db item)
|
||||||
(report))
|
(report))
|
||||||
items)))))
|
items)))))
|
||||||
|
|
||||||
|
(define (vacuum-database)
|
||||||
|
(let ((db (sqlite-open (store-database-file))))
|
||||||
|
(sqlite-exec db "VACUUM;")
|
||||||
|
(sqlite-close db)))
|
||||||
|
|
Loading…
Reference in a new issue