From 04b4c43232d114d7bc4a415e3c6138c52d33a800 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Thu, 12 Mar 2020 09:54:11 +0100 Subject: doc: Fix description for "guix package -A". * doc/guix.texi (Invoking guix package): Fix description for "guix package -A". --- doc/guix.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index eb6eb99361..dd32b65fe0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3122,7 +3122,7 @@ the store. @itemx -A [@var{regexp}] List packages currently available in the distribution for this system (@pxref{GNU Distribution}). When @var{regexp} is specified, list only -installed packages whose name matches @var{regexp}. +available packages whose name matches @var{regexp}. For each package, print the following items separated by tabs: its name, its version string, the parts of the package (@pxref{Packages with -- cgit 1.4.1 From cf2ac04f13d9266c7c8a2ebd2e85ef593231ac9d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 6 Mar 2020 11:25:43 +0100 Subject: gexp: Add 'with-parameters'. * guix/gexp.scm (): New record type. (with-parameters): New macro. (compile-parameterized): New gexp compiler. * tests/gexp.scm ("with-parameters for %current-system") ("with-parameters for %current-target-system") ("with-parameters + file-append"): New tests. * doc/guix.texi (G-Expressions): Document it. --- .dir-locals.el | 1 + doc/guix.texi | 19 +++++++++++++++++++ guix/gexp.scm | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/gexp.scm | 38 +++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+) (limited to 'doc') diff --git a/.dir-locals.el b/.dir-locals.el index 5ce3fbc9a5..1976f7e60d 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -83,6 +83,7 @@ (eval . (put 'wrap-program 'scheme-indent-function 1)) (eval . (put 'with-imported-modules 'scheme-indent-function 1)) (eval . (put 'with-extensions 'scheme-indent-function 1)) + (eval . (put 'with-parameters 'scheme-indent-function 1)) (eval . (put 'with-database 'scheme-indent-function 2)) (eval . (put 'call-with-transaction 'scheme-indent-function 2)) diff --git a/doc/guix.texi b/doc/guix.texi index dd32b65fe0..4f8f7cfb2a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -8022,6 +8022,25 @@ the second case, the resulting script contains a @code{(string-append @dots{})} expression to construct the file name @emph{at run time}. @end deffn +@deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp} +This macro is similar to the @code{parameterize} form for +dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU +Guile Reference Manual}). The key difference is that it takes effect +when the file-like object returned by @var{exp} is lowered to a +derivation or store item. + +A typical use of @code{with-parameters} is to force the system in effect +for a given object: + +@lisp +(with-parameters ((%current-system "i686-linux")) + coreutils) +@end lisp + +The example above returns an object that corresponds to the i686 build +of Coreutils, regardless of the current value of @code{%current-system}. +@end deffn + Of course, in addition to gexps embedded in ``host'' code, there are also modules containing build tools. To make it clear that they are diff --git a/guix/gexp.scm b/guix/gexp.scm index a657921741..133e0f5679 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -82,6 +82,9 @@ raw-derivation-file raw-derivation-file? + with-parameters + parameterized? + load-path-expression gexp-modules @@ -523,6 +526,62 @@ SUFFIX." (base (expand base lowered output))) (string-append base (string-concatenate suffix))))))) +;; Representation of SRFI-39 parameter settings in the dynamic scope of an +;; object lowering. +(define-record-type + (parameterized bindings thunk) + parameterized? + (bindings parameterized-bindings) ;list of parameter/value pairs + (thunk parameterized-thunk)) ;thunk + +(define-syntax-rule (with-parameters ((param value) ...) body ...) + "Bind each PARAM to the corresponding VALUE for the extent during which BODY +is lowered. Consider this example: + + (with-parameters ((%current-system \"x86_64-linux\")) + coreutils) + +It returns a object that ensures %CURRENT-SYSTEM is set to +x86_64-linux when COREUTILS is lowered." + (parameterized (list (list param (lambda () value)) ...) + (lambda () + body ...))) + +(define-gexp-compiler compile-parameterized + compiler => + (lambda (parameterized system target) + (match (parameterized-bindings parameterized) + (((parameters values) ...) + (let ((fluids (map parameter-fluid parameters)) + (thunk (parameterized-thunk parameterized))) + ;; Install the PARAMETERS for the dynamic extent of THUNK. + (with-fluids* fluids + (map (lambda (thunk) (thunk)) values) + (lambda () + ;; Special-case '%current-system' and '%current-target-system' to + ;; make sure we get the desired effect. + (let ((system (if (memq %current-system parameters) + (%current-system) + system)) + (target (if (memq %current-target-system parameters) + (%current-target-system) + target))) + (lower-object (thunk) system #:target target)))))))) + + expander => (lambda (parameterized lowered output) + (match (parameterized-bindings parameterized) + (((parameters values) ...) + (let ((fluids (map parameter-fluid parameters)) + (thunk (parameterized-thunk parameterized))) + ;; Install the PARAMETERS for the dynamic extent of THUNK. + (with-fluids* fluids + (map (lambda (thunk) (thunk)) values) + (lambda () + ;; Delegate to the expander of the wrapped object. + (let* ((base (thunk)) + (expand (lookup-expander base))) + (expand base lowered output))))))))) + ;;; ;;; Inputs & outputs. diff --git a/tests/gexp.scm b/tests/gexp.scm index 9e38816c3d..6a42d3eb57 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -284,6 +284,44 @@ (((thing "out")) (eq? thing file)))))) +(test-assertm "with-parameters for %current-system" + (mlet* %store-monad ((system -> (match (%current-system) + ("aarch64-linux" "x86_64-linux") + (_ "aarch64-linux"))) + (drv (package->derivation coreutils system)) + (obj -> (with-parameters ((%current-system system)) + coreutils)) + (result (lower-object obj))) + (return (string=? (derivation-file-name drv) + (derivation-file-name result))))) + +(test-assertm "with-parameters for %current-target-system" + (mlet* %store-monad ((target -> "riscv64-linux-gnu") + (drv (package->cross-derivation coreutils target)) + (obj -> (with-parameters + ((%current-target-system target)) + coreutils)) + (result (lower-object obj))) + (return (string=? (derivation-file-name drv) + (derivation-file-name result))))) + +(test-assert "with-parameters + file-append" + (let* ((system (match (%current-system) + ("aarch64-linux" "x86_64-linux") + (_ "aarch64-linux"))) + (drv (package-derivation %store coreutils system)) + (param (make-parameter 7)) + (exp #~(here we go #$(with-parameters ((%current-system system) + (param 42)) + (if (= (param) 42) + (file-append coreutils "/bin/touch") + %bootstrap-guile))))) + (match (gexp->sexp* exp) + (('here 'we 'go (? string? result)) + (string=? result + (string-append (derivation->output-path drv) + "/bin/touch")))))) + (test-assert "ungexp + ungexp-native" (let* ((exp (gexp (list (ungexp-native %bootstrap-guile) (ungexp coreutils) -- cgit 1.4.1 From 71bb485541328cdce214ada44be998570571bf36 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 12 Mar 2020 18:10:26 +0100 Subject: weather: Add '--display-missing'. * guix/scripts/weather.scm (report-server-coverage): Add #:display-missing? and honor it. (show-help, %options): Add "--display-missing". (guix-weather): Pass #:display-missing? to 'report-server-coverage'. * doc/guix.texi (Invoking guix weather): Document it. --- doc/guix.texi | 3 +++ guix/scripts/weather.scm | 22 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 4f8f7cfb2a..ca21857a31 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10860,6 +10860,9 @@ likewise for @code{qgpgme} and the 46 packages that depend on it. If you are a Guix developer, or if you are taking care of this build farm, you'll probably want to have a closer look at these packages: they may simply fail to build. + +@item --display-missing +Display the list of store items for which substitutes are missing. @end table @node Invoking guix processes diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 629844768a..60915d3451 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -175,8 +175,10 @@ about the derivations queued, as is the case with Hydra." #f ;no derivation information (lset-intersection string=? queued items))) -(define (report-server-coverage server items) - "Report the subset of ITEMS available as substitutes on SERVER." +(define* (report-server-coverage server items + #:key display-missing?) + "Report the subset of ITEMS available as substitutes on SERVER. +When DISPLAY-MISSING? is true, display the list of missing substitutes." (define MiB (* (expt 2 20) 1.)) (format #t (G_ "looking for ~h store items on ~a...~%") @@ -260,7 +262,12 @@ are queued~%") system (* (throughput builds build-timestamp) 3600.)))) - (histogram build-system cons '() latest))))))) + (histogram build-system cons '() latest)))) + + (when (and display-missing? (not (null? missing))) + (newline) + (format #t (G_ "Substitutes are missing for the following items:~%")) + (format #t "~{ ~a~%~}" missing))))) ;;; @@ -280,6 +287,8 @@ Report the availability of substitutes.\n")) -c, --coverage[=COUNT] show substitute coverage for packages with at least COUNT dependents")) + (display (G_ " + --display-missing display the list of missing substitutes")) (display (G_ " -s, --system=SYSTEM consider substitutes for SYSTEM--e.g., \"i686-linux\"")) (newline) @@ -318,6 +327,9 @@ Report the availability of substitutes.\n")) (alist-cons 'coverage (if arg (string->number* arg) 0) result))) + (option '("display-missing") #f #f + (lambda (opt name arg result) + (alist-cons 'display-missing? #t result))) (option '(#\s "system") #t #f (lambda (opt name arg result) (alist-cons 'system arg result))))) @@ -525,7 +537,9 @@ SERVER. Display information for packages with at least THRESHOLD dependents." (package-outputs packages system)) systems)))))) (for-each (lambda (server) - (report-server-coverage server items) + (report-server-coverage server items + #:display-missing? + (assoc-ref opts 'display-missing?)) (match (assoc-ref opts 'coverage) (#f #f) (threshold -- cgit 1.4.1 From 2843fed0e973145f01fb2004c99aca8e8837b332 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 12 Mar 2020 18:30:05 +0100 Subject: weather: Allow for multiple '--manifest' options. * guix/scripts/weather.scm (guix-weather)[package-list]: Account for all the 'manifest entries in OPTS. * doc/guix.texi (Invoking guix weather): Document it. --- doc/guix.texi | 3 +++ guix/scripts/weather.scm | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index ca21857a31..9a5b5f7fbe 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10830,6 +10830,9 @@ specified in @var{file}. @var{file} must contain a @dfn{manifest}, as with the @code{-m} option of @command{guix package} (@pxref{Invoking guix package}). +This option can be repeated several times, in which case the manifests +are concatenated. + @item --coverage[=@var{count}] @itemx -c [@var{count}] Report on substitute coverage for packages: list packages with at least diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 60915d3451..733986be0c 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -499,17 +499,19 @@ SERVER. Display information for packages with at least THRESHOLD dependents." (define (guix-weather . args) (define (package-list opts) ;; Return the package list specified by OPTS. - (let ((file (assoc-ref opts 'manifest)) - (base (filter-map (match-lambda - (('argument . spec) - (specification->package spec)) - (_ - #f)) - opts))) - (if (and (not file) (null? base)) + (let ((files (filter-map (match-lambda + (('manifest . file) file) + (_ #f)) + opts)) + (base (filter-map (match-lambda + (('argument . spec) + (specification->package spec)) + (_ + #f)) + opts))) + (if (and (null? files) (null? base)) (all-packages) - (append base - (if file (load-manifest file) '()))))) + (append base (append-map load-manifest files))))) (with-error-handling (parameterize ((current-terminal-columns (terminal-columns)) -- cgit 1.4.1 From be764b47ad1079df531f016c1946cbf98ff48c41 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 13 Mar 2020 10:53:49 +0100 Subject: weather: Exit with non-zero when coverage is below 100%. * guix/scripts/weather.scm (report-server-coverage): Return the coverage ratio. (guix-weather): Exit if and only if each server's coverage is 1. --- doc/guix.texi | 7 +++++-- guix/scripts/weather.scm | 29 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'doc') diff --git a/doc/guix.texi b/doc/guix.texi index 9a5b5f7fbe..8acae26b9a 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -10809,8 +10809,11 @@ guix weather @var{options}@dots{} [@var{packages}@dots{}] When @var{packages} is omitted, @command{guix weather} checks the availability of substitutes for @emph{all} the packages, or for those specified with @option{--manifest}; otherwise it only considers the specified packages. It -is also possible to query specific system types with @option{--system}. The -available options are listed below. +is also possible to query specific system types with @option{--system}. +@command{guix weather} exits with a non-zero code when the fraction of +available substitutes is below 100%. + +The available options are listed below. @table @code @item --substitute-urls=@var{urls} diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm index 733986be0c..913c84955e 100644 --- a/guix/scripts/weather.scm +++ b/guix/scripts/weather.scm @@ -178,7 +178,8 @@ about the derivations queued, as is the case with Hydra." (define* (report-server-coverage server items #:key display-missing?) "Report the subset of ITEMS available as substitutes on SERVER. -When DISPLAY-MISSING? is true, display the list of missing substitutes." +When DISPLAY-MISSING? is true, display the list of missing substitutes. +Return the coverage ratio, an exact number between 0 and 1." (define MiB (* (expt 2 20) 1.)) (format #t (G_ "looking for ~h store items on ~a...~%") @@ -267,7 +268,11 @@ are queued~%") (when (and display-missing? (not (null? missing))) (newline) (format #t (G_ "Substitutes are missing for the following items:~%")) - (format #t "~{ ~a~%~}" missing))))) + (format #t "~{ ~a~%~}" missing)) + + ;; Return the coverage ratio. + (let ((total (length items))) + (/ (- total (length missing)) total))))) ;;; @@ -538,16 +543,20 @@ SERVER. Display information for packages with at least THRESHOLD dependents." (lambda (system) (package-outputs packages system)) systems)))))) - (for-each (lambda (server) + (exit + (every (lambda (server) + (define coverage (report-server-coverage server items #:display-missing? - (assoc-ref opts 'display-missing?)) - (match (assoc-ref opts 'coverage) - (#f #f) - (threshold - (report-package-coverage server packages systems - #:threshold threshold)))) - urls))))) + (assoc-ref opts 'display-missing?))) + (match (assoc-ref opts 'coverage) + (#f #f) + (threshold + (report-package-coverage server packages systems + #:threshold threshold))) + + (= 1 coverage)) + urls)))))) ;;; Local Variables: ;;; eval: (put 'let/time 'scheme-indent-function 1) -- cgit 1.4.1 From 39356057bce20f74120b6d227567a943556717cc Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Wed, 11 Mar 2020 15:31:59 -0400 Subject: doc: Update guidance about Python 2 package variants. * doc/contributing.texi (Python Modules): Don't recommend adding Python-2 package variants by default. --- doc/contributing.texi | 11 ++++++----- doc/guix.texi | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/contributing.texi b/doc/contributing.texi index afcc030b4f..31b875f817 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -612,11 +612,12 @@ To avoid confusion and naming clashes with other programming languages, it seems desirable that the name of a package for a Python module contains the word @code{python}. -Some modules are compatible with only one version of Python, others with both. -If the package Foo compiles only with Python 3, we name it -@code{python-foo}; if it compiles only with Python 2, we name it -@code{python2-foo}. If it is compatible with both versions, we create two -packages with the corresponding names. +Some modules are compatible with only one version of Python, others with +both. If the package Foo is compiled with Python 3, we name it +@code{python-foo}. If it is compiled with Python 2, we name it +@code{python2-foo}. Packages should be added when they are necessary; +we don't add Python 2 variants of the package unless we are going to use +them. If a project already contains the word @code{python}, we drop this; for instance, the module python-dateutil is packaged under the names diff --git a/doc/guix.texi b/doc/guix.texi index 8acae26b9a..4658c6f5eb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -28,7 +28,7 @@ Copyright @copyright{} 2014, 2015, 2016 Alex Kost@* Copyright @copyright{} 2015, 2016 Mathieu Lirzin@* Copyright @copyright{} 2014 Pierre-Antoine Rault@* Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@* -Copyright @copyright{} 2015, 2016, 2017, 2019 Leo Famulari@* +Copyright @copyright{} 2015, 2016, 2017, 2019, 2020 Leo Famulari@* Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@* Copyright @copyright{} 2016 Ben Woodcroft@* Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@* -- cgit 1.4.1