guix gc: Add '--optimize'.

* guix/scripts/gc.scm (show-help, %options): Add --optimize.
  (guix-gc): Handle it.
This commit is contained in:
Ludovic Courtès 2015-05-19 09:59:45 +02:00
parent e3fd0ce696
commit 38d2778608
2 changed files with 20 additions and 1 deletions

View File

@ -1472,6 +1472,17 @@ Attempt to delete all the store files and directories specified as
arguments. This fails if some of the files are not in the store, or if arguments. This fails if some of the files are not in the store, or if
they are still live. they are still live.
@item --optimize
@cindex deduplication
Optimize the store by hard-linking identical files---this is
@dfn{deduplication}.
The daemon performs deduplication after each successful build or archive
import, unless it was started with @code{--disable-deduplication}
(@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
this option is primarily useful when the daemon was running with
@code{--disable-deduplication}.
@item --list-dead @item --list-dead
Show the list of dead files and directories still present in the Show the list of dead files and directories still present in the
store---i.e., files and directories no longer reachable from any root. store---i.e., files and directories no longer reachable from any root.

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@gnu.org>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -43,6 +43,8 @@ Invoke the garbage collector.\n"))
collect at least MIN bytes of garbage")) collect at least MIN bytes of garbage"))
(display (_ " (display (_ "
-d, --delete attempt to delete PATHS")) -d, --delete attempt to delete PATHS"))
(display (_ "
--optimize optimize the store by deduplicating identical files"))
(display (_ " (display (_ "
--list-dead list dead paths")) --list-dead list dead paths"))
(display (_ " (display (_ "
@ -88,6 +90,10 @@ Invoke the garbage collector.\n"))
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'action 'delete (alist-cons 'action 'delete
(alist-delete 'action result)))) (alist-delete 'action result))))
(option '("optimize") #f #f
(lambda (opt name arg result)
(alist-cons 'action 'optimize
(alist-delete 'action result))))
(option '("list-dead") #f #f (option '("list-dead") #f #f
(lambda (opt name arg result) (lambda (opt name arg result)
(alist-cons 'action 'list-dead (alist-cons 'action 'list-dead
@ -169,6 +175,8 @@ Invoke the garbage collector.\n"))
(list-relatives requisites)) (list-relatives requisites))
((list-referrers) ((list-referrers)
(list-relatives referrers)) (list-relatives referrers))
((optimize)
(optimize-store store))
((list-dead) ((list-dead)
(for-each (cut simple-format #t "~a~%" <>) (for-each (cut simple-format #t "~a~%" <>)
(dead-paths store))) (dead-paths store)))