2015-06-18 00:22:13 +02:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2019-04-06 14:52:56 +02:00
|
|
|
|
;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
|
2015-06-18 00:22:13 +02:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix scripts size)
|
|
|
|
|
#:use-module (guix ui)
|
2015-09-10 11:37:36 +02:00
|
|
|
|
#:use-module (guix scripts)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
#:use-module (guix store)
|
|
|
|
|
#:use-module (guix monads)
|
utils: Move combinators to (guix combinators).
* guix/utils.scm (compile-time-value, memoize, fold2)
(fold-tree, fold-tree-leaves): Move to...
* guix/combinators: ... here. New file.
* tests/utils.scm ("fold2, 1 list", "fold2, 2 lists")
(fold-tree tests): Move to...
* tests/combinators.scm: ... here. New file.
* Makefile.am (MODULES, SCM_TESTS): Add them.
* gnu/packages.scm, gnu/packages/bootstrap.scm,
gnu/services/herd.scm, guix/build-system/gnu.scm,
guix/build-system/python.scm, guix/derivations.scm,
guix/gnu-maintenance.scm, guix/import/elpa.scm,
guix/scripts/archive.scm, guix/scripts/build.scm,
guix/scripts/graph.scm, guix/scripts/lint.scm,
guix/scripts/size.scm, guix/scripts/substitute.scm,
guix/serialization.scm, guix/store.scm, guix/ui.scm: Adjust imports
accordingly.
2016-05-04 17:35:47 +02:00
|
|
|
|
#:use-module (guix combinators)
|
2016-03-14 09:54:30 +01:00
|
|
|
|
#:use-module (guix grafts)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
#:use-module (guix packages)
|
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
|
#:use-module (gnu packages)
|
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-9)
|
|
|
|
|
#:use-module (srfi srfi-11)
|
2016-07-29 19:48:23 +02:00
|
|
|
|
#:use-module (srfi srfi-26)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-37)
|
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:use-module (ice-9 format)
|
2019-04-06 14:52:56 +02:00
|
|
|
|
#:use-module (ice-9 vlist)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
#:export (profile?
|
|
|
|
|
profile-file
|
|
|
|
|
profile-self-size
|
|
|
|
|
profile-closure-size
|
|
|
|
|
store-profile
|
|
|
|
|
|
|
|
|
|
guix-size))
|
|
|
|
|
|
|
|
|
|
;; Size profile of a store item.
|
|
|
|
|
(define-record-type <profile>
|
|
|
|
|
(profile file self-size closure-size)
|
|
|
|
|
profile?
|
|
|
|
|
(file profile-file) ;store item
|
|
|
|
|
(self-size profile-self-size) ;size in bytes
|
|
|
|
|
(closure-size profile-closure-size)) ;size of dependencies in bytes
|
|
|
|
|
|
|
|
|
|
(define substitutable-path-info*
|
|
|
|
|
(store-lift substitutable-path-info))
|
|
|
|
|
|
2015-08-19 11:33:51 +02:00
|
|
|
|
(define (file-size item)
|
|
|
|
|
"Return the size in bytes of ITEM, resorting to information from substitutes
|
|
|
|
|
if ITEM is not in the store."
|
|
|
|
|
(mlet %store-monad ((info (query-path-info* item)))
|
|
|
|
|
(if info
|
|
|
|
|
(return (path-info-nar-size info))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(mlet %store-monad ((info (substitutable-path-info* (list item))))
|
|
|
|
|
(match info
|
|
|
|
|
((info)
|
|
|
|
|
;; The nar size is an approximation, but a good one.
|
|
|
|
|
(return (substitutable-nar-size info)))
|
|
|
|
|
(()
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(leave (G_ "no available substitute information for '~a'~%")
|
2015-06-18 00:22:13 +02:00
|
|
|
|
item)))))))
|
|
|
|
|
|
2017-07-12 15:41:49 +02:00
|
|
|
|
(define profile-closure<?
|
|
|
|
|
(match-lambda*
|
|
|
|
|
((($ <profile> name1 self1 total1)
|
|
|
|
|
($ <profile> name2 self2 total2))
|
|
|
|
|
(< total1 total2))))
|
|
|
|
|
|
|
|
|
|
(define profile-self<?
|
|
|
|
|
(match-lambda*
|
|
|
|
|
((($ <profile> name1 self1 total1)
|
|
|
|
|
($ <profile> name2 self2 total2))
|
|
|
|
|
(< self1 self2))))
|
|
|
|
|
|
|
|
|
|
(define* (display-profile profile #:optional (port (current-output-port))
|
|
|
|
|
#:key (profile<? profile-closure<?))
|
|
|
|
|
"Display PROFILE, a list of PROFILE objects, to PORT. Sort entries
|
|
|
|
|
according to PROFILE<?."
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(define MiB (expt 2 20))
|
|
|
|
|
|
|
|
|
|
(format port "~64a ~8a ~a\n"
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(G_ "store item") (G_ "total") (G_ "self"))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(let ((whole (reduce + 0 (map profile-self-size profile))))
|
|
|
|
|
(for-each (match-lambda
|
|
|
|
|
(($ <profile> name self total)
|
|
|
|
|
(format port "~64a ~6,1f ~6,1f ~5,1f%\n"
|
|
|
|
|
name (/ total MiB) (/ self MiB)
|
|
|
|
|
(* 100. (/ self whole 1.)))))
|
2017-07-12 15:41:49 +02:00
|
|
|
|
(sort profile (negate profile<?)))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(format port (G_ "total: ~,1f MiB~%") (/ whole MiB 1.))))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
|
|
|
|
|
(define display-profile*
|
|
|
|
|
(lift display-profile %store-monad))
|
|
|
|
|
|
2016-05-24 23:41:30 +02:00
|
|
|
|
(define (substitutable-requisites store items)
|
|
|
|
|
"Return the list of requisites of ITEMS based on information available in
|
2015-06-18 00:22:13 +02:00
|
|
|
|
substitutes."
|
2016-05-24 23:41:30 +02:00
|
|
|
|
(let loop ((items items)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(result '()))
|
|
|
|
|
(match items
|
|
|
|
|
(()
|
|
|
|
|
(delete-duplicates result))
|
|
|
|
|
(items
|
|
|
|
|
(let ((info (substitutable-path-info store
|
|
|
|
|
(delete-duplicates items))))
|
|
|
|
|
(loop (remove (lambda (item) ;XXX: complexity
|
|
|
|
|
(member item result))
|
|
|
|
|
(append-map substitutable-references info))
|
|
|
|
|
(append (append-map substitutable-references info)
|
|
|
|
|
result)))))))
|
|
|
|
|
|
2016-05-24 23:41:30 +02:00
|
|
|
|
(define (requisites* items)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
"Return as a monadic value the requisites of ITEMS, based either on the
|
|
|
|
|
information available in the local store or using information about
|
|
|
|
|
substitutes."
|
|
|
|
|
(lambda (store)
|
2016-07-29 19:48:23 +02:00
|
|
|
|
(let-values (((local missing)
|
|
|
|
|
(partition (cut valid-path? store <>) items)))
|
|
|
|
|
(values (delete-duplicates
|
|
|
|
|
(append (requisites store local)
|
|
|
|
|
(substitutable-requisites store missing)))
|
|
|
|
|
store))))
|
2016-05-24 20:51:49 +02:00
|
|
|
|
|
|
|
|
|
(define (store-profile items)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
"Return as a monadic value a list of <profile> objects representing the
|
2016-05-24 20:51:49 +02:00
|
|
|
|
profile of ITEMS and their requisites."
|
2016-05-24 23:41:30 +02:00
|
|
|
|
(mlet* %store-monad ((refs (>>= (requisites* items)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(lambda (refs)
|
|
|
|
|
(return (delete-duplicates
|
2016-05-24 20:51:49 +02:00
|
|
|
|
(append items refs))))))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(sizes (mapm %store-monad
|
|
|
|
|
(lambda (item)
|
2015-08-19 11:33:51 +02:00
|
|
|
|
(>>= (file-size item)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(lambda (size)
|
|
|
|
|
(return (cons item size)))))
|
|
|
|
|
refs)))
|
2019-04-06 14:52:56 +02:00
|
|
|
|
(define size-table
|
|
|
|
|
(fold (lambda (pair result)
|
|
|
|
|
(match pair
|
|
|
|
|
((item . size)
|
|
|
|
|
(vhash-cons item size result))))
|
|
|
|
|
vlist-null sizes))
|
|
|
|
|
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(define (dependency-size item)
|
2016-05-24 23:41:30 +02:00
|
|
|
|
(mlet %store-monad ((deps (requisites* (list item))))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(foldm %store-monad
|
|
|
|
|
(lambda (item total)
|
2019-04-06 14:52:56 +02:00
|
|
|
|
(return (+ (match (vhash-assoc item size-table)
|
|
|
|
|
((_ . size) size))
|
|
|
|
|
total)))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
0
|
|
|
|
|
(delete-duplicates (cons item deps)))))
|
|
|
|
|
|
|
|
|
|
(mapm %store-monad
|
|
|
|
|
(match-lambda
|
|
|
|
|
((item . size)
|
|
|
|
|
(mlet %store-monad ((dependencies (dependency-size item)))
|
|
|
|
|
(return (profile item size dependencies)))))
|
|
|
|
|
sizes)))
|
|
|
|
|
|
2015-06-19 22:22:15 +02:00
|
|
|
|
(define* (ensure-store-item spec-or-item)
|
2015-06-18 00:22:13 +02:00
|
|
|
|
"Return a store file name. If SPEC-OR-ITEM is a store file name, return it
|
|
|
|
|
as is. Otherwise, assume SPEC-OR-ITEM is a package output specification such
|
|
|
|
|
as \"guile:debug\" or \"gcc-4.8\" and return its store file name."
|
|
|
|
|
(with-monad %store-monad
|
|
|
|
|
(if (store-path? spec-or-item)
|
|
|
|
|
(return spec-or-item)
|
|
|
|
|
(let-values (((package output)
|
|
|
|
|
(specification->package+output spec-or-item)))
|
|
|
|
|
(mlet %store-monad ((drv (package->derivation package)))
|
|
|
|
|
;; Note: we don't try building DRV like 'guix archive' does
|
|
|
|
|
;; because we don't have to since we can instead rely on
|
|
|
|
|
;; substitute meta-data.
|
|
|
|
|
(return (derivation->output-path drv output)))))))
|
|
|
|
|
|
2015-06-21 23:25:19 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Charts.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
;; Autoload Guile-Charting.
|
|
|
|
|
;; XXX: Use this hack instead of #:autoload to avoid compilation errors.
|
|
|
|
|
;; See <http://bugs.gnu.org/12202>.
|
|
|
|
|
(module-autoload! (current-module)
|
|
|
|
|
'(charting) '(make-page-map))
|
|
|
|
|
|
|
|
|
|
(define (profile->page-map profiles file)
|
|
|
|
|
"Write a 'page map' chart of PROFILES, a list of <profile> objects, to FILE,
|
|
|
|
|
the name of a PNG file."
|
|
|
|
|
(define (strip name)
|
|
|
|
|
(string-drop name (+ (string-length (%store-prefix)) 28)))
|
|
|
|
|
|
|
|
|
|
(define data
|
|
|
|
|
(fold2 (lambda (profile result offset)
|
|
|
|
|
(match profile
|
|
|
|
|
(($ <profile> name self)
|
|
|
|
|
(let ((self (inexact->exact
|
|
|
|
|
(round (/ self (expt 2. 10))))))
|
|
|
|
|
(values `((,(strip name) ,offset . ,self)
|
|
|
|
|
,@result)
|
|
|
|
|
(+ offset self))))))
|
|
|
|
|
'()
|
|
|
|
|
0
|
|
|
|
|
(sort profiles
|
|
|
|
|
(match-lambda*
|
2017-04-06 18:21:54 +02:00
|
|
|
|
((($ <profile> name1 self1 total1)
|
|
|
|
|
($ <profile> name2 self2 total2))
|
2015-06-21 23:25:19 +02:00
|
|
|
|
(> total1 total2))))))
|
|
|
|
|
|
|
|
|
|
;; TRANSLATORS: This is the title of a graph, meaning that the graph
|
|
|
|
|
;; represents a profile of the store (the "store" being the place where
|
|
|
|
|
;; packages are stored.)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(make-page-map (G_ "store profile") data
|
2015-06-21 23:25:19 +02:00
|
|
|
|
#:write-to-png file))
|
|
|
|
|
|
2015-06-18 00:22:13 +02:00
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Options.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (show-help)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "Usage: guix size [OPTION]... PACKAGE
|
2015-06-18 00:22:13 +02:00
|
|
|
|
Report the size of PACKAGE and its dependencies.\n"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "
|
2015-07-22 19:47:01 +02:00
|
|
|
|
--substitute-urls=URLS
|
|
|
|
|
fetch substitute from URLS if they are authorized"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "
|
2015-06-18 00:22:13 +02:00
|
|
|
|
-s, --system=SYSTEM consider packages for SYSTEM--e.g., \"i686-linux\""))
|
2017-07-12 15:41:49 +02:00
|
|
|
|
;; TRANSLATORS: "closure" and "self" must not be translated.
|
|
|
|
|
(display (G_ "
|
|
|
|
|
--sort=KEY sort according to KEY--\"closure\" or \"self\""))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "
|
2015-07-22 19:47:01 +02:00
|
|
|
|
-m, --map-file=FILE write to FILE a graphical map of disk usage"))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(newline)
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "
|
2015-06-18 00:22:13 +02:00
|
|
|
|
-h, --help display this help and exit"))
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(display (G_ "
|
2015-06-18 00:22:13 +02:00
|
|
|
|
-V, --version display version information and exit"))
|
|
|
|
|
(newline)
|
|
|
|
|
(show-bug-report-information))
|
|
|
|
|
|
|
|
|
|
(define %options
|
|
|
|
|
;; Specifications of the command-line options.
|
|
|
|
|
(list (option '(#\s "system") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'system arg
|
|
|
|
|
(alist-delete 'system result eq?))))
|
2015-07-22 19:47:01 +02:00
|
|
|
|
(option '("substitute-urls") #t #f
|
|
|
|
|
(lambda (opt name arg result . rest)
|
|
|
|
|
(apply values
|
|
|
|
|
(alist-cons 'substitute-urls
|
|
|
|
|
(string-tokenize arg)
|
|
|
|
|
(alist-delete 'substitute-urls result))
|
|
|
|
|
rest)))
|
2017-07-12 15:41:49 +02:00
|
|
|
|
(option '("sort") #t #f
|
|
|
|
|
(lambda (opt name arg result . rest)
|
|
|
|
|
(match arg
|
|
|
|
|
("closure"
|
|
|
|
|
(alist-cons 'profile<? profile-closure<? result))
|
|
|
|
|
("self"
|
|
|
|
|
(alist-cons 'profile<? profile-self<? result))
|
|
|
|
|
(_
|
|
|
|
|
(leave (G_ "~a: invalid sorting key~%") arg)))))
|
2015-06-21 23:25:19 +02:00
|
|
|
|
(option '(#\m "map-file") #t #f
|
|
|
|
|
(lambda (opt name arg result)
|
|
|
|
|
(alist-cons 'map-file arg result)))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(option '(#\h "help") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-help)
|
|
|
|
|
(exit 0)))
|
|
|
|
|
(option '(#\V "version") #f #f
|
|
|
|
|
(lambda args
|
|
|
|
|
(show-version-and-exit "guix size")))))
|
|
|
|
|
|
|
|
|
|
(define %default-options
|
2017-07-12 15:41:49 +02:00
|
|
|
|
`((system . ,(%current-system))
|
2017-09-07 11:30:44 +02:00
|
|
|
|
(profile<? . ,profile-self<?)))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Entry point.
|
|
|
|
|
;;;
|
|
|
|
|
|
|
|
|
|
(define (guix-size . args)
|
|
|
|
|
(with-error-handling
|
2017-10-27 22:28:00 +02:00
|
|
|
|
(let* ((opts (parse-command-line args %options (list %default-options)
|
|
|
|
|
#:build-options? #f))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(files (filter-map (match-lambda
|
|
|
|
|
(('argument . file) file)
|
|
|
|
|
(_ #f))
|
|
|
|
|
opts))
|
2017-07-12 15:41:49 +02:00
|
|
|
|
(profile<? (assoc-ref opts 'profile<?))
|
2015-06-21 23:25:19 +02:00
|
|
|
|
(map-file (assoc-ref opts 'map-file))
|
2015-07-22 19:47:01 +02:00
|
|
|
|
(system (assoc-ref opts 'system))
|
|
|
|
|
(urls (assoc-ref opts 'substitute-urls)))
|
2015-06-18 00:22:13 +02:00
|
|
|
|
(match files
|
|
|
|
|
(()
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 15:57:02 +02:00
|
|
|
|
(leave (G_ "missing store item argument\n")))
|
2016-05-24 21:37:13 +02:00
|
|
|
|
((files ..1)
|
2015-07-15 18:05:29 +02:00
|
|
|
|
(leave-on-EPIPE
|
2018-12-03 16:22:43 +01:00
|
|
|
|
;; Turn off grafts because (1) substitute servers do not serve grafted
|
2016-03-14 09:54:30 +01:00
|
|
|
|
;; packages, and (2) they do not make any difference on the
|
|
|
|
|
;; resulting size.
|
|
|
|
|
(parameterize ((%graft? #f))
|
|
|
|
|
(with-store store
|
|
|
|
|
(set-build-options store
|
|
|
|
|
#:use-substitutes? #t
|
|
|
|
|
#:substitute-urls urls)
|
2015-07-22 19:47:01 +02:00
|
|
|
|
|
2016-03-14 09:54:30 +01:00
|
|
|
|
(run-with-store store
|
2016-05-24 21:37:13 +02:00
|
|
|
|
(mlet* %store-monad ((items (mapm %store-monad
|
|
|
|
|
ensure-store-item files))
|
|
|
|
|
(profile (store-profile items)))
|
2016-03-14 09:54:30 +01:00
|
|
|
|
(if map-file
|
|
|
|
|
(begin
|
|
|
|
|
(profile->page-map profile map-file)
|
|
|
|
|
(return #t))
|
2017-07-12 15:41:49 +02:00
|
|
|
|
(display-profile* profile (current-output-port)
|
|
|
|
|
#:profile<? profile<?)))
|
2016-05-24 21:37:13 +02:00
|
|
|
|
#:system system)))))))))
|