From 7dee475589868bf16b2ad2ef93511be8efb2c77a Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Wed, 15 Jul 2020 10:26:35 +0300 Subject: build/cargo-utils: Use all allocated threads to generate checksums. * guix/build/cargo-utils.scm (generate-all-checksums): Use n-par-for-each instead of for-each when regenerating checksums for source crates. --- guix/build/cargo-utils.scm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/build/cargo-utils.scm b/guix/build/cargo-utils.scm index 5ac429a62a..7a3bb4b843 100644 --- a/guix/build/cargo-utils.scm +++ b/guix/build/cargo-utils.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2016 David Craven ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2019 Ivan Petkov -;;; Copyright © 2019 Efraim Flashner +;;; Copyright © 2019, 2020 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,6 +23,7 @@ (define-module (guix build cargo-utils) #:use-module (guix build utils) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) + #:use-module (ice-9 threads) #:export (generate-checksums generate-all-checksums)) @@ -70,7 +71,7 @@ (define (generate-checksums dir-name) (display "}" port))))) (define (generate-all-checksums dir-name) - (for-each + (n-par-for-each (parallel-job-count) (lambda (filename) (let* ((dir (dirname filename)) (checksum-file (string-append dir "/.cargo-checksum.json"))) -- cgit v1.2.3 From a13f45c1505fb4cf02dcbd3a80df90cc3edbb9ca Mon Sep 17 00:00:00 2001 From: Guillaume Le Vaillant Date: Mon, 7 Sep 2020 14:57:57 +0200 Subject: build-system: asdf: Switch from bundles to regular compilation. * gnu/packages/lisp.scm (sbcl, ecl)[native-search-paths]: Add 'XDG_CONFIG_DIRS'. * guix/build-system/asdf.scm (asdf-build): Replace 'asd-file' and 'asd-system-name' keywords by 'asd-files' and 'asd-systems'. * guix/build/asdf-build-system.scm (%object-prefix, %lisp-source-install-prefix): Update variables. (install): Update variable. (main-system-name): New variable. (copy-source): Replace 'asd-file' and 'asd-system-name' keywords by 'asd-files' and 'asd-systems'. (configure): New variable. (build, check): Replace 'asd-file' and 'asd-system-name' keywords by 'asd-files' and 'asd-systems'. (create-asd-file, symlink-asd-files): Remove variables. (create-asdf-configuration): New variable. (cleanup-files): Update variable. (%standard-phases): Remove 'create-asd-file' and 'symlink-asd-files' phases. Add 'configure' and 'create-asdf-configuration' phases. * guix/build/lisp-utils.scm (%bundle-install-prefix, normalize-dependency, inputs->asd-file-map, asdf-load-all, compile-system): Remove variables. (compile-systems): New variable. (system-dependencies, compiled-system, generate-system-definition): Remove variable. (test-system): Replace 'asd-file' parameter by 'asd-files'. (generate-executable-for-system): Update variable. (generate-dependency-links, make-asd-file, bundle-asd-file): Remove variables. (make-asdf-configuration): New variable. (build-program, build-image): Set 'XDG_CONFIG_DIRS'. (generate-executable): Update variable. --- gnu/packages/lisp.scm | 10 +- guix/build-system/asdf.scm | 38 ++++-- guix/build/asdf-build-system.scm | 163 +++++++++++--------------- guix/build/lisp-utils.scm | 245 +++++++++------------------------------ 4 files changed, 160 insertions(+), 296 deletions(-) (limited to 'guix') diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm index df901aa34f..d2730f3bda 100644 --- a/gnu/packages/lisp.scm +++ b/gnu/packages/lisp.scm @@ -298,7 +298,10 @@ (define-public ecl (native-search-paths (list (search-path-specification (variable "XDG_DATA_DIRS") - (files '("share"))))) + (files '("share"))) + (search-path-specification + (variable "XDG_CONFIG_DIRS") + (files '("etc"))))) (home-page "http://ecls.sourceforge.net/") (synopsis "Embeddable Common Lisp") (description "ECL is an implementation of the Common Lisp language as @@ -546,7 +549,10 @@ (define (quoted-path input path) (native-search-paths (list (search-path-specification (variable "XDG_DATA_DIRS") - (files '("share"))))) + (files '("share"))) + (search-path-specification + (variable "XDG_CONFIG_DIRS") + (files '("etc"))))) (home-page "http://www.sbcl.org/") (synopsis "Common Lisp implementation") (description "Steel Bank Common Lisp (SBCL) is a high performance Common diff --git a/guix/build-system/asdf.scm b/guix/build-system/asdf.scm index 630b99e2bf..334a119948 100644 --- a/guix/build-system/asdf.scm +++ b/guix/build-system/asdf.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017 Andy Patterson -;;; Copyright © 2019 Guillaume Le Vaillant +;;; Copyright © 2019, 2020 Guillaume Le Vaillant ;;; ;;; This file is part of GNU Guix. ;;; @@ -54,12 +54,14 @@ (define %asdf-build-system-modules ;; Imported build-side modules `((guix build asdf-build-system) (guix build lisp-utils) + (guix build union) ,@%gnu-build-system-modules)) (define %asdf-build-modules ;; Used (visible) build-side modules '((guix build asdf-build-system) (guix build utils) + (guix build union) (guix build lisp-utils))) (define (default-lisp implementation) @@ -210,7 +212,7 @@ (define (new-inputs inputs-getter) (define base-arguments (if target-is-source? (strip-keyword-arguments - '(#:tests? #:asd-file #:lisp #:asd-system-name #:test-asd-file) + '(#:tests? #:asd-files #:lisp #:asd-systems #:test-asd-file) (package-arguments pkg)) (package-arguments pkg))) @@ -278,8 +280,8 @@ (define (asdf-build lisp-type) (lambda* (store name inputs #:key source outputs (tests? #t) - (asd-file #f) - (asd-system-name #f) + (asd-files ''()) + (asd-systems ''()) (test-asd-file #f) (phases '(@ (guix build asdf-build-system) %standard-phases)) @@ -289,12 +291,24 @@ (define (asdf-build lisp-type) (imported-modules %asdf-build-system-modules) (modules %asdf-build-modules)) - (define system-name - (or asd-system-name - (string-drop - ;; NAME is the value returned from `package-full-name'. - (hyphen-separated-name->name+version name) - (1+ (string-length lisp-type))))) ; drop the "-" prefix. + ;; FIXME: The definitions of 'systems' and 'files' are pretty hacky. + ;; Is there a more elegant way to do it? + (define systems + (if (null? (cadr asd-systems)) + `(quote + ,(list + (string-drop + ;; NAME is the value returned from `package-full-name'. + (hyphen-separated-name->name+version name) + (1+ (string-length lisp-type))))) ; drop the "-" prefix. + asd-systems)) + + (define files + (if (null? (cadr asd-files)) + `(quote ,(map (lambda (system) + (string-append system ".asd")) + (cadr systems))) + asd-files)) (define builder `(begin @@ -309,8 +323,8 @@ (define builder (derivation->output-path source)) ((source) source) (source source)) - #:asd-file ,(or asd-file (string-append system-name ".asd")) - #:asd-system-name ,system-name + #:asd-files ,files + #:asd-systems ,systems #:test-asd-file ,test-asd-file #:system ,system #:tests? ,tests? diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm index 25dd031962..b7957e7fc5 100644 --- a/guix/build/asdf-build-system.scm +++ b/guix/build/asdf-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017 Andy Patterson +;;; Copyright © 2020 Guillaume Le Vaillant ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +20,7 @@ (define-module (guix build asdf-build-system) #:use-module ((guix build gnu-build-system) #:prefix gnu:) #:use-module (guix build utils) + #:use-module (guix build union) #:use-module (guix build lisp-utils) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) @@ -41,14 +43,22 @@ (define-module (guix build asdf-build-system) ;; ;; Code: -(define %object-prefix "/lib") +(define %object-prefix "/lib/common-lisp") (define (%lisp-source-install-prefix) - (string-append %source-install-prefix "/" (%lisp-type) "-source")) + (string-append %source-install-prefix "/" (%lisp-type))) (define %system-install-prefix (string-append %source-install-prefix "/systems")) +(define (main-system-name output) + (let ((package-name (package-name->name+version + (strip-store-file-name output))) + (lisp-prefix (string-append (%lisp-type) "-"))) + (if (string-prefix? lisp-prefix package-name) + (string-drop package-name (string-length lisp-prefix)) + package-name))) + (define (lisp-source-directory output name) (string-append output (%lisp-source-install-prefix) "/" name)) @@ -126,8 +136,7 @@ (define parent-source (and parent (string-append parent "/share/common-lisp/" (string-take parent-name - (string-index parent-name #\-)) - "-source"))) + (string-index parent-name #\-))))) (define (first-subdirectory directory) ; From gnu-build-system. "Return the file name of the first sub-directory of DIRECTORY." @@ -146,122 +155,87 @@ (define source-directory (with-directory-excursion source-directory (copy-files-to-output output package-name))) -(define* (copy-source #:key outputs asd-system-name #:allow-other-keys) +(define* (copy-source #:key outputs asd-systems #:allow-other-keys) "Copy the source to the library output." (let* ((out (library-output outputs)) - (install-path (string-append out %source-install-prefix))) - (copy-files-to-output out asd-system-name) + (install-path (string-append out %source-install-prefix)) + (system-name (main-system-name out))) + (copy-files-to-output out system-name) ;; Hide the files from asdf (with-directory-excursion install-path - (rename-file "source" (string-append (%lisp-type) "-source")) + (rename-file "source" (%lisp-type)) (delete-file-recursively "systems"))) #t) -(define* (build #:key outputs inputs asd-file asd-system-name +(define* (configure #:key inputs #:allow-other-keys) + ;; Create a directory having the configuration files for + ;; all the dependencies in 'etc/common-lisp/'. + (let ((out (string-append (getcwd) "/.cl-union"))) + (match inputs + (((name . directories) ...) + (union-build out (filter directory-exists? directories) + #:create-all-directories? #t + #:log-port (%make-void-port "w")))) + (setenv "CL_UNION" out) + (setenv "XDG_CONFIG_DIRS" (string-append out "/etc"))) + #t) + +(define* (build #:key outputs inputs asd-files asd-systems #:allow-other-keys) "Compile the system." (let* ((out (library-output outputs)) - (source-path (lisp-source-directory out asd-system-name)) + (system-name (main-system-name out)) + (source-path (string-append out (%lisp-source-install-prefix))) (translations (wrap-output-translations `(,(output-translation source-path out)))) - (asd-file (source-asd-file out asd-system-name asd-file))) - + (asd-files (map (lambda (asd-file) + (source-asd-file out system-name asd-file)) + asd-files))) (setenv "ASDF_OUTPUT_TRANSLATIONS" (replace-escaped-macros (format #f "~S" translations))) - (setenv "HOME" out) ; ecl's asdf sometimes wants to create $HOME/.cache - - (compile-system asd-system-name asd-file) - - ;; As above, ecl will sometimes create this even though it doesn't use it - - (let ((cache-directory (string-append out "/.cache"))) - (when (directory-exists? cache-directory) - (delete-file-recursively cache-directory)))) + (compile-systems asd-systems asd-files)) #t) -(define* (check #:key tests? outputs inputs asd-file asd-system-name +(define* (check #:key tests? outputs inputs asd-files asd-systems test-asd-file #:allow-other-keys) "Test the system." (let* ((out (library-output outputs)) - (asd-file (source-asd-file out asd-system-name asd-file)) + (system-name (main-system-name out)) + (asd-files (map (lambda (asd-file) + (source-asd-file out system-name asd-file)) + asd-files)) (test-asd-file (and=> test-asd-file - (cut source-asd-file out asd-system-name <>)))) + (cut source-asd-file out system-name <>)))) (if tests? - (test-system asd-system-name asd-file test-asd-file) + (test-system (first asd-systems) asd-files test-asd-file) (format #t "test suite not run~%"))) #t) -(define* (create-asd-file #:key outputs - inputs - asd-file - asd-system-name - #:allow-other-keys) - "Create a system definition file for the built system." - (let*-values (((out) (library-output outputs)) - ((_ version) (package-name->name+version - (strip-store-file-name out))) - ((new-asd-file) (string-append - (library-directory out) - "/" (normalize-string asd-system-name) - ".asd"))) - - (make-asd-file new-asd-file - #:system asd-system-name - #:version version - #:inputs inputs - #:system-asd-file asd-file)) - #t) - -(define* (symlink-asd-files #:key outputs #:allow-other-keys) - "Create an extra reference to the system in a convenient location." - (let* ((out (library-output outputs))) - (for-each - (lambda (asd-file) - (receive (new-asd-file asd-file-directory) - (bundle-asd-file out asd-file) - (mkdir-p asd-file-directory) - (symlink asd-file new-asd-file) - ;; Update the source registry for future phases which might want to - ;; use the newly compiled system. - (prepend-to-source-registry - (string-append asd-file-directory "/")))) - - (find-files (string-append out %object-prefix) "\\.asd$"))) - #t) +(define* (create-asdf-configuration #:key inputs outputs #:allow-other-keys) + "Create the ASDF configuration files for the built systems." + (let* ((system-name (main-system-name (assoc-ref outputs "out"))) + (out (library-output outputs)) + (conf-dir (string-append out "/etc/common-lisp")) + (deps-conf-dir (string-append (getenv "CL_UNION") "/etc/common-lisp")) + (source-dir (lisp-source-directory out system-name)) + (lib-dir (string-append (library-directory out) "/" system-name))) + (make-asdf-configuration system-name conf-dir deps-conf-dir + source-dir lib-dir) + #t)) (define* (cleanup-files #:key outputs #:allow-other-keys) "Remove any compiled files which are not a part of the final bundle." - (let ((out (library-output outputs))) - (match (%lisp-type) - ("sbcl" - (for-each - (lambda (file) - (unless (string-suffix? "--system.fasl" file) - (delete-file file))) - (find-files out "\\.fasl$"))) - ("ecl" - (for-each delete-file - (append (find-files out "\\.fas$") - (find-files out "\\.o$"))))) - - (with-directory-excursion (library-directory out) - (for-each - (lambda (file) - (rename-file file - (string-append "./" (basename file)))) - (find-files ".")) - (for-each delete-file-recursively - (scandir "." - (lambda (file) - (and - (directory-exists? file) - (string<> "." file) - (string<> ".." file))))))) + (let* ((out (library-output outputs)) + (cache-directory (string-append out "/.cache"))) + ;; Remove the cache directory in case the lisp implementation wrote + ;; something in there when compiling or testing a system. + (when (directory-exists? cache-directory) + (delete-file-recursively cache-directory))) #t) (define* (strip #:rest args) @@ -280,15 +254,14 @@ (define %standard-phases/source (define %standard-phases (modify-phases gnu:%standard-phases (delete 'bootstrap) - (delete 'configure) - (delete 'install) + (replace 'configure configure) + (add-before 'configure 'copy-source copy-source) (replace 'build build) - (add-before 'build 'copy-source copy-source) (replace 'check check) - (replace 'strip strip) - (add-after 'check 'create-asd-file create-asd-file) - (add-after 'create-asd-file 'cleanup cleanup-files) - (add-after 'cleanup 'create-symlinks symlink-asd-files))) + (add-after 'check 'create-asdf-configuration create-asdf-configuration) + (add-after 'create-asdf-configuration 'cleanup cleanup-files) + (delete 'install) + (replace 'strip strip))) (define* (asdf-build #:key inputs (phases %standard-phases) diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm index f6d9168c48..8a02cb68dd 100644 --- a/guix/build/lisp-utils.scm +++ b/guix/build/lisp-utils.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017 Andy Patterson +;;; Copyright © 2020 Guillaume Le Vaillant ;;; ;;; This file is part of GNU Guix. ;;; @@ -28,19 +29,17 @@ (define-module (guix build lisp-utils) %lisp-type %source-install-prefix lisp-eval-program - compile-system + compile-systems test-system replace-escaped-macros generate-executable-wrapper-system generate-executable-entry-point generate-executable-for-system - %bundle-install-prefix - bundle-asd-file wrap-output-translations prepend-to-source-registry build-program build-image - make-asd-file + make-asdf-configuration valid-char-set normalize-string library-output)) @@ -65,9 +64,6 @@ (define %lisp-type ;; link farm for system definition (.asd) files. (define %source-install-prefix "/share/common-lisp") -(define (%bundle-install-prefix) - (string-append %source-install-prefix "/" (%lisp-type) "-bundle-systems")) - (define (library-output outputs) "If a `lib' output exists, build things there. Otherwise use `out'." (or (assoc-ref outputs "lib") (assoc-ref outputs "out"))) @@ -81,38 +77,6 @@ (define (normalize-string str) "Replace invalid characters in STR with a hyphen." (string-join (string-tokenize str valid-char-set) "-")) -(define (normalize-dependency dependency) - "Normalize the name of DEPENDENCY. Handles dependency definitions of the -dependency-def form described by -. -Assume that any symbols in DEPENDENCY will be in upper-case." - (match dependency - ((':VERSION name rest ...) - `(:version ,(normalize-string name) ,@rest)) - ((':FEATURE feature-specification dependency-specification) - `(:feature - ,feature-specification - ,(normalize-dependency dependency-specification))) - ((? string? name) (normalize-string name)) - (require-specification require-specification))) - -(define (inputs->asd-file-map inputs) - "Produce a hash table of the form (system . asd-file), where system is the -name of an ASD system, and asd-file is the full path to its definition." - (alist->hash-table - (filter-map - (match-lambda - ((_ . path) - (let ((prefix (string-append path (%bundle-install-prefix)))) - (and (directory-exists? prefix) - (match (find-files prefix "\\.asd$") - ((asd-file) - (cons - (string-drop-right (basename asd-file) 4) ; drop ".asd" - asd-file)) - (_ #f)))))) - inputs))) - (define (wrap-output-translations translations) `(:output-translations ,@translations @@ -143,70 +107,26 @@ (define (lisp-invocation program) "--eval" "(quit)")) (_ (error "The LISP provided is not supported at this time.")))) -(define (asdf-load-all systems) - (map (lambda (system) - `(asdf:load-system ,system)) - systems)) - -(define (compile-system system asd-file) - "Use a lisp implementation to compile SYSTEM using asdf. Load ASD-FILE -first." +(define (compile-systems systems asd-files) + "Use a lisp implementation to compile the SYSTEMS using asdf. +Load ASD-FILES first." (lisp-eval-program `((require :asdf) - (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) - (asdf:operate 'asdf:compile-bundle-op ,system)))) - -(define (system-dependencies system asd-file) - "Return the dependencies of SYSTEM, as reported by -asdf:system-depends-on. First load the system's ASD-FILE." - (define deps-file ".deps.sexp") - (define program - `((require :asdf) - (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) - (with-open-file - (stream ,deps-file :direction :output) - (format stream - "~s~%" - (asdf:system-depends-on - (asdf:find-system ,system)))))) - - (dynamic-wind - (lambda _ - (lisp-eval-program program)) - (lambda _ - (call-with-input-file deps-file read)) - (lambda _ - (when (file-exists? deps-file) - (delete-file deps-file))))) - -(define (compiled-system system) - (let ((system (basename system))) ; this is how asdf handles slashes - (match (%lisp-type) - ("sbcl" (string-append system "--system")) - (_ system)))) - -(define* (generate-system-definition system - #:key version dependencies component?) - `(asdf:defsystem - ,(normalize-string system) - ,@(if component? - '(:class asdf/bundle:prebuilt-system) - '()) - :version ,version - :depends-on ,dependencies - ,@(if component? - `(:components ((:compiled-file ,(compiled-system system)))) - '()) - ,@(if (string=? "ecl" (%lisp-type)) - `(:lib ,(string-append system ".a")) - '()))) - -(define (test-system system asd-file test-asd-file) - "Use a lisp implementation to test SYSTEM using asdf. Load ASD-FILE first. + ,@(map (lambda (asd-file) + `(asdf:load-asd (truename ,asd-file))) + asd-files) + ,@(map (lambda (system) + `(asdf:compile-system ,system)) + systems)))) + +(define (test-system system asd-files test-asd-file) + "Use a lisp implementation to test SYSTEM using asdf. Load ASD-FILES first. Also load TEST-ASD-FILE if necessary." (lisp-eval-program `((require :asdf) - (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) + ,@(map (lambda (asd-file) + `(asdf:load-asd (truename ,asd-file))) + asd-files) ,@(if test-asd-file `((asdf:load-asd (truename ,test-asd-file))) ;; Try some likely files. @@ -237,6 +157,7 @@ (define* (generate-executable-for-system type system #:key compress?) :executable t :compression t)) '()) + (asdf:load-asd (truename ,(string-append system "-exec.asd"))) (asdf:operate ',type ,(string-append system "-exec"))))) (define (generate-executable-wrapper-system system dependencies) @@ -271,79 +192,30 @@ (define (generate-executable-entry-point system entry-program) (declare (ignorable arguments)) ,@entry-program)))))))) -(define (generate-dependency-links registry system) - "Creates a program which populates asdf's source registry from REGISTRY, an -alist of dependency names to corresponding asd files. This allows the system -to locate its dependent systems." - `(progn - (asdf/source-registry:ensure-source-registry) - ,@(map (match-lambda - ((name . asd-file) - `(setf - (gethash ,name - asdf/source-registry:*source-registry*) - ,(string->symbol "#p") - ,asd-file))) - registry))) - -(define* (make-asd-file asd-file - #:key system version inputs - (system-asd-file #f)) - "Create an ASD-FILE for SYSTEM@VERSION, appending a program to allow the -system to find its dependencies, as described by GENERATE-DEPENDENCY-LINKS." - (define dependencies - (let ((deps - (system-dependencies system system-asd-file))) - (if (eq? 'NIL deps) - '() - (map normalize-dependency deps)))) - - (define lisp-input-map - (inputs->asd-file-map inputs)) - - (define dependency-name - (match-lambda - ((':version name _ ...) name) - ((':feature _ dependency-specification) - (dependency-name dependency-specification)) - ((? string? name) name) - (_ #f))) - - (define registry - (filter-map hash-get-handle - (make-list (length dependencies) - lisp-input-map) - (map dependency-name dependencies))) - - ;; Ensure directory exists, which might not be the case for an .asd without components. - (mkdir-p (dirname asd-file)) - (call-with-output-file asd-file - (lambda (port) - (display - (replace-escaped-macros - (format #f "~y~%~y~%" - (generate-system-definition - system - #:version version - #:dependencies dependencies - ;; Some .asd don't have components, and thus they don't generate any .fasl. - #:component? (match (%lisp-type) - ("sbcl" (pair? (find-files (dirname asd-file) - "--system\\.fasl$"))) - ("ecl" (pair? (find-files (dirname asd-file) - "\\.fasb$"))) - (_ (error "The LISP provided is not supported at this time.")))) - (generate-dependency-links registry system))) - port)))) - -(define (bundle-asd-file output-path original-asd-file) - "Find the symlinked bundle file for ORIGINAL-ASD-FILE by looking in -OUTPUT-PATH/share/common-lisp/LISP-bundle-systems/.asd. Returns two -values: the asd file itself and the directory in which it resides." - (let ((bundle-asd-path (string-append output-path - (%bundle-install-prefix)))) - (values (string-append bundle-asd-path "/" (basename original-asd-file)) - bundle-asd-path))) +(define (make-asdf-configuration name conf-dir deps-conf-dir source-dir lib-dir) + (let ((registry-dir (string-append + conf-dir "/source-registry.conf.d")) + (translations-dir (string-append + conf-dir "/asdf-output-translations.conf.d")) + (deps-registry-dir (string-append + deps-conf-dir "/source-registry.conf.d")) + (deps-translations-dir (string-append + deps-conf-dir + "/asdf-output-translations.conf.d"))) + (mkdir-p registry-dir) + (when (directory-exists? deps-registry-dir) + (copy-recursively deps-registry-dir registry-dir)) + (with-output-to-file (string-append registry-dir "/50-" name ".conf") + (lambda _ + (format #t "~y~%" `(:tree ,source-dir)))) + + (mkdir-p translations-dir) + (when (directory-exists? deps-translations-dir) + (copy-recursively deps-translations-dir translations-dir)) + (with-output-to-file (string-append translations-dir "/50-" name ".conf") + (lambda _ + (format #t "~y~%" `((,source-dir :**/ :*.*.*) + (,lib-dir :**/ :*.*.*))))))) (define (replace-escaped-macros string) "Replace simple lisp forms that the guile writer escapes, for example by @@ -368,6 +240,7 @@ (define* (build-program program outputs #:key has been bound to the command-line arguments which were passed. Link in any asd files from DEPENDENCY-PREFIXES to ensure references to those libraries are retained." + (setenv "XDG_CONFIG_DIRS" (string-append (library-output outputs) "/etc")) (generate-executable program #:dependencies dependencies #:dependency-prefixes dependency-prefixes @@ -388,6 +261,7 @@ (define* (build-image image outputs #:key "Generate an image, possibly standalone, which contains all DEPENDENCIES, placing the result in IMAGE.image. Link in any asd files from DEPENDENCY-PREFIXES to ensure references to those libraries are retained." + (setenv "XDG_CONFIG_DIRS" (string-append (library-output outputs) "/etc")) (generate-executable image #:dependencies dependencies #:dependency-prefixes dependency-prefixes @@ -416,20 +290,15 @@ (define* (generate-executable out-file #:key (mkdir-p bin-directory) (with-directory-excursion bin-directory (generate-executable-wrapper-system name dependencies) - (generate-executable-entry-point name entry-program)) - - (prepend-to-source-registry - (string-append bin-directory "/")) - - (setenv "ASDF_OUTPUT_TRANSLATIONS" - (replace-escaped-macros - (format - #f "~S" - (wrap-output-translations - `(((,bin-directory :**/ :*.*.*) - (,bin-directory :**/ :*.*.*))))))) - - (generate-executable-for-system type name #:compress? compress?) + (generate-executable-entry-point name entry-program) + (setenv "ASDF_OUTPUT_TRANSLATIONS" + (replace-escaped-macros + (format + #f "~S" + (wrap-output-translations + `(((,bin-directory :**/ :*.*.*) + (,bin-directory :**/ :*.*.*))))))) + (generate-executable-for-system type name #:compress? compress?)) (let* ((after-store-prefix-index (string-index out-file #\/ @@ -445,9 +314,11 @@ (define* (generate-executable out-file #:key (symlink asd-file (string-append hidden-asd-links "/" (basename asd-file)))) - (find-files (string-append path (%bundle-install-prefix)) + (find-files (string-append path %source-install-prefix "/" + (%lisp-type)) "\\.asd$"))) dependency-prefixes)) (delete-file (string-append bin-directory "/" name "-exec.asd")) - (delete-file (string-append bin-directory "/" name "-exec.lisp")))) + (delete-file (string-append bin-directory "/" name "-exec.lisp")) + (delete-file (string-append bin-directory "/" name "-exec.fasl")))) -- cgit v1.2.3 From 952fafb2a3c7a0978cc6a96268ad0632558b212d Mon Sep 17 00:00:00 2001 From: Guillaume Le Vaillant Date: Tue, 15 Sep 2020 14:36:24 +0200 Subject: build-system: asdf: Read all .asd files if no #:asd-files specified. * guix/build-system/asdf.scm (asdf-build): Remove the 'files' variable. * guix/build/asd-build-system.scm (find-asd-files): New variable. (build, check): Use it. --- guix/build-system/asdf.scm | 11 ++--------- guix/build/asdf-build-system.scm | 15 +++++++++------ 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'guix') diff --git a/guix/build-system/asdf.scm b/guix/build-system/asdf.scm index 334a119948..28403a1960 100644 --- a/guix/build-system/asdf.scm +++ b/guix/build-system/asdf.scm @@ -291,7 +291,7 @@ (define (asdf-build lisp-type) (imported-modules %asdf-build-system-modules) (modules %asdf-build-modules)) - ;; FIXME: The definitions of 'systems' and 'files' are pretty hacky. + ;; FIXME: The definition of 'systems' is pretty hacky. ;; Is there a more elegant way to do it? (define systems (if (null? (cadr asd-systems)) @@ -303,13 +303,6 @@ (define systems (1+ (string-length lisp-type))))) ; drop the "-" prefix. asd-systems)) - (define files - (if (null? (cadr asd-files)) - `(quote ,(map (lambda (system) - (string-append system ".asd")) - (cadr systems))) - asd-files)) - (define builder `(begin (use-modules ,@modules) @@ -323,7 +316,7 @@ (define builder (derivation->output-path source)) ((source) source) (source source)) - #:asd-files ,files + #:asd-files ,asd-files #:asd-systems ,systems #:test-asd-file ,test-asd-file #:system ,system diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm index b7957e7fc5..26d295e083 100644 --- a/guix/build/asdf-build-system.scm +++ b/guix/build/asdf-build-system.scm @@ -81,6 +81,13 @@ (define (output-translation source-path (define (source-asd-file output name asd-file) (string-append (lisp-source-directory output name) "/" asd-file)) +(define (find-asd-files output name asd-files) + (if (null? asd-files) + (find-files (lisp-source-directory output name) "\\.asd$") + (map (lambda (asd-file) + (source-asd-file output name asd-file)) + asd-files))) + (define (copy-files-to-output out name) "Copy all files from the current directory to OUT. Create an extra link to any system-defining files in the source to a convenient location. This is @@ -189,9 +196,7 @@ (define* (build #:key outputs inputs asd-files asd-systems (translations (wrap-output-translations `(,(output-translation source-path out)))) - (asd-files (map (lambda (asd-file) - (source-asd-file out system-name asd-file)) - asd-files))) + (asd-files (find-asd-files out system-name asd-files))) (setenv "ASDF_OUTPUT_TRANSLATIONS" (replace-escaped-macros (format #f "~S" translations))) (setenv "HOME" out) ; ecl's asdf sometimes wants to create $HOME/.cache @@ -204,9 +209,7 @@ (define* (check #:key tests? outputs inputs asd-files asd-systems "Test the system." (let* ((out (library-output outputs)) (system-name (main-system-name out)) - (asd-files (map (lambda (asd-file) - (source-asd-file out system-name asd-file)) - asd-files)) + (asd-files (find-asd-files out system-name asd-files)) (test-asd-file (and=> test-asd-file (cut source-asd-file out system-name <>)))) -- cgit v1.2.3 From b911d6547444b5f8d17b224bafa5ee1b5aafaff5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 15 Sep 2020 14:24:05 +0200 Subject: authenticate: Encode strings as ISO-8859-1. Fixes . * guix/scripts/authenticate.scm (read-command): Decode strings as ISO-8859-1, not UTF-8. (guix-authenticate)[send-reply]: Encode strings as ISO-8859-1, not UTF-8. * tests/guix-authenticate.sh: Add test. --- guix/scripts/authenticate.scm | 8 +++++--- tests/guix-authenticate.sh | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/guix/scripts/authenticate.scm b/guix/scripts/authenticate.scm index 0bac13edee..45f62f6ebc 100644 --- a/guix/scripts/authenticate.scm +++ b/guix/scripts/authenticate.scm @@ -31,6 +31,7 @@ (define-module (guix scripts authenticate) #:use-module (ice-9 rdelim) #:use-module (ice-9 match) #:use-module (ice-9 vlist) + #:use-module (ice-9 iconv) #:export (guix-authenticate)) ;;; Commentary: @@ -122,8 +123,9 @@ (define (consume-whitespace port) (reverse result)) (else (let* ((len (string->number (read-delimited ":" port))) - (str (utf8->string - (get-bytevector-n port len)))) + (str (bytevector->string + (get-bytevector-n port len) + "ISO-8859-1" 'error))) (loop (cons str result)))))))))) (define-syntax define-enumerate-type ;TODO: factorize @@ -150,7 +152,7 @@ (define-command (guix-authenticate . args) (define (send-reply code str) ;; Send CODE and STR as a reply to our client. - (let ((bv (string->utf8 str))) + (let ((bv (string->bytevector str "ISO-8859-1" 'error))) (format #t "~a ~a:" code (bytevector-length bv)) (put-bytevector (current-output-port) bv) (force-output (current-output-port)))) diff --git a/tests/guix-authenticate.sh b/tests/guix-authenticate.sh index f3b36ee41d..3a05b232c1 100644 --- a/tests/guix-authenticate.sh +++ b/tests/guix-authenticate.sh @@ -61,6 +61,15 @@ sed -i "$sig" \ code="$(echo "verify $(cat $sig)" | guix authenticate | cut -f1 -d ' ')" test "$code" -ne 0 +# Make sure byte strings are correctly encoded. The hash string below is +# "café" repeated 8 times. Libgcrypt would normally choose to write it as a +# string rather than a hex sequence. We want that string to be Latin-1 +# encoded independently of the current locale: . +hash="636166e9636166e9636166e9636166e9636166e9636166e9636166e9636166e9" +latin1_cafe="caf$(printf '\351')" +echo "sign 21:tests/signing-key.sec 64:$hash" | guix authenticate \ + | LC_ALL=C grep "hash sha256 \"$latin1_cafe" + # Test for : make sure 'guix authenticate' produces # valid signatures when run in the C locale. hash="5eff0b55c9c5f5e87b4e34cd60a2d5654ca1eb78c7b3c67c3179fed1cff07b4c" -- cgit v1.2.3 From 9d1af83e0b87cde6dd914eba8e2eeb84ceda3bc0 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Mon, 14 Sep 2020 09:18:39 +0200 Subject: import: cpan: Export cpan-release-module. * guix/import/cpan.scm: Fix typo. --- guix/import/cpan.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm index fd940415a2..514417f781 100644 --- a/guix/import/cpan.scm +++ b/guix/import/cpan.scm @@ -49,7 +49,7 @@ (define-module (guix import cpan) cpan-release-license cpan-release-author cpan-release-version - cpan-release-modle + cpan-release-module cpan-release-distribution cpan-release-download-url cpan-release-abstract -- cgit v1.2.3 From e0d9103f416d5c6e6c0c230f08dc9392bb8e8df1 Mon Sep 17 00:00:00 2001 From: Guillaume Le Vaillant Date: Tue, 15 Sep 2020 22:00:29 +0200 Subject: build-system: asdf: Improve install phase for CL source packages. * guix/build/asdf-build-system.scm (install)[parent-source]: Add support for package names not containing a hyphen. --- guix/build/asdf-build-system.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/guix/build/asdf-build-system.scm b/guix/build/asdf-build-system.scm index 26d295e083..6ad855cab2 100644 --- a/guix/build/asdf-build-system.scm +++ b/guix/build/asdf-build-system.scm @@ -124,9 +124,10 @@ (define package-name (package-name->name+version (strip-store-file-name output))) (define (no-prefix pkgname) - (if (string-index pkgname #\-) - (string-drop pkgname (1+ (string-index pkgname #\-))) - pkgname)) + (let ((index (string-index pkgname #\-))) + (if index + (string-drop pkgname (1+ index)) + pkgname))) (define parent (match (assoc package-name inputs (lambda (key alist-car) @@ -142,8 +143,10 @@ (define parent-name (define parent-source (and parent (string-append parent "/share/common-lisp/" - (string-take parent-name - (string-index parent-name #\-))))) + (let ((index (string-index parent-name #\-))) + (if index + (string-take parent-name index) + parent-name))))) (define (first-subdirectory directory) ; From gnu-build-system. "Return the file name of the first sub-directory of DIRECTORY." -- cgit v1.2.3 From d7f7ed39be3be926b3c46c0ea15d416c593ef61f Mon Sep 17 00:00:00 2001 From: Konrad Hinsen Date: Fri, 11 Sep 2020 13:13:26 +0200 Subject: repl: Look for script files in (getcwd). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * guix/scripts/repl.scm (guix-repl): Replace "." by (getcwd) * tests/guix-repl.sh: Add test. Co-authored-by: Ludovic Courtès --- guix/scripts/repl.scm | 5 ++++- tests/guix-repl.sh | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm index 3c79e89f8d..7d4e474e92 100644 --- a/guix/scripts/repl.scm +++ b/guix/scripts/repl.scm @@ -178,7 +178,10 @@ (define script (lambda () (set-program-arguments script) (set-user-module) - (load-in-vicinity "." (car script))))) + + ;; When passed a relative file name, 'load-in-vicinity' searches the + ;; file in %LOAD-PATH. Thus, pass (getcwd) instead of ".". + (load-in-vicinity (getcwd) (car script))))) (when (null? script) ;; Start REPL diff --git a/tests/guix-repl.sh b/tests/guix-repl.sh index e1c2b8241f..d4ebb5f6c6 100644 --- a/tests/guix-repl.sh +++ b/tests/guix-repl.sh @@ -45,6 +45,10 @@ EOF test "`guix repl "$tmpfile"`" = "coreutils" +# Make sure that the file can also be loaded when passed as a relative file +# name. +(cd "$(dirname "$tmpfile")"; test "$(guix repl "$(basename "$tmpfile")")" = "coreutils") + cat > "$module_dir/foo.scm"< Date: Sat, 19 Sep 2020 16:26:44 +0200 Subject: describe: Save the original value of (program-arguments). Fixes . Reported by pkill9 . This ensures that 'guix repl -s SCRIPT' give SCRIPT the right value of (current-profile), which in turn ensures that (%package-module-path) is initialized with the right set of channels. * guix/describe.scm (initial-program-arguments): New variable. (current-profile): Use it. * guix/scripts/repl.scm (guix-repl): Call 'current-profile' before 'set-program-arguments'. --- guix/describe.scm | 10 ++++++++-- guix/scripts/repl.scm | 8 ++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/describe.scm b/guix/describe.scm index 6b9b219113..05bf99eb58 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018, 2019 Ludovic Courtès +;;; Copyright © 2018, 2019, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -43,11 +43,17 @@ (define-module (guix describe) ;;; ;;; Code: +(define initial-program-arguments + ;; Save the initial program arguments. This allows us to see the "real" + ;; 'guix' program, even if 'guix repl -s' calls 'set-program-arguments' + ;; later on. + (program-arguments)) + (define current-profile (mlambda () "Return the profile (created by 'guix pull') the calling process lives in, or #f if this is not applicable." - (match (command-line) + (match initial-program-arguments ((program . _) (and (string-suffix? "/bin/guix" program) ;; Note: We want to do _lexical dot-dot resolution_. Using ".." diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm index 7d4e474e92..9f20803efc 100644 --- a/guix/scripts/repl.scm +++ b/guix/scripts/repl.scm @@ -27,6 +27,7 @@ (define-module (guix scripts repl) #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (rnrs bytevectors) + #:autoload (guix describe) (current-profile) #:autoload (system repl repl) (start-repl) #:autoload (system repl server) (make-tcp-server-socket make-unix-domain-server-socket) @@ -176,6 +177,13 @@ (define script ;; Run script (save-module-excursion (lambda () + ;; Invoke 'current-profile' so that it memoizes the correct value + ;; based on (program-arguments), before we call + ;; 'set-program-arguments'. This in turn ensures that + ;; (%package-module-path) will contain entries for the channels + ;; available in the current profile. + (current-profile) + (set-program-arguments script) (set-user-module) -- cgit v1.2.3 From 9b65281de51bcb56714509524f5ae0731c9b96d0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 14 Sep 2020 22:49:06 +0200 Subject: environment: '--link-profile' uses ~/.guix-profile for environment variables. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this patch, we had: $ guix environment -CP --ad-hoc coreutils [env]$ echo $PATH /gnu/store/…-profile/bin [env]$ echo $GUIX_ENVIRONMENT /gnu/store/…-profile After this patch: $ guix environment -CP --ad-hoc coreutils [env]$ echo $PATH /home/ludo/.guix-profile/bin [env]$ echo $GUIX_ENVIRONMENT /home/ludo/.guix-profile * guix/scripts/environment.scm (launch-environment/container): When LINK-PROFILE? is true, pass ~/.guix-profile as the second argument to 'launch-environment'. * tests/guix-environment-container.sh: Adjust test accordingly. * doc/guix.texi (Invoking guix environment): Update accordingly. --- doc/guix.texi | 5 +++-- guix/scripts/environment.scm | 6 +++++- tests/guix-environment-container.sh | 10 +++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index f7e2204b53..949551a163 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5420,8 +5420,9 @@ device. @item --link-profile @itemx -P For containers, link the environment profile to @file{~/.guix-profile} -within the container. This is equivalent to running the command -@samp{ln -s $GUIX_ENVIRONMENT ~/.guix-profile} within the container. +within the container and set @code{GUIX_ENVIRONMENT} to that. +This is equivalent to making @file{~/.guix-profile} a symlink to the +actual profile within the container. Linking will fail and abort the environment if the directory already exists, which will certainly be the case if @command{guix environment} was invoked in the user's home directory. diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index ad50281eb2..e2e481dd02 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -564,7 +564,11 @@ (define (optional-mapping->fs mapping) (primitive-exit/status ;; A container's environment is already purified, so no need to ;; request it be purified again. - (launch-environment command profile manifest #:pure? #f))) + (launch-environment command + (if link-profile? + (string-append home-dir "/.guix-profile") + profile) + manifest #:pure? #f))) #:guest-uid uid #:guest-gid gid #:namespaces (if network? diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 45264d4978..040f32cce9 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -127,11 +127,15 @@ grep -e "$NIX_STORE_DIR/.*-bash" $tmpdir/mounts # bootstrap bash rm $tmpdir/mounts -# Make sure 'GUIX_ENVIRONMENT' is linked to '~/.guix-profile' when requested +# Make sure 'GUIX_ENVIRONMENT' is set to '~/.guix-profile' when requested # within a container. ( - linktest='(exit (string=? (getenv "GUIX_ENVIRONMENT") -(readlink (string-append (getenv "HOME") "/.guix-profile"))))' + linktest=' +(exit (and (string=? (getenv "GUIX_ENVIRONMENT") + (string-append (getenv "HOME") "/.guix-profile")) + (string-prefix? "'"$NIX_STORE_DIR"'" + (readlink (string-append (getenv "HOME") + "/.guix-profile")))))' cd "$tmpdir" \ && guix environment --bootstrap --container --link-profile \ -- cgit v1.2.3 From 620681534a2a6f0505cb7a3e1b66e6c138b28769 Mon Sep 17 00:00:00 2001 From: zimoun Date: Wed, 16 Sep 2020 00:17:29 +0200 Subject: guix: scripts: build: Mention 'PACKAGE' in '--with-source' option. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/build.scm (show-transformation-options-help): Mention 'PACKAGE' in '--with-source' option. Co-authored-by: Ludovic Courtès --- guix/scripts/build.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 25418661b9..38e0516c95 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -427,7 +427,7 @@ (define %transformation-options (define (show-transformation-options-help) (display (G_ " - --with-source=SOURCE + --with-source=[PACKAGE=]SOURCE use SOURCE when building the corresponding package")) (display (G_ " --with-input=PACKAGE=REPLACEMENT -- cgit v1.2.3 From bd16cc2902800932f58a34647e224734aa3647cd Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Tue, 22 Sep 2020 15:24:10 +0200 Subject: import: Fix docstring typoes. * guix/import/cabal.scm (cabal-flags->alist): Fix typo in docstring. * guix/import/stackage.scm (lts-info-ghc-version): Likewise. * guix/scripts/import/hackage.scm (show-help): Likewise. --- guix/import/cabal.scm | 2 +- guix/import/stackage.scm | 4 ++-- guix/scripts/import/hackage.scm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'guix') diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index 7dfe771e41..da00019297 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -718,7 +718,7 @@ (define-record-type (dependencies cabal-custom-setup-dependencies)) ; list of (define (cabal-flags->alist flag-list) - "Retrun an alist associating the flag name to its default value from a + "Return an alist associating the flag name to its default value from a list of objects." (map (lambda (flag) (cons (cabal-flag-name flag) (cabal-flag-default flag))) flag-list)) diff --git a/guix/import/stackage.scm b/guix/import/stackage.scm index e04073d193..ee12108815 100644 --- a/guix/import/stackage.scm +++ b/guix/import/stackage.scm @@ -42,12 +42,12 @@ (define-module (guix import stackage) (define %stackage-url "http://www.stackage.org") (define (lts-info-ghc-version lts-info) - "Retruns the version of the GHC compiler contained in LTS-INFO." + "Returns the version of the GHC compiler contained in LTS-INFO." (and=> (assoc-ref lts-info "snapshot") (cut assoc-ref <> "ghc"))) (define (lts-info-packages lts-info) - "Retruns the alist of packages contained in LTS-INFO." + "Returns the alist of packages contained in LTS-INFO." (or (assoc-ref lts-info "packages") '())) (define (leave-with-message fmt . args) diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm index 710e786a79..906dca24b1 100644 --- a/guix/scripts/import/hackage.scm +++ b/guix/scripts/import/hackage.scm @@ -49,7 +49,7 @@ (define (show-help) Import and convert the Hackage package for PACKAGE-NAME. If PACKAGE-NAME includes a suffix constituted by a at-sign followed by a numerical version (as used with Guix packages), then a definition for the specified version of the -package will be generated. If no version suffix is pecified, then the +package will be generated. If no version suffix is specified, then the generated package definition will correspond to the latest available version.\n")) (display (G_ " -- cgit v1.2.3 From 9c4aaa630d97f9f29ca1b732fb265bd583e83e02 Mon Sep 17 00:00:00 2001 From: André Batista Date: Thu, 24 Sep 2020 21:29:49 -0300 Subject: licenses: Add Apple Public Source License 2.0. * guix/licenses.scm (apsl2): New variable. Signed-off-by: Mathieu Othacehe --- guix/licenses.scm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'guix') diff --git a/guix/licenses.scm b/guix/licenses.scm index bf72a33c92..5038f75638 100644 --- a/guix/licenses.scm +++ b/guix/licenses.scm @@ -14,6 +14,7 @@ ;;; Copyright © 2017 Marius Bakke ;;; Copyright © 2017 Arun Isaac ;;; Copyright © 2017 Rutger Helling +;;; Copyright © 2020 André Batista ;;; ;;; This file is part of GNU Guix. ;;; @@ -34,6 +35,7 @@ (define-module (guix licenses) #:use-module (srfi srfi-9) #:export (license? license-name license-uri license-comment agpl1 agpl3 agpl3+ + apsl2 asl1.1 asl2.0 boost1.0 bsd-2 bsd-3 bsd-4 @@ -132,6 +134,11 @@ (define agpl3+ "https://gnu.org/licenses/agpl.html" "https://gnu.org/licenses/why-affero-gpl.html")) +(define apsl2 + (license "APSL 2.0" + "https://directory.fsf.org/wiki/License:APSL-2.0" + "https://www.gnu.org/licenses/license-list.html#apsl2")) + (define asl1.1 (license "ASL 1.1" "http://directory.fsf.org/wiki/License:Apache1.1" -- cgit v1.2.3 From 4eeaae7994c6fb82e005acf290a3b81cba7bd871 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 24 Sep 2020 18:41:09 +0200 Subject: guix package: Simplify 'package->manifest-entry*'. * guix/scripts/package.scm (package->manifest-entry*): Rewrite in terms of 'manifest-entry-with-provenance'. --- guix/scripts/package.scm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'guix') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 4eb968a49b..7e7c37eac4 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -585,14 +585,8 @@ (define (store-item->manifest-entry item) (define (package->manifest-entry* package output) "Like 'package->manifest-entry', but attach PACKAGE provenance meta-data to the resulting manifest entry." - (define (provenance-properties package) - (match (package-provenance package) - (#f '()) - (sexp `((provenance ,@sexp))))) - - (package->manifest-entry package output - #:properties (provenance-properties package))) - + (manifest-entry-with-provenance + (package->manifest-entry package output))) (define (options->installable opts manifest transaction) "Given MANIFEST, the current manifest, and OPTS, the result of 'args-fold', -- cgit v1.2.3 From 795065533d3326e02326509d93d3bab7105d97a3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 25 Sep 2020 19:02:13 +0200 Subject: gnu: Replace uses of 'guile3.0-gnutls' by 'gnutls'. * gnu/packages/package-management.scm (guix)[propagated-inputs]: Use GNUTLS instead of GUILE3.0-GNUTLS. (guix-daemon)[inputs]: Likewise. * guix/self.scm (specification->package): Likewise. --- gnu/packages/package-management.scm | 4 ++-- guix/self.scm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index ec87226197..99f78f2ac8 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -384,7 +384,7 @@ (define code ("glibc-utf8-locales" ,glibc-utf8-locales))) (propagated-inputs - `(("gnutls" ,(if (%current-target-system) gnutls-3.6.14 guile3.0-gnutls)) + `(("gnutls" ,(if (%current-target-system) gnutls-3.6.14 gnutls)) ("guile-gcrypt" ,guile-gcrypt) ("guile-json" ,guile-json-4) ("guile-sqlite3" ,guile-sqlite3) @@ -418,7 +418,7 @@ (define-public guix-daemon (fold alist-delete (package-native-inputs guix) '("po4a" "graphviz" "help2man"))) (inputs - `(("gnutls" ,guile3.0-gnutls) + `(("gnutls" ,gnutls) ("guile-git" ,guile-git) ("guile-json" ,guile-json-3) ("guile-gcrypt" ,guile-gcrypt) diff --git a/guix/self.scm b/guix/self.scm index 02ef982c7c..5eb80f42fe 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -56,7 +56,7 @@ (define specification->package ("guile-zlib" (ref '(gnu packages guile) 'guile-zlib)) ("guile-lzlib" (ref '(gnu packages guile) 'guile-lzlib)) ("guile-gcrypt" (ref '(gnu packages gnupg) 'guile-gcrypt)) - ("gnutls" (ref '(gnu packages tls) 'guile3.0-gnutls)) + ("gnutls" (ref '(gnu packages tls) 'gnutls)) ("gzip" (ref '(gnu packages compression) 'gzip)) ("bzip2" (ref '(gnu packages compression) 'bzip2)) ("xz" (ref '(gnu packages compression) 'xz)) -- cgit v1.2.3 From f458cfbcc54ed87b1a87dd9e150ea276f17eab74 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 23 Sep 2020 22:29:17 +0200 Subject: guix build: Add '--without-tests'. * guix/scripts/build.scm (transform-package-tests): New procedure. (%transformations, %transformation-options) show-transformation-options-help): Add it. * tests/scripts-build.scm ("options->transformation, without-tests"): New test. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 22 ++++++++++++++++++++++ guix/scripts/build.scm | 31 ++++++++++++++++++++++++++++--- tests/scripts-build.scm | 14 ++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 538e7cceab..8384eee6c3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9271,6 +9271,28 @@ guix build --with-branch=guile-sqlite3=master cuirass This is similar to @option{--with-branch}, except that it builds from @var{commit} rather than the tip of a branch. @var{commit} must be a valid Git commit SHA1 identifier or a tag. + +@cindex test suite, skipping +@item --without-tests=@var{package} +Build @var{package} without running its tests. This can be useful in +situations where you want to skip the lengthy test suite of a +intermediate package, or if a package's test suite fails in a +non-deterministic fashion. It should be used with care because running +the test suite is a good way to ensure a package is working as intended. + +Turning off tests leads to a different store item. Consequently, when +using this option, anything that depends on @var{package} must be +rebuilt, as in this example: + +@example +guix install --without-tests=python python-notebook +@end example + +The command above installs @code{python-notebook} on top of +@code{python} built without running its test suite. To do so, it also +rebuilds everything that depends on @code{python}, including +@code{python-notebook} itself. + @end table @node Additional Build Options diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 38e0516c95..f238e9b876 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -393,6 +393,25 @@ (define rewrite (rewrite obj) obj))) +(define (transform-package-tests specs) + "Return a procedure that, when passed a package, sets #:tests? #f in its +'arguments' field." + (define (package-without-tests p) + (package/inherit p + (arguments + (substitute-keyword-arguments (package-arguments p) + ((#:tests? _ #f) #f))))) + + (define rewrite + (package-input-rewriting/spec (map (lambda (spec) + (cons spec package-without-tests)) + specs))) + + (lambda (store obj) + (if (package? obj) + (rewrite obj) + obj))) + (define %transformations ;; Transformations that can be applied to things to build. The car is the ;; key used in the option alist, and the cdr is the transformation @@ -403,7 +422,8 @@ (define %transformations (with-graft . ,transform-package-inputs/graft) (with-branch . ,transform-package-source-branch) (with-commit . ,transform-package-source-commit) - (with-git-url . ,transform-package-source-git-url))) + (with-git-url . ,transform-package-source-git-url) + (without-tests . ,transform-package-tests))) (define %transformation-options ;; The command-line interface to the above transformations. @@ -423,7 +443,9 @@ (define %transformation-options (option '("with-commit") #t #f (parser 'with-commit)) (option '("with-git-url") #t #f - (parser 'with-git-url))))) + (parser 'with-git-url)) + (option '("without-tests") #t #f + (parser 'without-tests))))) (define (show-transformation-options-help) (display (G_ " @@ -443,7 +465,10 @@ (define (show-transformation-options-help) build PACKAGE from COMMIT")) (display (G_ " --with-git-url=PACKAGE=URL - build PACKAGE from the repository at URL"))) + build PACKAGE from the repository at URL")) + (display (G_ " + --without-tests=PACKAGE + build PACKAGE without running its tests"))) (define (options->transformation opts) diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm index 32876e956a..12114fc8f5 100644 --- a/tests/scripts-build.scm +++ b/tests/scripts-build.scm @@ -264,5 +264,19 @@ (define-module (test-scripts-build) ((("x" dep3)) (map package-source (list dep1 dep3)))))))))))) +(test-assert "options->transformation, without-tests" + (let* ((dep (dummy-package "dep")) + (p (dummy-package "foo" + (inputs `(("dep" ,dep))))) + (t (options->transformation '((without-tests . "dep") + (without-tests . "tar"))))) + (with-store store + (let ((new (t store p))) + (match (bag-direct-inputs (package->bag new)) + ((("dep" dep) ("tar" tar) _ ...) + ;; TODO: Check whether TAR has #:tests? #f when transformations + ;; apply to implicit inputs. + (equal? (package-arguments dep) + '(#:tests? #f)))))))) (test-end) -- cgit v1.2.3 From ff39361c80dfc67a9afe35f315a774140d8cf99b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 21 Sep 2020 17:44:29 +0200 Subject: packages: 'package-mapping' can recurse on implicit inputs. * guix/packages.scm (build-system-with-package-mapping): New procedure. (package-mapping): Add #:deep? and honor it. * tests/packages.scm ("package-mapping"): Compare the direct inputs of the bag of P0 and that of P1. ("package-mapping, deep"): New test. --- doc/guix.texi | 5 +++-- guix/packages.scm | 65 +++++++++++++++++++++++++++++++++++++++++------------- tests/packages.scm | 36 +++++++++++++++++++++++++++++- 3 files changed, 88 insertions(+), 18 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 8384eee6c3..054449d8d6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6296,10 +6296,11 @@ A more generic procedure to rewrite a package dependency graph is @code{package-mapping}: it supports arbitrary changes to nodes in the graph. -@deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] +@deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f] Return a procedure that, given a package, applies @var{proc} to all the packages depended on and returns the resulting package. The procedure stops recursion -when @var{cut?} returns true for a given package. +when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is +applied to implicit inputs as well. @end deffn @menu diff --git a/guix/packages.scm b/guix/packages.scm index 6598bd3149..171fd048ef 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -968,10 +968,31 @@ (define* (package-closure packages #:key (system (%current-system))) (vhash-consq package #t visited) (fold set-insert closure dependencies)))))))) -(define* (package-mapping proc #:optional (cut? (const #f))) +(define (build-system-with-package-mapping bs rewrite) + "Return a variant of BS, a build system, that rewrites a bag's inputs by +passing them through REWRITE, a procedure that takes an input tuplet and +returns a \"rewritten\" input tuplet." + (define lower + (build-system-lower bs)) + + (define (lower* . args) + (let ((lowered (apply lower args))) + (bag + (inherit lowered) + (build-inputs (map rewrite (bag-build-inputs lowered))) + (host-inputs (map rewrite (bag-host-inputs lowered))) + (target-inputs (map rewrite (bag-target-inputs lowered)))))) + + (build-system + (inherit bs) + (lower lower*))) + +(define* (package-mapping proc #:optional (cut? (const #f)) + #:key deep?) "Return a procedure that, given a package, applies PROC to all the packages depended on and returns the resulting package. The procedure stops recursion -when CUT? returns true for a given package." +when CUT? returns true for a given package. When DEEP? is true, PROC is +applied to implicit inputs as well." (define (rewrite input) (match input ((label (? package? package) outputs ...) @@ -980,21 +1001,35 @@ (define (rewrite input) (_ input))) + (define mapping-property + ;; Property indicating whether the package has already been processed. + (gensym " package-mapping-done")) + (define replace (mlambdaq (p) - ;; Return a variant of P with PROC applied to P and its explicit - ;; dependencies, recursively. Memoize the transformations. Failing to - ;; do that, we would build a huge object graph with lots of duplicates, - ;; which in turns prevents us from benefiting from memoization in - ;; 'package-derivation'. - (let ((p (proc p))) - (package - (inherit p) - (location (package-location p)) - (inputs (map rewrite (package-inputs p))) - (native-inputs (map rewrite (package-native-inputs p))) - (propagated-inputs (map rewrite (package-propagated-inputs p))) - (replacement (and=> (package-replacement p) proc)))))) + ;; If P is the result of a previous call, return it. + (if (assq-ref (package-properties p) mapping-property) + p + + ;; Return a variant of P with PROC applied to P and its explicit + ;; dependencies, recursively. Memoize the transformations. Failing + ;; to do that, we would build a huge object graph with lots of + ;; duplicates, which in turns prevents us from benefiting from + ;; memoization in 'package-derivation'. + (let ((p (proc p))) + (package + (inherit p) + (location (package-location p)) + (build-system (if deep? + (build-system-with-package-mapping + (package-build-system p) rewrite) + (package-build-system p))) + (inputs (map rewrite (package-inputs p))) + (native-inputs (map rewrite (package-native-inputs p))) + (propagated-inputs (map rewrite (package-propagated-inputs p))) + (replacement (and=> (package-replacement p) proc)) + (properties `((,mapping-property . #t) + ,@(package-properties p)))))))) replace) diff --git a/tests/packages.scm b/tests/packages.scm index cbd0503733..f33332a461 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1172,15 +1172,24 @@ (define read-at (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) (p0 (dummy-package "example" + (source 77) (inputs `(("foo" ,coreutils) ("bar" ,grep) ("baz" ,dep))))) (transform (lambda (p) (package (inherit p) (source 42)))) (rewrite (package-mapping transform)) - (p1 (rewrite p0))) + (p1 (rewrite p0)) + (bag0 (package->bag p0)) + (bag1 (package->bag p1))) (and (eq? p1 (rewrite p0)) (eqv? 42 (package-source p1)) + + ;; Implicit inputs should be left unchanged (skip "source", "foo", + ;; "bar", and "baz" in this comparison). + (equal? (drop (bag-direct-inputs bag0) 4) + (drop (bag-direct-inputs bag1) 4)) + (match (package-inputs p1) ((("foo" dep1) ("bar" dep2) ("baz" dep3)) (and (eq? dep1 (rewrite coreutils)) ;memoization @@ -1194,6 +1203,31 @@ (define read-at (and (eq? dep (rewrite grep)) (package-source dep)))))))))) +(test-equal "package-mapping, deep" + '(42) + (let* ((p0 (dummy-package "example" + (inputs `(("foo" ,coreutils) + ("bar" ,grep))))) + (transform (lambda (p) + (package (inherit p) (source 42)))) + (rewrite (package-mapping transform #:deep? #t)) + (p1 (rewrite p0)) + (bag (package->bag p1))) + (and (eq? p1 (rewrite p0)) + (match (bag-direct-inputs bag) + ((("source" 42) ("foo" dep1) ("bar" dep2) rest ..1) + (and (eq? dep1 (rewrite coreutils)) ;memoization + (eq? dep2 (rewrite grep)) + (= 42 (package-source dep1)) + (= 42 (package-source dep2)) + + ;; Check that implicit inputs of P0 also got rewritten. + (delete-duplicates + (map (match-lambda + ((_ package . _) + (package-source package))) + rest)))))))) + (test-assert "package-input-rewriting" (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) -- cgit v1.2.3 From 2bf6f962b91123b0474c0f7123cd17efe7f09a66 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 23 Sep 2020 10:29:09 +0200 Subject: packages: 'package-input-rewriting/spec' can rewrite implicit dependencies. With this change, '--with-input', '--with-graft', etc. also apply to implicit dependencies. Thus, it's now possible to do: guix build python-itsdangerous --with-input=python-wrapper=python@2 or: guix build hello --with-graft=glibc=glibc@2.29 Additionally, before, implicit inputs were not rewritten, which could lead to duplicates in the output of 'bag-transitive-inputs' (packages that are not 'eq?' but lead to the same derivation). This in turn would lead to unnecessary rebuilds when using '--with-input' & co. This change fixes it by ensuring even implicit inputs are rewritten. Fixes . * guix/packages.scm (package-input-rewriting/spec): Add #:deep? defaulting to #true, and pass it to 'package-mapping'. [replacement-property]: New variable. [rewrite]: Check that property and set it on the result of PROC. [cut?]: New procedure. * tests/packages.scm ("package-input-rewriting/spec"): Ensure implicit inputs were unchanged. ("package-input-rewriting/spec, partial match"): Pass #:deep? #f. ("package-input-rewriting/spec, deep") ("package-input-rewriting/spec, no duplicates"): New tests. (package/inherit): Move before use. * tests/guix-build.sh: Add tests. * tests/scripts-build.scm ("options->transformation, with-graft"): Compare dependencies by package name or derivation file name. * doc/guix.texi (Defining Packages): Adjust accordingly. --- doc/guix.texi | 13 +++++----- guix/packages.scm | 55 ++++++++++++++++++++++++++--------------- tests/guix-build.sh | 11 +++++++++ tests/packages.scm | 66 ++++++++++++++++++++++++++++++++++++++++++++++--- tests/scripts-build.scm | 12 ++++++--- 5 files changed, 125 insertions(+), 32 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 054449d8d6..e72e1ec130 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6272,12 +6272,13 @@ This is exactly what the @option{--with-input} command-line option does The following variant of @code{package-input-rewriting} can match packages to be replaced by name rather than by identity. -@deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} -Return a procedure that, given a package, applies the given @var{replacements} to -all the package graph (excluding implicit inputs). @var{replacements} is a list of -spec/procedures pair; each spec is a package specification such as @code{"gcc"} or -@code{"guile@@2"}, and each procedure takes a matching package and returns a -replacement for that package. +@deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t] +Return a procedure that, given a package, applies the given +@var{replacements} to all the package graph, including implicit inputs +unless @var{deep?} is false. @var{replacements} is a list of +spec/procedures pair; each spec is a package specification such as +@code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching +package and returns a replacement for that package. @end deffn The example above could be rewritten this way: diff --git a/guix/packages.scm b/guix/packages.scm index 171fd048ef..f696945e30 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -422,6 +422,16 @@ (define-record-type* package) 16))))) +(define-syntax-rule (package/inherit p overrides ...) + "Like (package (inherit P) OVERRIDES ...), except that the same +transformation is done to the package replacement, if any. P must be a bare +identifier, and will be bound to either P or its replacement when evaluating +OVERRIDES." + (let loop ((p p)) + (package (inherit p) + overrides ... + (replacement (and=> (package-replacement p) loop))))) + (define (package-upstream-name package) "Return the upstream name of PACKAGE, which could be different from the name it has in Guix." @@ -1051,12 +1061,12 @@ (define (rewrite p) (package-mapping rewrite (cut assq <> replacements))) -(define (package-input-rewriting/spec replacements) +(define* (package-input-rewriting/spec replacements #:key (deep? #t)) "Return a procedure that, given a package, applies the given REPLACEMENTS to -all the package graph (excluding implicit inputs). REPLACEMENTS is a list of -spec/procedures pair; each spec is a package specification such as \"gcc\" or -\"guile@2\", and each procedure takes a matching package and returns a -replacement for that package." +all the package graph, including implicit inputs unless DEEP? is false. +REPLACEMENTS is a list of spec/procedures pair; each spec is a package +specification such as \"gcc\" or \"guile@2\", and each procedure takes a +matching package and returns a replacement for that package." (define table (fold (lambda (replacement table) (match replacement @@ -1081,22 +1091,27 @@ (define (find-replacement package) (package-name package) table)) - (define (rewrite package) - (match (find-replacement package) - (#f package) - (proc (proc package)))) - - (package-mapping rewrite find-replacement)) + (define replacement-property + (gensym " package-replacement")) -(define-syntax-rule (package/inherit p overrides ...) - "Like (package (inherit P) OVERRIDES ...), except that the same -transformation is done to the package replacement, if any. P must be a bare -identifier, and will be bound to either P or its replacement when evaluating -OVERRIDES." - (let loop ((p p)) - (package (inherit p) - overrides ... - (replacement (and=> (package-replacement p) loop))))) + (define (rewrite p) + (if (assq-ref (package-properties p) replacement-property) + p + (match (find-replacement p) + (#f p) + (proc + (let ((new (proc p))) + ;; Mark NEW as already processed. + (package/inherit new + (properties `((,replacement-property . #t) + ,@(package-properties new))))))))) + + (define (cut? p) + (or (assq-ref (package-properties p) replacement-property) + (find-replacement p))) + + (package-mapping rewrite cut? + #:deep? deep?)) ;;; diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 6c08857358..ec2f736ccb 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -259,6 +259,17 @@ drv1=`guix build guile -d` drv2=`guix build guile --with-input=gimp=ruby -d` test "$drv1" = "$drv2" +# See . +drv1=`guix build glib -d` +drv2=`guix build glib -d --with-input=libreoffice=inkscape` +test "$drv1" = "$drv2" + +# Rewriting implicit inputs. +drv1=`guix build hello -d` +drv2=`guix build hello -d --with-input=gcc=gcc-toolchain` +test "$drv1" != "$drv2" +guix gc -R "$drv2" | grep `guix build -d gcc-toolchain` + if guix build guile --with-input=libunistring=something-really-silly then false; else true; fi diff --git a/tests/packages.scm b/tests/packages.scm index f33332a461..6fa4ad2f1b 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -38,6 +38,7 @@ (define-module (test-packages) #:use-module (guix build-system) #:use-module (guix build-system trivial) #:use-module (guix build-system gnu) + #:use-module (guix build-system python) #:use-module (guix memoization) #:use-module (guix profiles) #:use-module (guix scripts package) @@ -45,6 +46,7 @@ (define-module (test-packages) #:use-module (gnu packages base) #:use-module (gnu packages guile) #:use-module (gnu packages bootstrap) + #:use-module (gnu packages python) #:use-module (gnu packages version-control) #:use-module (gnu packages xml) #:use-module (srfi srfi-1) @@ -1262,7 +1264,8 @@ (define read-at ("baz" ,dep))))) (rewrite (package-input-rewriting/spec `(("coreutils" . ,(const sed)) - ("grep" . ,(const findutils))))) + ("grep" . ,(const findutils))) + #:deep? #f)) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) @@ -1279,7 +1282,11 @@ (define read-at (match (package-native-inputs dep3) ((("x" dep)) (string=? (package-full-name dep) - (package-full-name findutils)))))))))) + (package-full-name findutils))))))) + + ;; Make sure implicit inputs were left unchanged. + (equal? (drop (bag-direct-inputs (package->bag p1)) 3) + (drop (bag-direct-inputs (package->bag p0)) 3))))) (test-assert "package-input-rewriting/spec, partial match" (let* ((dep (dummy-package "chbouib" @@ -1290,7 +1297,8 @@ (define read-at ("bar" ,dep))))) (rewrite (package-input-rewriting/spec `(("chbouib@123" . ,(const sed)) ;not matched - ("grep" . ,(const findutils))))) + ("grep" . ,(const findutils))) + #:deep? #f)) (p1 (rewrite p0))) (and (not (eq? p1 p0)) (string=? "example" (package-name p1)) @@ -1304,6 +1312,58 @@ (define read-at (string=? (package-full-name dep) (package-full-name findutils)))))))))) +(test-assert "package-input-rewriting/spec, deep" + (let* ((dep (dummy-package "chbouib")) + (p0 (dummy-package "example" + (build-system gnu-build-system) + (inputs `(("dep" ,dep))))) + (rewrite (package-input-rewriting/spec + `(("tar" . ,(const sed)) + ("gzip" . ,(const findutils))))) + (p1 (rewrite p0)) + (p2 (rewrite p0))) + (and (not (eq? p1 p0)) + (eq? p1 p2) ;memoization + (string=? "example" (package-name p1)) + (match (package-inputs p1) + ((("dep" dep1)) + (and (string=? (package-full-name dep1) + (package-full-name dep)) + (eq? dep1 (rewrite dep))))) ;memoization + + ;; Make sure implicit inputs were replaced. + (match (bag-direct-inputs (package->bag p1)) + ((("dep" dep1) ("tar" tar) ("gzip" gzip) _ ...) + (and (eq? dep1 (rewrite dep)) + (string=? (package-full-name tar) + (package-full-name sed)) + (string=? (package-full-name gzip) + (package-full-name findutils)))))))) + +(test-assert "package-input-rewriting/spec, no duplicates" + ;; Ensure that deep input rewriting does not forget implicit inputs. Doing + ;; so could lead to duplicates in a package's inputs: in the example below, + ;; P0's transitive inputs would contain one rewritten "python" and one + ;; original "python". These two "python" packages are thus not 'eq?' but + ;; they lower to the same derivation. See , + ;; which can be reproduced by passing #:deep? #f. + (let* ((dep0 (dummy-package "dep0" + (build-system trivial-build-system) + (propagated-inputs `(("python" ,python))))) + (p0 (dummy-package "chbouib" + (build-system python-build-system) + (arguments `(#:python ,python)) + (inputs `(("dep0" ,dep0))))) + (rewrite (package-input-rewriting/spec '() #:deep? #t)) + (p1 (rewrite p0)) + (bag1 (package->bag p1)) + (pythons (filter-map (match-lambda + (("python" python) python) + (_ #f)) + (bag-transitive-inputs bag1)))) + (match (delete-duplicates pythons eq?) + ((p) (eq? p (rewrite python)))))) + (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm index 12114fc8f5..5f91360953 100644 --- a/tests/scripts-build.scm +++ b/tests/scripts-build.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2017, 2019 Ludovic Courtès +;;; Copyright © 2016, 2017, 2019, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +19,7 @@ (define-module (test-scripts-build) #:use-module (guix tests) #:use-module (guix store) + #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix git-download) #:use-module (guix scripts build) @@ -163,11 +164,16 @@ (define-module (test-scripts-build) ((("foo" dep1) ("bar" dep2)) (and (string=? (package-full-name dep1) (package-full-name grep)) - (eq? (package-replacement dep1) findutils) + (string=? (package-full-name (package-replacement dep1)) + (package-full-name findutils)) (string=? (package-name dep2) "chbouib") (match (package-native-inputs dep2) ((("x" dep)) - (eq? (package-replacement dep) findutils))))))))))) + (with-store store + (string=? (derivation-file-name + (package-derivation store findutils)) + (derivation-file-name + (package-derivation store dep)))))))))))))) (test-equal "options->transformation, with-branch" (git-checkout (url "https://example.org") -- cgit v1.2.3 From b3fc03ee266a5f6d810d780582d458e561efccf3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 23 Sep 2020 14:40:15 +0200 Subject: packages: 'package-mapping' correctly recurses into 'replacement'. Previously, something like: guix build glib --with-graft=glibc=glibc@2.29 would produce a result showing that rewriting rules were not applied to libx11@1.6.A (a replacement). * guix/packages.scm (package-mapping): Call REPLACE instead of PROC to 'replacement'. * tests/packages.scm ("package-input-rewriting/spec, graft"): New test. --- guix/packages.scm | 2 +- tests/packages.scm | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/packages.scm b/guix/packages.scm index f696945e30..0d0d7492b6 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1037,7 +1037,7 @@ (define replace (inputs (map rewrite (package-inputs p))) (native-inputs (map rewrite (package-native-inputs p))) (propagated-inputs (map rewrite (package-propagated-inputs p))) - (replacement (and=> (package-replacement p) proc)) + (replacement (and=> (package-replacement p) replace)) (properties `((,mapping-property . #t) ,@(package-properties p)))))))) diff --git a/tests/packages.scm b/tests/packages.scm index 6fa4ad2f1b..e31dea6f72 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1364,6 +1364,33 @@ (define read-at (match (delete-duplicates pythons eq?) ((p) (eq? p (rewrite python)))))) +(test-equal "package-input-rewriting/spec, graft" + (derivation-file-name (package-derivation %store sed)) + + ;; Make sure replacements are rewritten. + (let* ((dep0 (dummy-package "dep" + (version "1") + (build-system trivial-build-system) + (inputs `(("coreutils" ,coreutils))))) + (dep1 (dummy-package "dep" + (version "0") + (build-system trivial-build-system) + (replacement dep0))) + (p0 (dummy-package "p" + (build-system trivial-build-system) + (inputs `(("dep" ,dep1))))) + (rewrite (package-input-rewriting/spec + `(("coreutils" . ,(const sed))))) + (p1 (rewrite p0))) + (match (package-inputs p1) + ((("dep" dep)) + (match (package-inputs (package-replacement dep)) + ((("coreutils" coreutils)) + ;; COREUTILS is not 'eq?' to SED, so the most reliable way to check + ;; for equality is to lower to a derivation. + (derivation-file-name + (package-derivation %store coreutils)))))))) + (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") -- cgit v1.2.3 From 8819551c8d2a12cd4e84e09b51e434d05a012c9d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 23 Sep 2020 14:56:38 +0200 Subject: packages: 'package-input-rewriting' has a #:deep? parameter. * guix/packages.scm (package-input-rewriting): Add #:deep? and pass it to 'package-mapping'. [replacement-property]: New variable. [rewrite]: Check it. [cut?]: New procedure. * tests/packages.scm ("package-input-rewriting"): Pass #:deep? #f and ensure implicit inputs were not rewritten. Avoid 'eq?' comparisons. ("package-input-rewriting, deep"): New test. * gnu/packages/guile.scm (package-for-guile-2.0, package-for-guile-3.0): Pass #:deep? #f. --- doc/guix.texi | 10 +++++----- gnu/packages/guile.scm | 6 ++++-- guix/packages.scm | 35 +++++++++++++++++++++++++---------- tests/packages.scm | 20 ++++++++++++++++++-- 4 files changed, 52 insertions(+), 19 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index e72e1ec130..0805e2d508 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6238,12 +6238,12 @@ transformation is @dfn{input rewriting}, whereby the dependency tree of a package is rewritten by replacing specific inputs by others: @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @ - [@var{rewrite-name}] + [@var{rewrite-name}] [#:deep? #t] Return a procedure that, when passed a package, replaces its direct and -indirect dependencies (but not its implicit inputs) according to -@var{replacements}. @var{replacements} is a list of package pairs; the -first element of each pair is the package to replace, and the second one -is the replacement. +indirect dependencies, including implicit inputs when @var{deep?} is +true, according to @var{replacements}. @var{replacements} is a list of +package pairs; the first element of each pair is the package to replace, +and the second one is the replacement. Optionally, @var{rewrite-name} is a one-argument procedure that takes the name of a package and returns its new name after rewrite. diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm index c59daeebe2..280053bf06 100644 --- a/gnu/packages/guile.scm +++ b/gnu/packages/guile.scm @@ -420,11 +420,13 @@ (define package-for-guile-2.0 ;; A procedure that rewrites the dependency tree of the given package to use ;; GUILE-2.0 instead of GUILE-3.0. (package-input-rewriting `((,guile-3.0 . ,guile-2.0)) - (guile-variant-package-name "guile2.0"))) + (guile-variant-package-name "guile2.0") + #:deep? #f)) (define package-for-guile-2.2 (package-input-rewriting `((,guile-3.0 . ,guile-2.2)) - (guile-variant-package-name "guile2.2"))) + (guile-variant-package-name "guile2.2") + #:deep? #f)) (define-syntax define-deprecated-guile3.0-package (lambda (s) diff --git a/guix/packages.scm b/guix/packages.scm index 0d0d7492b6..4f2bb432be 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1044,22 +1044,37 @@ (define replace replace) (define* (package-input-rewriting replacements - #:optional (rewrite-name identity)) + #:optional (rewrite-name identity) + #:key (deep? #t)) "Return a procedure that, when passed a package, replaces its direct and -indirect dependencies (but not its implicit inputs) according to REPLACEMENTS. -REPLACEMENTS is a list of package pairs; the first element of each pair is the -package to replace, and the second one is the replacement. +indirect dependencies, including implicit inputs when DEEP? is true, according +to REPLACEMENTS. REPLACEMENTS is a list of package pairs; the first element +of each pair is the package to replace, and the second one is the replacement. Optionally, REWRITE-NAME is a one-argument procedure that takes the name of a package and returns its new name after rewrite." + (define replacement-property + ;; Property to tag right-hand sides in REPLACEMENTS. + (gensym " package-replacement")) + (define (rewrite p) - (match (assq-ref replacements p) - (#f (package - (inherit p) - (name (rewrite-name (package-name p))))) - (new new))) + (if (assq-ref (package-properties p) replacement-property) + p + (match (assq-ref replacements p) + (#f (package/inherit p + (name (rewrite-name (package-name p))))) + (new (if deep? + (package/inherit new + (properties `((,replacement-property . #t) + ,@(package-properties new)))) + new))))) - (package-mapping rewrite (cut assq <> replacements))) + (define (cut? p) + (or (assq-ref (package-properties p) replacement-property) + (assq-ref replacements p))) + + (package-mapping rewrite cut? + #:deep? deep?)) (define* (package-input-rewriting/spec replacements #:key (deep? #t)) "Return a procedure that, given a package, applies the given REPLACEMENTS to diff --git a/tests/packages.scm b/tests/packages.scm index e31dea6f72..af8941c2e2 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1239,7 +1239,8 @@ (define read-at ("baz" ,dep))))) (rewrite (package-input-rewriting `((,coreutils . ,sed) (,grep . ,findutils)) - (cut string-append "r-" <>))) + (cut string-append "r-" <>) + #:deep? #f)) (p1 (rewrite p0)) (p2 (rewrite p0))) (and (not (eq? p1 p0)) @@ -1253,7 +1254,22 @@ (define read-at (eq? dep3 (rewrite dep)) ;memoization (match (package-native-inputs dep3) ((("x" dep)) - (eq? dep findutils))))))))) + (eq? dep findutils)))))) + + ;; Make sure implicit inputs were left unchanged. + (equal? (drop (bag-direct-inputs (package->bag p1)) 3) + (drop (bag-direct-inputs (package->bag p0)) 3))))) + +(test-eq "package-input-rewriting, deep" + (derivation-file-name (package-derivation %store sed)) + (let* ((p0 (dummy-package "chbouib" + (build-system python-build-system) + (arguments `(#:python ,python)))) + (rewrite (package-input-rewriting `((,python . ,sed)))) + (p1 (rewrite p0))) + (match (bag-direct-inputs (package->bag p1)) + ((("python" python) _ ...) + (derivation-file-name (package-derivation %store python)))))) (test-assert "package-input-rewriting/spec" (let* ((dep (dummy-package "chbouib" -- cgit v1.2.3 From e75443d4f28ff1aa97e545f2b47b311c3a5ac32a Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Wed, 16 Sep 2020 23:32:00 +0200 Subject: guix build: Add a hint for unspecified value. * guix/scripts/build.scm (options->things-to-build): Add a hint when we cannot build something. --- guix/scripts/build.scm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index f238e9b876..476e556618 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -38,6 +38,7 @@ (define-module (guix scripts build) #:use-module (guix monads) #:use-module (guix gexp) #:use-module (guix profiles) + #:use-module (guix diagnostics) #:autoload (guix http-client) (http-fetch http-get-error?) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -46,6 +47,7 @@ (define-module (guix scripts build) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) #:use-module (gnu packages) #:autoload (guix download) (download-to-store) @@ -830,7 +832,28 @@ (define (options->things-to-build opts) build---packages, gexps, derivations, and so on." (define (validate-type x) (unless (or (derivation? x) (file-like? x) (gexp? x) (procedure? x)) - (leave (G_ "~s: not something we can build~%") x))) + (raise (make-compound-condition + (formatted-message (G_ "~s: not something we can build~%") x) + (condition + (&fix-hint + (hint + (if (unspecified? x) + (G_ "If you build from a file, make sure the last Scheme +expression returns a package value. @code{define-public} defines a variable, +but returns @code{#}. To fix this, add a Scheme expression at +the end of the file that consists only of the package's variable name you +defined, as in this example: + +@example +(define-public my-package + (package + ...)) + +my-package +@end example") + (G_ "If you build from a file, make sure the last +Scheme expression returns a package, gexp, derivation or a list of such +values."))))))))) (define (ensure-list x) (let ((lst (match x -- cgit v1.2.3 From 680b80e37453d4e23ad8188d60894916e1c07162 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 29 Sep 2020 10:29:23 +0200 Subject: openpgp: Fix argument order of 'fxbit-set?'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/openpgp.scm (fxbit-set?): Change to swap arguments compared to 'bit-set?'. * tests/openpgp.scm (%binary-sample): New test vector. ("port-ascii-armored?, #t"): Add test. ("port-ascii-armored?, #f"): Add another test. Co-authored-by: Ludovic Courtès --- guix/openpgp.scm | 2 +- tests/openpgp.scm | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/openpgp.scm b/guix/openpgp.scm index 33c851255b..153752ee73 100644 --- a/guix/openpgp.scm +++ b/guix/openpgp.scm @@ -110,7 +110,7 @@ (define-alias fx* *) (define-alias fx/ /) (define-alias fxdiv quotient) (define-alias fxand logand) -(define-alias fxbit-set? bit-set?) +(define-inlinable (fxbit-set? n index) (bit-set? index n)) (define-alias fxbit-field bit-field) (define-alias bitwise-bit-field bit-field) (define-alias fxarithmetic-shift-left ash) diff --git a/tests/openpgp.scm b/tests/openpgp.scm index 0beab6f88b..c2be26fa49 100644 --- a/tests/openpgp.scm +++ b/tests/openpgp.scm @@ -50,6 +50,12 @@ (define %radix-64-sample/crc-mismatch =AAAA -----END PGP MESSAGE-----\n") +(define %binary-sample + ;; Same message as %radix-64-sample, decoded into bytevector. + (base16-string->bytevector + "c838013b6d96c411efecef17ecefe3ca0004ce8979ea250a897995f979a9\ +0ad9a9a9050a890ac5a9c945a940c1a2fcd2bc14858cd4a2547b2e00")) + (define %civodul-fingerprint "3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5") @@ -155,6 +161,12 @@ (define %hello-signature/ed25519/sha1 ;digest-algo: sha1 read-radix-64)) list)) +(test-assert "port-ascii-armored?, #t" + (call-with-input-string %radix-64-sample port-ascii-armored?)) + +(test-assert "port-ascii-armored?, #f" + (not (port-ascii-armored? (open-bytevector-input-port %binary-sample)))) + (test-assert "get-openpgp-keyring" (let* ((key (search-path %load-path "tests/civodul.key")) (keyring (get-openpgp-keyring -- cgit v1.2.3 From 313f492657f1d0863c641fa5ee7f5b7028e27c94 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 31 Jul 2020 16:49:29 +0200 Subject: scripts: system: Add support for image-type. * guix/scripts/system.scm (list-image-types): New procedure, (%options): add "image-type" and "list-image-types" options, remove "file-system-type" option, (show-help): adapt accordingly, (%default-options): also adapt, and set the default "image-type" to "raw", (perform-action): add image-type argument and remove file-system-type argument, (process-action): adapt perform-action call, (system-derivation-for-action): remove base-image argument, add image-type argument, and use it to create the image passed to "system-image". * tests/guix-system.sh: Adapt accordingly and add a test for "--list-image-types" command. * doc/guix.texi (Building the Installation Image, Invoking guix system): Adapt accordingly. Signed-off-by: Mathieu Othacehe --- Makefile.am | 5 ++-- doc/guix.texi | 43 ++++++++++++++++-------------- guix/scripts/system.scm | 70 +++++++++++++++++++++++++++++++------------------ tests/guix-system.sh | 9 ++++--- 4 files changed, 75 insertions(+), 52 deletions(-) (limited to 'guix') diff --git a/Makefile.am b/Makefile.am index 8e91e1e558..9c3ff4420f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -833,9 +833,8 @@ release: dist-with-updated-version -v1 --no-grafts --fallback for system in $(GUIX_SYSTEM_SUPPORTED_SYSTEMS) ; do \ image=`$(top_builddir)/pre-inst-env \ - guix system disk-image \ - --file-system-type=iso9660 \ - --label="GUIX_$${system}_$(VERSION)" \ + guix system disk-image -t iso9660 \ + --label="GUIX_$${system}_$(VERSION)" \ --system=$$system --fallback \ gnu/system/install.scm` ; \ if [ ! -f "$$image" ] ; then \ diff --git a/doc/guix.texi b/doc/guix.texi index ff2e582347..e8458ad8d8 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40,7 +40,7 @@ Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Julien Lepiller@* Copyright @copyright{} 2016 Alex ter Weele@* Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@* Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@* -Copyright @copyright{} 2017, 2018 Mathieu Othacehe@* +Copyright @copyright{} 2017, 2018, 2020 Mathieu Othacehe@* Copyright @copyright{} 2017 Federico Beffa@* Copyright @copyright{} 2017, 2018 Carlo Zancanaro@* Copyright @copyright{} 2017 Thomas Danckaert@* @@ -2568,8 +2568,7 @@ The installation image described above was built using the @command{guix system} command, specifically: @example -guix system disk-image --file-system-type=iso9660 \ - gnu/system/install.scm +guix system disk-image -t iso9660 gnu/system/install.scm @end example Have a look at @file{gnu/system/install.scm} in the source tree, @@ -29375,24 +29374,28 @@ a value. Docker images are built to contain exactly what they need, so the @option{--image-size} option is ignored in the case of @code{docker-image}. -You can specify the root file system type by using the -@option{--file-system-type} option. It defaults to @code{ext4}. When its -value is @code{iso9660}, the @option{--label} option can be used to specify -a volume ID with @code{disk-image}. +The @code{disk-image} command can produce various image types. The +image type can be selected using the @command{--image-type} option. It +defaults to @code{raw}. When its value is @code{iso9660}, the +@option{--label} option can be used to specify a volume ID with +@code{disk-image}. -When using @code{vm-image}, the returned image is in qcow2 format, which -the QEMU emulator can efficiently use. @xref{Running Guix in a VM}, -for more information on how to run the image in a virtual machine. - -When using @code{disk-image}, a raw disk image is produced; it can be -copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is -the device corresponding to a USB stick, one can copy the image to it -using the following command: +When using the @code{raw} image type, a raw disk image is produced; it +can be copied as is to a USB stick, for instance. Assuming +@code{/dev/sdc} is the device corresponding to a USB stick, one can copy +the image to it using the following command: @example # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc status=progress @end example +The @code{--list-image-types} command lists all the available image +types. + +When using @code{vm-image}, the returned image is in qcow2 format, which +the QEMU emulator can efficiently use. @xref{Running Guix in a VM}, +for more information on how to run the image in a virtual machine. + When using @code{docker-image}, a Docker image is produced. Guix builds the image from scratch, not from a pre-existing Docker base image. As a result, it contains @emph{exactly} what you define in the operating @@ -29494,17 +29497,17 @@ information, one can rebuild the image to make sure it really contains what it pretends to contain; or they could use that to derive a variant of the image. -@item --file-system-type=@var{type} +@item --image-type=@var{type} @itemx -t @var{type} -For the @code{disk-image} action, create a file system of the given -@var{type} on the image. +For the @code{disk-image} action, create an image with given @var{type}. -When this option is omitted, @command{guix system} uses @code{ext4}. +When this option is omitted, @command{guix system} uses the @code{raw} +image type. @cindex ISO-9660 format @cindex CD image format @cindex DVD image format -@option{--file-system-type=iso9660} produces an ISO-9660 image, suitable +@option{--image-type=iso9660} produces an ISO-9660 image, suitable for burning on CDs and DVDs. @item --image-size=@var{size} diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index bd5f84fc5b..7b3eacf2e1 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -666,8 +666,8 @@ (define file-systems ;;; Action. ;;; -(define* (system-derivation-for-action os base-image action - #:key image-size file-system-type +(define* (system-derivation-for-action os action + #:key image-size image-type full-boot? container-shared-network? mappings label) "Return as a monadic value the derivation for OS according to ACTION." @@ -690,12 +690,15 @@ (define* (system-derivation-for-action os base-image action (* 70 (expt 2 20))) #:mappings mappings)) ((disk-image) - (lower-object - (system-image - (image - (inherit (if label (image-with-label base-image label) base-image)) - (size image-size) - (operating-system os))))) + (let ((base-image (os->image os #:type image-type))) + (lower-object + (system-image + (image + (inherit (if label + (image-with-label base-image label) + base-image)) + (size image-size) + (operating-system os)))))) ((docker-image) (system-docker-image os #:shared-network? container-shared-network?)))) @@ -748,18 +751,19 @@ (define* (perform-action action os install-bootloader? dry-run? derivations-only? use-substitutes? bootloader-target target - image-size file-system-type full-boot? label - container-shared-network? + image-size image-type + full-boot? label container-shared-network? (mappings '()) (gc-root #f)) "Perform ACTION for OS. INSTALL-BOOTLOADER? specifies whether to install bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the target root directory; IMAGE-SIZE is the size of the image to be built, for -the 'vm-image' and 'disk-image' actions. The root file system is created as a -FILE-SYSTEM-TYPE file system. FULL-BOOT? is used for the 'vm' action; it -determines whether to boot directly to the kernel or to the bootloader. -CONTAINER-SHARED-NETWORK? determines if the container will use a separate -network namespace. +the 'vm-image' and 'disk-image' actions. IMAGE-TYPE is the type of image to +be built. + +FULL-BOOT? is used for the 'vm' action; it determines whether to +boot directly to the kernel or to the bootloader. CONTAINER-SHARED-NETWORK? +determines if the container will use a separate network namespace. When DERIVATIONS-ONLY? is true, print the derivation file name(s) without building anything. @@ -799,11 +803,9 @@ (define bootcfg (check-initrd-modules os))) (mlet* %store-monad - ((target* (current-target-system)) - (image -> (find-image file-system-type target*)) - (sys (system-derivation-for-action os image action + ((sys (system-derivation-for-action os action #:label label - #:file-system-type file-system-type + #:image-type image-type #:image-size image-size #:full-boot? full-boot? #:container-shared-network? container-shared-network? @@ -886,6 +888,17 @@ (define (export-shepherd-graph os port) #:node-type (shepherd-service-node-type shepherds) #:reverse-edges? #t))) + +;;; +;;; Images. +;;; + +(define (list-image-types) + "Print the available image types." + (display (G_ "The available image types are:\n")) + (newline) + (format #t "~{ - ~a ~%~}" (map image-type-name (force %image-types)))) + ;;; ;;; Options. @@ -945,9 +958,9 @@ (define (show-help) apply STRATEGY (one of nothing-special, backtrace, or debug) when an error occurs while reading FILE")) (display (G_ " - --file-system-type=TYPE - for 'disk-image', produce a root file system of TYPE - (one of 'ext4', 'iso9660')")) + --list-image-types list available image types")) + (display (G_ " + -t, --image-type=TYPE for 'disk-image', produce an image of TYPE")) (display (G_ " --image-size=SIZE for 'vm-image', produce an image of SIZE")) (display (G_ " @@ -1008,10 +1021,14 @@ (define %options (lambda (opt name arg result) (alist-cons 'on-error (string->symbol arg) result))) - (option '(#\t "file-system-type") #t #f + (option '(#\t "image-type") #t #f (lambda (opt name arg result) - (alist-cons 'file-system-type arg + (alist-cons 'image-type (string->symbol arg) result))) + (option '("list-image-types") #f #f + (lambda (opt name arg result) + (list-image-types) + (exit 0))) (option '("image-size") #t #f (lambda (opt name arg result) (alist-cons 'image-size (size->number arg) @@ -1080,7 +1097,7 @@ (define %default-options (debug . 0) (verbosity . #f) ;default (validate-reconfigure . ,ensure-forward-reconfigure) - (file-system-type . "ext4") + (image-type . raw) (image-size . guess) (install-bootloader? . #t) (label . #f))) @@ -1177,7 +1194,8 @@ (define save-provenance? (assoc-ref opts 'skip-safety-checks?) #:validate-reconfigure (assoc-ref opts 'validate-reconfigure) - #:file-system-type (assoc-ref opts 'file-system-type) + #:image-type (lookup-image-type-by-name + (assoc-ref opts 'image-type)) #:image-size (assoc-ref opts 'image-size) #:full-boot? (assoc-ref opts 'full-boot?) #:container-shared-network? diff --git a/tests/guix-system.sh b/tests/guix-system.sh index 0e22686a34..667e084fcf 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -261,8 +261,8 @@ guix system vm "$tmpfile" -d | grep '\.drv$' drv1="`guix system vm "$tmpfile" -d`" drv2="`guix system vm "$tmpfile" -d`" test "$drv1" = "$drv2" -drv1="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`" -drv2="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`" +drv1="`guix system disk-image -t iso9660 "$tmpfile" -d`" +drv2="`guix system disk-image -t iso9660 "$tmpfile" -d`" test "$drv1" = "$drv2" make_user_config "group-that-does-not-exist" "users" @@ -320,5 +320,8 @@ guix system -n vm gnu/system/examples/vm-image.tmpl guix system -n vm-image gnu/system/examples/vm-image.tmpl # This invocation was taken care of in the loop above: # guix system -n disk-image gnu/system/examples/bare-bones.tmpl -guix system -n disk-image --file-system-type=iso9660 gnu/system/examples/bare-bones.tmpl +guix system -n disk-image -t iso9660 gnu/system/examples/bare-bones.tmpl guix system -n docker-image gnu/system/examples/docker-image.tmpl + +# Verify that at least the raw image type is available. +guix system --list-image-types | grep "raw" -- cgit v1.2.3 From 58abd5873985e0cd9a2926867bf697c5e7bc01f9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 1 Oct 2020 11:29:54 +0200 Subject: pack: Work around ld.so bug that affects the "fakechroot" engine. Fixes . * guix/scripts/pack.scm (wrapped-package): Use (runpath program) instead of (runpath #$(audit-module)). --- guix/scripts/pack.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 379e6a3ac6..bab3a3e2e4 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -817,11 +817,17 @@ (define (elf-loader-compile-flags program) (string-append "-DLOADER_AUDIT_MODULE=\"" #$(audit-module) "\"") + + ;; XXX: Normally (runpath #$(audit-module)) is + ;; enough. However, to work around + ;; + ;; (glibc <= 2.32), pass the whole search path of + ;; PROGRAM, which presumably is a superset of that + ;; of the audit module. (string-append "-DLOADER_AUDIT_RUNPATH={ " (string-join (map object->string - (runpath - #$(audit-module))) + (runpath program)) ", " 'suffix) "NULL }") (if gconv -- cgit v1.2.3 From 7dc19c33fc71e17a1d7ddd4563aa6ffd73d1a2cf Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 1 Oct 2020 12:35:00 +0200 Subject: ui: "guix help" silently ignores EPIPE. This avoids a backtrace when running "guix help | head" or similar. * guix/ui.scm (run-guix): Wrap 'show-guix-help' calls in 'leave-on-EPIPE'. --- guix/ui.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/ui.scm b/guix/ui.scm index ecaf975c1f..e88b7b4015 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2134,7 +2134,7 @@ (define option? (cut string-prefix? "-" <>)) (G_ "guix: missing command name~%")) (show-guix-usage)) ((or ("-h") ("--help")) - (show-guix-help)) + (leave-on-EPIPE (show-guix-help))) ((or ("-V") ("--version")) (show-version-and-exit "guix")) (((? option? o) args ...) @@ -2145,7 +2145,7 @@ (define option? (cut string-prefix? "-" <>)) (apply run-guix-command (string->symbol command) '("--help"))) (("help" args ...) - (show-guix-help)) + (leave-on-EPIPE (show-guix-help))) ((command args ...) (apply run-guix-command (string->symbol command) -- cgit v1.2.3 From f4390d391b5901735444cba21c94e1e23d3fc575 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Thu, 1 Oct 2020 15:05:05 +0200 Subject: guix: opam: Fix syntax. * guix/import/opam.scm (STRCHR, comment, choice): Fix syntax. (group-pat): Add syntax. (opam->guix-package): Suppport "archive" keyword. --- guix/import/opam.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'guix') diff --git a/guix/import/opam.scm b/guix/import/opam.scm index 9cda3da006..7327ab6e29 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -49,16 +49,19 @@ (define-module (guix import opam) condition)) ;; Define a PEG parser for the opam format -(define-peg-pattern comment none (and "#" (* STRCHR) "\n")) +(define-peg-pattern comment none (and "#" (* COMMCHR) "\n")) (define-peg-pattern SP none (or " " "\n" comment)) (define-peg-pattern SP2 body (or " " "\n")) (define-peg-pattern QUOTE none "\"") (define-peg-pattern QUOTE2 body "\"") (define-peg-pattern COLON none ":") ;; A string character is any character that is not a quote, or a quote preceded by a backslash. +(define-peg-pattern COMMCHR none + (or " " "!" "\\" "\"" (range #\# #\頋))) (define-peg-pattern STRCHR body (or " " "!" "\n" (and (ignore "\\") "\"") - (and (ignore "\\") "\\") (range #\# #\頋))) + (ignore "\\\n") (and (ignore "\\") "\\") + (range #\# #\頋))) (define-peg-pattern operator all (or "=" "!" "<" ">")) (define-peg-pattern records body (* (and (or record weird-record) (* SP)))) @@ -69,8 +72,12 @@ (define-peg-pattern value body (and (or conditional-value ground-value operator) (define-peg-pattern choice-pat all (and (ignore "(") (* SP) choice (* SP) (ignore ")"))) (define-peg-pattern choice body (or (and (or conditional-value ground-value) (* SP) (ignore "|") (* SP) choice) + group-pat conditional-value ground-value)) +(define-peg-pattern group-pat body + (and ground-value (* SP) (ignore "&") (* SP) + (or group-pat conditional-value ground-value))) (define-peg-pattern ground-value body (and (or multiline-string string-pat choice-pat list-pat var) (* SP))) (define-peg-pattern conditional-value all (and ground-value (* SP) condition)) (define-peg-pattern string-pat all (and QUOTE (* STRCHR) QUOTE)) @@ -258,7 +265,8 @@ (define* (opam->guix-package name #:key (repository (get-opam-repository))) (version (assoc-ref opam-file "version")) (opam-content (assoc-ref opam-file "metadata")) (url-dict (metadata-ref opam-content "url")) - (source-url (metadata-ref url-dict "src")) + (source-url (or (metadata-ref url-dict "src") + (metadata-ref url-dict "archive"))) (requirements (metadata-ref opam-content "depends")) (dependencies (dependency-list->names requirements)) (native-dependencies (depends->native-inputs requirements)) @@ -308,7 +316,7 @@ (define* (opam->guix-package name #:key (repository (get-opam-repository))) (filter (lambda (name) (not (member name '("dune" "jbuilder")))) - dependencies)))))))) + dependencies)))))))) (define (opam-recursive-import package-name) (recursive-import package-name #f -- cgit v1.2.3 From a6816618fc1e48417a64c5f8ca67e3d64ebc5441 Mon Sep 17 00:00:00 2001 From: Julien Lepiller Date: Fri, 2 Oct 2020 00:27:24 +0200 Subject: import: opam: Report groups in syntax tree. * guix/import/opam.scm (group-pat): Report in syntax tree. (dependency->input, dependency->native-input, dependency->name): consider the case of a group. --- guix/import/opam.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/guix/import/opam.scm b/guix/import/opam.scm index 7327ab6e29..6d9eb0a092 100644 --- a/guix/import/opam.scm +++ b/guix/import/opam.scm @@ -75,8 +75,8 @@ (define-peg-pattern choice body group-pat conditional-value ground-value)) -(define-peg-pattern group-pat body - (and ground-value (* SP) (ignore "&") (* SP) +(define-peg-pattern group-pat all + (and (or conditional-value ground-value) (* SP) (ignore "&") (* SP) (or group-pat conditional-value ground-value))) (define-peg-pattern ground-value body (and (or multiline-string string-pat choice-pat list-pat var) (* SP))) (define-peg-pattern conditional-value all (and ground-value (* SP) condition)) @@ -196,6 +196,7 @@ (define (dependency->input dependency) (('string-pat str) str) ;; Arbitrary select the first dependency (('choice-pat choice ...) (dependency->input (car choice))) + (('group-pat val ...) (map dependency->input val)) (('conditional-value val condition) (if (native? condition) "" (dependency->input val))))) @@ -203,7 +204,8 @@ (define (dependency->native-input dependency) (match dependency (('string-pat str) "") ;; Arbitrary select the first dependency - (('choice-pat choice ...) (dependency->input (car choice))) + (('choice-pat choice ...) (dependency->native-input (car choice))) + (('group-pat val ...) (map dependency->native-input val)) (('conditional-value val condition) (if (native? condition) (dependency->input val) "")))) @@ -211,7 +213,8 @@ (define (dependency->name dependency) (match dependency (('string-pat str) str) ;; Arbitrary select the first dependency - (('choice-pat choice ...) (dependency->input (car choice))) + (('choice-pat choice ...) (dependency->name (car choice))) + (('group-pat val ...) (map dependency->name val)) (('conditional-value val condition) (dependency->name val)))) @@ -263,7 +266,7 @@ (define* (opam->guix-package name #:key (repository (get-opam-repository))) or #f on failure." (and-let* ((opam-file (opam-fetch name repository)) (version (assoc-ref opam-file "version")) - (opam-content (assoc-ref opam-file "metadata")) + (opam-content (pk (assoc-ref opam-file "metadata"))) (url-dict (metadata-ref opam-content "url")) (source-url (or (metadata-ref url-dict "src") (metadata-ref url-dict "archive"))) -- cgit v1.2.3 From f43ffee90882c2d61b46d69728daa7432be297e4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 1 Oct 2020 22:09:58 +0200 Subject: gexp: 'local-file' warns when passed a non-literal relative file name. Fixes . Reported by Vitaliy Shatrov . * guix/gexp.scm (%local-file): Add #:literal? and #:location. Emit a warning when LITERAL? is false and FILE is not absolute. (local-file): In the non-literal case, pass #:location and #:literal?. * po/guix/POTFILES.in: Add guix/gexp.scm. * tests/guix-system.sh: Add test for the warning. --- guix/gexp.scm | 19 +++++++++++++++---- po/guix/POTFILES.in | 1 + tests/guix-system.sh | 14 ++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'guix') diff --git a/guix/gexp.scm b/guix/gexp.scm index 9d3c52e783..40346b61e1 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -26,6 +26,8 @@ (define-module (guix gexp) #:use-module (guix derivations) #:use-module (guix grafts) #:use-module (guix utils) + #:use-module (guix diagnostics) + #:use-module (guix i18n) #:use-module (rnrs bytevectors) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -401,9 +403,15 @@ (define-record-type (define (true file stat) #t) (define* (%local-file file promise #:optional (name (basename file)) - #:key recursive? (select? true)) + #:key + (literal? #t) location + recursive? (select? true)) ;; This intermediate procedure is part of our ABI, but the underlying ;; %%LOCAL-FILE is not. + (when (and (not literal?) (not (string-prefix? "/" file))) + (warning (and=> location source-properties->location) + (G_ "resolving '~a' relative to current directory~%") + file)) (%%local-file file promise name recursive? select?)) (define (absolute-file-name file directory) @@ -443,9 +451,12 @@ (define-syntax local-file rest ...)) ((_ file rest ...) ;; Resolve FILE relative to the current directory. - #'(%local-file file - (delay (absolute-file-name file (getcwd))) - rest ...)) + (with-syntax ((location (datum->syntax s (syntax-source s)))) + #`(%local-file file + (delay (absolute-file-name file (getcwd))) + #:location 'location + #:literal? #f + rest ...))) ((_) #'(syntax-error "missing file name")) (id diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index f4d020782c..b877fac9df 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -76,6 +76,7 @@ guix/scripts/weather.scm guix/scripts/describe.scm guix/scripts/processes.scm guix/scripts/deploy.scm +guix/gexp.scm guix/gnu-maintenance.scm guix/scripts/container.scm guix/scripts/container/exec.scm diff --git a/tests/guix-system.sh b/tests/guix-system.sh index 667e084fcf..957479ede0 100644 --- a/tests/guix-system.sh +++ b/tests/guix-system.sh @@ -297,6 +297,20 @@ EOF guix system build "$tmpdir/config.scm" -n (cd "$tmpdir"; guix system build "config.scm" -n) +# Check that we get a warning when passing 'local-file' a non-literal relative +# file name. +cat > "$tmpdir/config.scm" <&1 | \ + grep "config\.scm:4:2: warning:.*whatever.*relative to current directory" + # Searching. guix system search tor | grep "^name: tor" guix system search tor | grep "^shepherdnames: tor" -- cgit v1.2.3 From dc749a0e91b15e7e65a95dac1a9341dc17e2ff12 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 1 Oct 2020 22:32:22 +0200 Subject: ui: Use "guix install" in locale hint. * guix/ui.scm (install-locale): Change "guix package -i" to "guix install". --- guix/ui.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/ui.scm b/guix/ui.scm index e88b7b4015..8213e8ebab 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -492,7 +492,7 @@ (define (install-locale) lines: @example -guix package -i glibc-utf8-locales +guix install glibc-utf8-locales export GUIX_LOCPATH=\"$HOME/.guix-profile/lib/locale\" @end example -- cgit v1.2.3 From 9471aea76ace5c0998d889fc5fbde7a6bcafc654 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 2 Oct 2020 09:29:26 +0200 Subject: gexp: Fix argument ordering in 'local-file' macro. Fixes a regression introduced in f43ffee90882c2d61b46d69728daa7432be297e4. Reported by jonsger on #guix. * guix/gexp.scm (local-file): In the non-literal case, add #:literal? and #:location after REST. --- guix/gexp.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/gexp.scm b/guix/gexp.scm index 40346b61e1..25e4881d21 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -454,9 +454,9 @@ (define-syntax local-file (with-syntax ((location (datum->syntax s (syntax-source s)))) #`(%local-file file (delay (absolute-file-name file (getcwd))) + rest ... #:location 'location - #:literal? #f - rest ...))) + #:literal? #f))) ((_) #'(syntax-error "missing file name")) (id -- cgit v1.2.3 From bdbd8bf9054c88aaf694a08e49270c95e6adad27 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 2 Oct 2020 09:53:45 +0200 Subject: scripts: system: Honor target argument. Since 313f492657f1d0863c641fa5ee7f5b7028e27c94 the target argument passed to "guix system" was not honored for 'disk-image' command. This forces the command line passed "target" to take precedence over the "target" field of the record returned by "os->image" procedure. * guix/scripts/system.scm (system-derivation-for-action): Override the "target" field of the "image" record using the "target" argument from the command line. --- guix/scripts/system.scm | 64 ++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'guix') diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 7b3eacf2e1..939559e719 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -671,36 +671,40 @@ (define* (system-derivation-for-action os action full-boot? container-shared-network? mappings label) "Return as a monadic value the derivation for OS according to ACTION." - (case action - ((build init reconfigure) - (operating-system-derivation os)) - ((container) - (container-script - os - #:mappings mappings - #:shared-network? container-shared-network?)) - ((vm-image) - (system-qemu-image os #:disk-image-size image-size)) - ((vm) - (system-qemu-image/shared-store-script os - #:full-boot? full-boot? - #:disk-image-size - (if full-boot? - image-size - (* 70 (expt 2 20))) - #:mappings mappings)) - ((disk-image) - (let ((base-image (os->image os #:type image-type))) - (lower-object - (system-image - (image - (inherit (if label - (image-with-label base-image label) - base-image)) - (size image-size) - (operating-system os)))))) - ((docker-image) - (system-docker-image os #:shared-network? container-shared-network?)))) + (mlet %store-monad ((target (current-target-system))) + (case action + ((build init reconfigure) + (operating-system-derivation os)) + ((container) + (container-script + os + #:mappings mappings + #:shared-network? container-shared-network?)) + ((vm-image) + (system-qemu-image os #:disk-image-size image-size)) + ((vm) + (system-qemu-image/shared-store-script os + #:full-boot? full-boot? + #:disk-image-size + (if full-boot? + image-size + (* 70 (expt 2 20))) + #:mappings mappings)) + ((disk-image) + (let* ((base-image (os->image os #:type image-type)) + (base-target (image-target base-image))) + (lower-object + (system-image + (image + (inherit (if label + (image-with-label base-image label) + base-image)) + (target (or base-target target)) + (size image-size) + (operating-system os)))))) + ((docker-image) + (system-docker-image os + #:shared-network? container-shared-network?))))) (define (maybe-suggest-running-guix-pull) "Suggest running 'guix pull' if this has never been done before." -- cgit v1.2.3 From ad54a73bb820a685f242976a86be63931789fa97 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 24 Sep 2020 22:13:06 +0200 Subject: guix build: Record package transformations in manifest entries. With this change, package transformation options used while building a manifest are saved in the metadata of the manifest entries. * guix/scripts/build.scm (transformation-procedure): New procedure. (options->transformation)[applicable]: Use it. Change to a list of key/value/proc tuples instead of key/proc pairs. [package-with-transformation-properties, tagged-object]: New procedures. Use them. (package-transformations, manifest-entry-with-transformations): New procedures. * guix/scripts/pack.scm (guix-pack)[with-transformations]: New procedure. Use it. * guix/scripts/package.scm (process-actions)[transform-entry]: Use it. * tests/guix-package-aliases.sh: Add test. --- guix/scripts/build.scm | 80 ++++++++++++++++++++++++++++++++++--------- guix/scripts/pack.scm | 29 +++++++++------- guix/scripts/package.scm | 13 +++---- tests/guix-package-aliases.sh | 6 ++++ 4 files changed, 93 insertions(+), 35 deletions(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 476e556618..72a5d46347 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -63,6 +63,7 @@ (define-module (guix scripts build) %transformation-options options->transformation + manifest-entry-with-transformations show-transformation-options-help guix-build @@ -427,6 +428,14 @@ (define %transformations (with-git-url . ,transform-package-source-git-url) (without-tests . ,transform-package-tests))) +(define (transformation-procedure key) + "Return the transformation procedure associated with KEY, a symbol such as +'with-source', or #f if there is none." + (any (match-lambda + ((k . proc) + (and (eq? k key) proc))) + %transformations)) + (define %transformation-options ;; The command-line interface to the above transformations. (let ((parser (lambda (symbol) @@ -481,32 +490,69 @@ (define applicable ;; order in which they appear on the command line. (filter-map (match-lambda ((key . value) - (match (any (match-lambda - ((k . proc) - (and (eq? k key) proc))) - %transformations) + (match (transformation-procedure key) (#f #f) (transform ;; XXX: We used to pass TRANSFORM a list of several ;; arguments, but we now pass only one, assuming that ;; transform composes well. - (cons key (transform (list value))))))) + (list key value (transform (list value))))))) (reverse opts))) + (define (package-with-transformation-properties p) + (package/inherit p + (properties `((transformations + . ,(map (match-lambda + ((key value _) + (cons key value))) + applicable)) + ,@(package-properties p))))) + (lambda (store obj) - (fold (match-lambda* - (((name . transform) obj) - (let ((new (transform store obj))) - (when (eq? new obj) - (warning (G_ "transformation '~a' had no effect on ~a~%") - name - (if (package? obj) - (package-full-name obj) - obj))) - new))) - obj - applicable))) + (define (tagged-object new) + (if (and (not (eq? obj new)) + (package? new) (not (null? applicable))) + (package-with-transformation-properties new) + new)) + + (tagged-object + (fold (match-lambda* + (((name value transform) obj) + (let ((new (transform store obj))) + (when (eq? new obj) + (warning (G_ "transformation '~a' had no effect on ~a~%") + name + (if (package? obj) + (package-full-name obj) + obj))) + new))) + obj + applicable)))) + +(define (package-transformations package) + "Return the transformations applied to PACKAGE according to its properties." + (match (assq-ref (package-properties package) 'transformations) + (#f '()) + (transformations transformations))) + +(define (manifest-entry-with-transformations entry) + "Return ENTRY with an additional 'transformations' property if it's not +already there." + (let ((properties (manifest-entry-properties entry))) + (if (assq 'transformations properties) + entry + (let ((item (manifest-entry-item entry))) + (manifest-entry + (inherit entry) + (properties + (match (and (package? item) + (package-transformations item)) + ((or #f '()) + properties) + (transformations + `((transformations . ,transformations) + ,@properties))))))))) ;;; diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index bab3a3e2e4..0b66da01f9 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -1140,19 +1140,24 @@ (define with-provenance manifest)) identity)) + (define (with-transformations manifest) + (map-manifest-entries manifest-entry-with-transformations + manifest)) + (with-provenance - (cond - ((and (not (null? manifests)) (not (null? packages))) - (leave (G_ "both a manifest and a package list were given~%"))) - ((not (null? manifests)) - (concatenate-manifests - (map (lambda (file) - (let ((user-module (make-user-module - '((guix profiles) (gnu))))) - (load* file user-module))) - manifests))) - (else - (packages->manifest packages)))))) + (with-transformations + (cond + ((and (not (null? manifests)) (not (null? packages))) + (leave (G_ "both a manifest and a package list were given~%"))) + ((not (null? manifests)) + (concatenate-manifests + (map (lambda (file) + (let ((user-module (make-user-module + '((guix profiles) (gnu))))) + (load* file user-module))) + manifests))) + (else + (packages->manifest packages))))))) (with-error-handling (with-store store diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 7e7c37eac4..83f8c123d9 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -864,12 +864,13 @@ (define transform (options->transformation opts)) (define (transform-entry entry) (let ((item (transform store (manifest-entry-item entry)))) - (manifest-entry - (inherit entry) - (item item) - (version (if (package? item) - (package-version item) - (manifest-entry-version entry)))))) + (manifest-entry-with-transformations + (manifest-entry + (inherit entry) + (item item) + (version (if (package? item) + (package-version item) + (manifest-entry-version entry))))))) (when (equal? profile %current-profile) ;; Normally the daemon created %CURRENT-PROFILE when we connected, unless diff --git a/tests/guix-package-aliases.sh b/tests/guix-package-aliases.sh index e4ddace057..311838b768 100644 --- a/tests/guix-package-aliases.sh +++ b/tests/guix-package-aliases.sh @@ -39,6 +39,12 @@ test -x "$profile/bin/guile" ! guix install -r guile-bootstrap -p "$profile" --bootstrap test -x "$profile/bin/guile" +# Use a package transformation option and make sure it's recorded. +guix install --bootstrap guile-bootstrap -p "$profile" \ + --with-input=libreoffice=inkscape +test -x "$profile/bin/guile" +grep "libreoffice=inkscape" "$profile/manifest" + guix upgrade --version guix upgrade -n guix upgrade gui.e -n -- cgit v1.2.3 From 8e1907a72430aa989125b053573ef0897c480697 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 25 Sep 2020 17:16:34 +0200 Subject: guix package: Re-apply package transformation when upgrading. * guix/scripts/package.scm (transaction-upgrade-entry)[upgrade]: Add 'transform' parameter. Pass PKG through it. Use 'manifest-entry-with-transformations'. Call 'options->transformation' to get the transformation procedure. * tests/guix-package.sh: Add 'guix package -u' test. * tests/packages.scm ("transaction-upgrade-entry, transformation options preserved"): New test. * doc/guix.texi (Invoking guix package): Mention that transformations are preserved across upgrades. (Package Transformation Options): Likewise. --- doc/guix.texi | 27 +++++++++++++++++++++++++++ guix/scripts/package.scm | 20 +++++++++++++++----- tests/guix-package.sh | 15 +++++++++++++++ tests/packages.scm | 23 +++++++++++++++++++++++ 4 files changed, 80 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index da48c8a72d..a6260a12aa 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3101,6 +3101,29 @@ in the distribution currently installed. To update your distribution, you should regularly run @command{guix pull} (@pxref{Invoking guix pull}). +@cindex package transformations, upgrades +When upgrading, package transformations that were originally applied +when creating the profile are automatically re-applied (@pxref{Package +Transformation Options}). For example, assume you first installed Emacs +from the tip of its development branch with: + +@example +guix install emacs-next --with-branch=emacs-next=master +@end example + +Next time you run @command{guix upgrade}, Guix will again pull the tip +of the Emacs development branch and build @code{emacs-next} from that +checkout. + +Note that transformation options such as @option{--with-branch} and +@option{--with-source} depend on external state; it is up to you to +ensure that they work as expected. You can also discard a +transformations that apply to a package by running: + +@example +guix install @var{package} +@end example + @item --do-not-upgrade[=@var{regexp} @dots{}] When used together with the @option{--upgrade} option, do @emph{not} upgrade any packages whose name matches a @var{regexp}. For example, to @@ -9193,6 +9216,10 @@ This is a convenient way to create customized packages on the fly without having to type in the definitions of package variants (@pxref{Defining Packages}). +Package transformation options are preserved across upgrades: +@command{guix upgrade} attempts to apply transformation options +initially used when creating the profile to the upgraded packages. + @table @code @item --with-source=@var{source} diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 83f8c123d9..2f04652634 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -218,12 +218,13 @@ (define (supersede old new) (output (manifest-entry-output old))) transaction))) - (define (upgrade entry) + (define (upgrade entry transform) (match entry (($ name version output (? string? path)) (match (find-best-packages-by-name name #f) ((pkg . rest) - (let ((candidate-version (package-version pkg))) + (let* ((pkg (transform store pkg)) + (candidate-version (package-version pkg))) (match (package-superseded pkg) ((? package? new) (supersede entry new)) @@ -231,12 +232,14 @@ (define (upgrade entry) (case (version-compare candidate-version version) ((>) (manifest-transaction-install-entry - (package->manifest-entry* pkg output) + (manifest-entry-with-transformations + (package->manifest-entry* pkg output)) transaction)) ((<) transaction) ((=) - (let* ((new (package->manifest-entry* pkg output))) + (let* ((new (manifest-entry-with-transformations + (package->manifest-entry* pkg output)))) ;; Here we want to determine whether the NEW actually ;; differs from ENTRY, but we need to intercept ;; 'build-things' calls because they would prevent us from @@ -255,7 +258,14 @@ (define (upgrade entry) (if (manifest-transaction-removal-candidate? entry transaction) transaction - (upgrade entry))) + + ;; Upgrade ENTRY, preserving transformation options listed in its + ;; properties. + (let ((transform (options->transformation + (or (assq-ref (manifest-entry-properties entry) + 'transformations) + '())))) + (upgrade entry transform)))) ;;; diff --git a/tests/guix-package.sh b/tests/guix-package.sh index a43496699b..3e5fa71d20 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -184,6 +184,21 @@ grep -E 'emacs[[:blank:]]+42\.5\.9rc7' "$tmpfile" rm "$emacs_tarball" "$tmpfile" rmdir "$module_dir" +# Install with package transformations. +guix install --bootstrap -p "$profile" sed --with-input=sed=guile-bootstrap +grep "sed=guile-bootstrap" "$profile/manifest" +test "$(readlink -f "$profile/bin/guile")" \ + = "$(guix build guile-bootstrap)/bin/guile" +test ! -f "$profile/bin/sed" + +# Make sure the package transformation is preserved. +guix package --bootstrap -p "$profile" -u +grep "sed=guile-bootstrap" "$profile/manifest" +test "$(readlink -f "$profile/bin/guile")" \ + = "$(guix build guile-bootstrap)/bin/guile" +test ! -f "$profile/bin/sed" +rm "$profile" "$profile"-[0-9]-link + # Profiles with a relative file name. Make sure we don't create dangling # symlinks--see bug report at # . diff --git a/tests/packages.scm b/tests/packages.scm index af8941c2e2..5d5abcbd76 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -187,6 +187,29 @@ (define %store (string=? (manifest-pattern-version pattern) "1") (string=? (manifest-pattern-output pattern) "out"))))))) +(test-equal "transaction-upgrade-entry, transformation options preserved" + (derivation-file-name (package-derivation %store grep)) + + (let* ((old (dummy-package "emacs" (version "1"))) + (props '((transformations . ((with-input . "emacs=grep"))))) + (tx (transaction-upgrade-entry + %store + (manifest-entry + (inherit (package->manifest-entry old)) + (properties props) + (item (string-append (%store-prefix) "/" + (make-string 32 #\e) "-foo-1"))) + (manifest-transaction)))) + (match (manifest-transaction-install tx) + (((? manifest-entry? entry)) + (and (string=? (manifest-entry-version entry) + (package-version grep)) + (string=? (manifest-entry-name entry) + (package-name grep)) + (equal? (manifest-entry-properties entry) props) + (derivation-file-name + (package-derivation %store (manifest-entry-item entry)))))))) + (test-assert "transaction-upgrade-entry, grafts" ;; Ensure that, when grafts are enabled, 'transaction-upgrade-entry' doesn't ;; try to build stuff. -- cgit v1.2.3 From 0f53c801b91919380a924b402d1ff822bb1dc6ea Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 2 Oct 2020 23:17:40 +0200 Subject: environment: Provide /etc/hosts in containers without '--network'. Fixes . * guix/scripts/environment.scm (launch-environment/container): Create /etc/hosts when NETWORK? is false. * tests/guix-environment-container.sh: Add "localhost" resolution test. --- guix/scripts/environment.scm | 7 +++++++ tests/guix-environment-container.sh | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'guix') diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index e2e481dd02..9698111cd2 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -549,6 +549,13 @@ (define (optional-mapping->fs mapping) (write-passwd (list passwd)) (write-group groups) + (unless network? + ;; When isolated from the network, provide a minimal /etc/hosts + ;; to resolve "localhost". + (call-with-output-file "/etc/hosts" + (lambda (port) + (display "127.0.0.1 localhost\n" port)))) + ;; For convenience, start in the user's current working ;; directory or, if unmapped, the home directory. (chdir (if map-cwd? diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 040f32cce9..3674aa6026 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -44,6 +44,10 @@ else test $? = 42 fi +# Make sure "localhost" resolves. +guix environment --container --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c '(exit (pair? (getaddrinfo "localhost" "80")))' + # Make sure '--preserve' is honored. result="`FOOBAR=42; export FOOBAR; guix environment -C --ad-hoc --bootstrap \ guile-bootstrap -E ^FOO -- guile -c '(display (getenv \"FOOBAR\"))'`" -- cgit v1.2.3 From b68d4106518abed20ba308831b65dcc69bf120a5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 4 Oct 2020 22:40:26 +0200 Subject: environment: Turn "lo" up in network-less containers. This is a followup to 0f53c801b91919380a924b402d1ff822bb1dc6ea. * guix/scripts/environment.scm (launch-environment/container): Add call to 'set-network-interface-up'. * tests/guix-environment-container.sh: Add test. --- guix/scripts/environment.scm | 6 +++++- tests/guix-environment-container.sh | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 9698111cd2..085f11a9d4 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -34,6 +34,7 @@ (define-module (guix scripts environment) #:use-module (guix scripts build) #:use-module (gnu build linux-container) #:use-module (gnu build accounts) + #:use-module ((guix build syscalls) #:select (set-network-interface-up)) #:use-module (gnu system linux-container) #:use-module (gnu system file-systems) #:use-module (gnu packages) @@ -554,7 +555,10 @@ (define (optional-mapping->fs mapping) ;; to resolve "localhost". (call-with-output-file "/etc/hosts" (lambda (port) - (display "127.0.0.1 localhost\n" port)))) + (display "127.0.0.1 localhost\n" port))) + + ;; Allow local AF_INET communications. + (set-network-interface-up "lo")) ;; For convenience, start in the user's current working ;; directory or, if unmapped, the home directory. diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh index 3674aa6026..f2d15c8d0c 100644 --- a/tests/guix-environment-container.sh +++ b/tests/guix-environment-container.sh @@ -48,6 +48,17 @@ fi guix environment --container --ad-hoc --bootstrap guile-bootstrap \ -- guile -c '(exit (pair? (getaddrinfo "localhost" "80")))' +# We should get ECONNREFUSED, not ENETUNREACH, which would indicate that "lo" +# is down. +guix environment --container --ad-hoc --bootstrap guile-bootstrap \ + -- guile -c "(exit (= ECONNREFUSED + (catch 'system-error + (lambda () + (let ((sock (socket AF_INET SOCK_STREAM 0))) + (connect sock AF_INET INADDR_LOOPBACK 12345))) + (lambda args + (pk 'errno (system-error-errno args))))))" + # Make sure '--preserve' is honored. result="`FOOBAR=42; export FOOBAR; guix environment -C --ad-hoc --bootstrap \ guile-bootstrap -E ^FOO -- guile -c '(display (getenv \"FOOBAR\"))'`" -- cgit v1.2.3 From 1d4ab335b22a93e01c2eb1eb3e93fc6534157040 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 30 Sep 2020 22:40:59 +0200 Subject: self: Use a 'guile' that doesn't complain about locales. Since commit ba48895899a117d6ace2209c3f54411a4a989133, selected UTF-8 locales are bundled. However, because 'guix-command' is itself a Guile script, users would still see Guile's warning, particularly on foreign distros: $ LC_ALL=sdf guix foo guile: warning: failed to install locale hint: Consider installing the `glibc-utf8-locales' [...] User commands would print that warning, but more importantly, each invocation of 'guix substitute' would print it, even though 'guix-daemon.service' explicitly chooses "en_US.utf8", which is in 'glibc-utf8-locales'. This leads to confusion since users would keep seeing this message unless/until they realize they also need to install 'glibc-utf8-locales' in root's profile. This patch gets rid of "guile: warning: ..." for a guix-pulled 'guix' command. * guix/self.scm (specification->package): Add "gcc-toolchain". (quiet-guile): New procedure. (guix-command): Use it. * gnu/packages/aux-files/guile-launcher.c: New file. * Makefile.am (AUX_FILES): Add it. --- Makefile.am | 1 + gnu/packages/aux-files/guile-launcher.c | 46 +++++++++++++++++++++++++++++++ guix/self.scm | 48 ++++++++++++++++++++++++++++++++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/aux-files/guile-launcher.c (limited to 'guix') diff --git a/Makefile.am b/Makefile.am index 26973d14d9..01a3dc10ef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -330,6 +330,7 @@ dist_noinst_DATA = \ # Auxiliary files for packages. AUX_FILES = \ + gnu/packages/aux-files/guile-launcher.c \ gnu/packages/aux-files/chromium/master-preferences.json \ gnu/packages/aux-files/emacs/guix-emacs.el \ gnu/packages/aux-files/linux-libre/5.8-arm.conf \ diff --git a/gnu/packages/aux-files/guile-launcher.c b/gnu/packages/aux-files/guile-launcher.c new file mode 100644 index 0000000000..886ede2846 --- /dev/null +++ b/gnu/packages/aux-files/guile-launcher.c @@ -0,0 +1,46 @@ +/* GNU Guix --- Functional package management for GNU + Copyright 1996-1997,2000-2001,2006,2008,2011,2013,2018 + Free Software Foundation, Inc. + Copyright (C) 2020 Ludovic Courtès + + 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 . */ + +/* This file implements a variant of the 'guile' executable that does not + complain about locale issues. */ + +#include +#include + +static void +inner_main (void *unused, int argc, char **argv) +{ + scm_shell (argc, argv); +} + +int +main (int argc, char **argv) +{ + /* Try to install the current locale; remain silent if it fails. */ + if (setlocale (LC_ALL, "") == NULL) + /* The 'guix pull'-provided 'guix' includes at least en_US.utf8 so use + that. That gives us UTF-8 support for 'scm_to_locale_string', etc., + which is always preferable over the C locale. */ + setlocale (LC_ALL, "en_US.utf8"); + + scm_install_gmp_memory_functions = 1; + scm_boot_guile (argc, argv, inner_main, 0); + return 0; /* never reached */ +} diff --git a/guix/self.scm b/guix/self.scm index 5eb80f42fe..bbfd2f1b95 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -27,6 +27,7 @@ (define-module (guix self) #:use-module (guix packages) #:use-module (guix sets) #:use-module (guix modules) + #:use-module ((guix utils) #:select (version-major+minor)) #:use-module ((guix build utils) #:select (find-files)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) @@ -62,6 +63,7 @@ (define specification->package ("xz" (ref '(gnu packages compression) 'xz)) ("po4a" (ref '(gnu packages gettext) 'po4a)) ("gettext" (ref '(gnu packages gettext) 'gettext-minimal)) + ("gcc-toolchain" (ref '(gnu packages commencement) 'gcc-toolchain)) (_ #f)))) ;no such package @@ -580,6 +582,48 @@ (define (objects directory) (computed-file name build)) +(define (quiet-guile guile) + "Return a wrapper that does the same as the 'guile' executable of GUILE, +except that it does not complain about locales and falls back to 'en_US.utf8' +instead of 'C'." + (define gcc + (specification->package "gcc-toolchain")) + + (define source + (search-path %load-path + "gnu/packages/aux-files/guile-launcher.c")) + + (define effective + (version-major+minor (package-version guile))) + + (define build + ;; XXX: Reuse from (guix scripts pack) instead? + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (srfi srfi-26)) + + (mkdir-p (string-append #$output "/bin")) + + (setenv "PATH" #$(file-append gcc "/bin")) + (setenv "C_INCLUDE_PATH" + (string-join + (map (cut string-append <> "/include") + '#$(match (bag-transitive-build-inputs + (package->bag guile)) + (((labels packages . _) ...) + (filter package? packages)))) + ":")) + (setenv "LIBRARY_PATH" #$(file-append gcc "/lib")) + + (invoke "gcc" #$(local-file source) "-Wall" "-g0" "-O2" + "-I" #$(file-append guile "/include/guile/" effective) + "-L" #$(file-append guile "/lib") + #$(string-append "-lguile-" effective) + "-o" (string-append #$output "/bin/guile"))))) + + (computed-file "guile-wrapper" build)) + (define* (guix-command modules #:key source (dependencies '()) guile (guile-version (effective-version))) @@ -634,7 +678,9 @@ (define module-directory ;; XXX: It would be more convenient to change it to: ;; (exit (apply guix-main (command-line))) (apply guix-main (command-line)))) - #:guile guile)) + + ;; Use a 'guile' variant that doesn't complain about locales. + #:guile (quiet-guile guile))) (define (miscellaneous-files source) "Return data files taken from SOURCE." -- cgit v1.2.3 From c1cc0c4865a8bfff43c5c9bd6ae8dcadb061c8a0 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Tue, 6 Oct 2020 10:29:47 +0300 Subject: build-system/cargo: Don't install .crates.toml file. Fixes . * guix/build/cargo-build-system.scm (install): Remove installed .crates.toml file. --- guix/build/cargo-build-system.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 95e8dd772a..117c8da66c 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -173,7 +173,13 @@ (define* (install #:key inputs outputs skip-build? features #:allow-other-keys) (or skip-build? (not (has-executable-target?)) (invoke "cargo" "install" "--path" "." "--root" out - "--features" (string-join features))))) + "--features" (string-join features))) + + ;; This is a file which we definitely don't need installed. + (when (file-exists? (string-append out "/.crates.toml")) + (delete-file (string-append out "/.crates.toml"))) + + #t)) (define %standard-phases (modify-phases gnu:%standard-phases -- cgit v1.2.3 From a5a3f813c74aa8143af1e42a3d754f1bf7be2fb0 Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 5 Oct 2020 18:36:34 +0200 Subject: build: hg: Handle fetch errors. * guix/build/hg.scm (hg-fetch): Add 'guard' to handle errors. Signed-off-by: Mathieu Othacehe --- guix/build/hg.scm | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'guix') diff --git a/guix/build/hg.scm b/guix/build/hg.scm index b3e3ff7ac3..1cceb63433 100644 --- a/guix/build/hg.scm +++ b/guix/build/hg.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016 Ricardo Wurmus ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2018 Björn Höfling +;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,8 @@ (define-module (guix build hg) #:use-module (guix build utils) + #:use-module (srfi srfi-34) + #:use-module (ice-9 format) #:export (hg-fetch)) ;;; Commentary: @@ -35,22 +38,35 @@ (define* (hg-fetch url changeset directory "Fetch CHANGESET from URL into DIRECTORY. CHANGESET must be a valid Mercurial changeset identifier. Return #t on success, #f otherwise." - (invoke hg-command - "clone" url - "--rev" changeset - ;; Disable TLS certificate verification. The hash of - ;; the checkout is known in advance anyway. - "--insecure" - directory) - - ;; The contents of '.hg' vary as a function of the current - ;; status of the Mercurial repo. Since we want a fixed - ;; output, this directory needs to be taken out. - ;; Since the '.hg' file is also in sub-modules, we have to - ;; search for it in all sub-directories. - (for-each delete-file-recursively - (find-files directory "^\\.hg$" #:directories? #t)) - - #t) + (mkdir-p directory) + + (guard (c ((invoke-error? c) + (format (current-error-port) + "hg-fetch: '~a~{ ~a~}' failed with exit code ~a~%" + (invoke-error-program c) + (invoke-error-arguments c) + (or (invoke-error-exit-status c) + (invoke-error-stop-signal c) + (invoke-error-term-signal c))) + (delete-file-recursively directory) + #f)) + (with-directory-excursion directory + (invoke hg-command + "clone" url + "--rev" changeset + ;; Disable TLS certificate verification. The hash of + ;; the checkout is known in advance anyway. + "--insecure" + directory) + + ;; The contents of '.hg' vary as a function of the current + ;; status of the Mercurial repo. Since we want a fixed + ;; output, this directory needs to be taken out. + ;; Since the '.hg' file is also in sub-modules, we have to + ;; search for it in all sub-directories. + (for-each delete-file-recursively + (find-files directory "^\\.hg$" #:directories? #t)) + + #t))) ;;; hg.scm ends here -- cgit v1.2.3 From 2fb12dd1bb725592e1561ac8f4b32fb68accb161 Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 5 Oct 2020 18:47:39 +0200 Subject: build: svn: Handle fetch errors. * guix/build/svn.scm (svn-fetch): Add 'guard' to handle errors. Signed-off-by: Mathieu Othacehe --- guix/build/svn.scm | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'guix') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 33783f3056..48d28f0327 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver +;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,8 @@ (define-module (guix build svn) #:use-module (guix build utils) + #:use-module (srfi srfi-34) + #:use-module (ice-9 format) #:export (svn-fetch)) ;;; Commentary: @@ -36,20 +39,33 @@ (define* (svn-fetch url revision directory (password #f)) "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." - (apply invoke svn-command - "export" "--non-interactive" - ;; Trust the server certificate. This is OK as we - ;; verify the checksum later. This can be removed when - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t) + (mkdir-p directory) + + (guard (c ((invoke-error? c) + (format (current-error-port) + "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%" + (invoke-error-program c) + (invoke-error-arguments c) + (or (invoke-error-exit-status c) + (invoke-error-stop-signal c) + (invoke-error-term-signal c))) + (delete-file-recursively directory) + #f)) + (with-directory-excursion directory + (apply invoke svn-command + "export" "--non-interactive" + ;; Trust the server certificate. This is OK as we + ;; verify the checksum later. This can be removed when + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t))) ;;; svn.scm ends here -- cgit v1.2.3 From 1ec67d5220b0ebac20263b44f4fefaf51ba8fdbb Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Tue, 6 Oct 2020 14:44:09 +0100 Subject: Revert "build: svn: Handle fetch errors." This reverts commit 2fb12dd1bb725592e1561ac8f4b32fb68accb161, which causes the 'svn export' command to fail with: svn: E155000: Destination directory exists; please remove the directory or use --force to overwrite --- guix/build/svn.scm | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'guix') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 48d28f0327..33783f3056 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,7 +2,6 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver -;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,8 +20,6 @@ (define-module (guix build svn) #:use-module (guix build utils) - #:use-module (srfi srfi-34) - #:use-module (ice-9 format) #:export (svn-fetch)) ;;; Commentary: @@ -39,33 +36,20 @@ (define* (svn-fetch url revision directory (password #f)) "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." - (mkdir-p directory) - - (guard (c ((invoke-error? c) - (format (current-error-port) - "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%" - (invoke-error-program c) - (invoke-error-arguments c) - (or (invoke-error-exit-status c) - (invoke-error-stop-signal c) - (invoke-error-term-signal c))) - (delete-file-recursively directory) - #f)) - (with-directory-excursion directory - (apply invoke svn-command - "export" "--non-interactive" - ;; Trust the server certificate. This is OK as we - ;; verify the checksum later. This can be removed when - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t))) + (apply invoke svn-command + "export" "--non-interactive" + ;; Trust the server certificate. This is OK as we + ;; verify the checksum later. This can be removed when + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t) ;;; svn.scm ends here -- cgit v1.2.3 From db9e4af0ead4b02e1a70f358de995c43249b8bcf Mon Sep 17 00:00:00 2001 From: zimoun Date: Wed, 7 Oct 2020 01:05:21 +0200 Subject: build: svn: Fix handle fetch errors. This fixes the revert 1ec67d5220b0ebac20263b44f4fefaf51ba8fdbb. * guix/build/svn.scm (svn-fetch): Add 'guard' to handle errors. Signed-off-by: Mathieu Othacehe --- guix/build/svn.scm | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'guix') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 33783f3056..f6b4ca0776 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver +;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,6 +21,8 @@ (define-module (guix build svn) #:use-module (guix build utils) + #:use-module (srfi srfi-34) + #:use-module (ice-9 format) #:export (svn-fetch)) ;;; Commentary: @@ -36,20 +39,29 @@ (define* (svn-fetch url revision directory (password #f)) "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." - (apply invoke svn-command - "export" "--non-interactive" - ;; Trust the server certificate. This is OK as we - ;; verify the checksum later. This can be removed when - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t) + (guard (c ((invoke-error? c) + (format (current-error-port) + "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%" + (invoke-error-program c) + (invoke-error-arguments c) + (or (invoke-error-exit-status c) + (invoke-error-stop-signal c) + (invoke-error-term-signal c))) + #f)) + (apply invoke svn-command + "export" "--non-interactive" + ;; Trust the server certificate. This is OK as we + ;; verify the checksum later. This can be removed when + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t)) ;;; svn.scm ends here -- cgit v1.2.3 From efbf5fdd01817ea75de369e3dd2761a85f8f7dd5 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sat, 3 Oct 2020 01:17:54 -0400 Subject: offload: Improve load normalization and configurability. Fixes . The computed normalized load was previously obtained by dividing the load average as found in /proc/loadavg by the number of parallel builds defined for a build machine. This normalized load didn't allow to compare machines with different number of cores, as the load average reported by /proc/loadavg can be as high as the number of cores; thus comparing that value to a fixed threshold of 2.0 would mean machines with multiple cores were more likely to be flagged as overloaded compared to single core machines. This can be fixed by normalizing using the available number of cores instead of the number of parallel jobs. * guix/scripts/offload.scm ()[overload-threshold]: New field. (node-load): Modify to return a normalized load value between 0 and 1, taking into account the number of cores available. (normalized-load): Remove procedure. (report-load): New procedure. (choose-build-machine): Adjust to use the modified 'node-load' and the new 'report-load' and 'build-machine-overload-threshold' procedures. (check-machine-status): Adjust. * doc/guix.texi (Daemon Offload Setup): Document the offload scheduler and the new 'overload-threshold' field. --- doc/guix.texi | 30 ++++++++++++++++++++++++++- guix/scripts/offload.scm | 54 +++++++++++++++++++++++++++++------------------- 2 files changed, 62 insertions(+), 22 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 3fc76c8670..553a3b8ae9 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1081,7 +1081,28 @@ architecture natively supports it, via emulation (@pxref{Transparent Emulation with QEMU}), or both. Missing prerequisites for the build are copied over SSH to the target machine, which then proceeds with the build; upon success the output(s) of the build are copied back to the -initial machine. +initial machine. The offload facility comes with a basic scheduler that +attempts to select the best machine. The best machine is chosen among +the available machines based on criteria such as: + +@enumerate +@item +The availability of a build slot. A build machine can have as many +build slots (connections) as the value of the @code{parallel-builds} +field of its @code{build-machine} object. + +@item +Its relative speed, as defined via the @code{speed} field of its +@code{build-machine} object. + +@item +Its load. The normalized machine load must be lower than a threshold +value, configurable via the @code{overload-threshold} field of its +@code{build-machine} object. + +@item +Disk space availability. More than a 100 MiB must be available. +@end enumerate The @file{/etc/guix/machines.scm} file typically looks like this: @@ -1185,6 +1206,13 @@ when transferring files to and from build machines. File name of the Unix-domain socket @command{guix-daemon} is listening to on that machine. +@item @code{overload-threshold} (default: @code{0.6}) +The load threshold above which a potential offload machine is +disregarded by the offload scheduler. The value roughly translates to +the total processor usage of the build machine, ranging from 0.0 (0%) to +1.0 (100%). It can also be disabled by setting +@code{overload-threshold} to @code{#f}. + @item @code{parallel-builds} (default: @code{1}) The number of builds that may run in parallel on the machine. diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 3dc8ccefcb..a5fe98b675 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -88,6 +88,10 @@ (define-record-type* (default 3)) (daemon-socket build-machine-daemon-socket ; string (default "/var/guix/daemon-socket/socket")) + ;; A #f value tells the offload scheduler to disregard the load of the build + ;; machine when selecting the best offload machine. + (overload-threshold build-machine-overload-threshold ; inexact real between + (default 0.6)) ; 0.0 and 1.0 | #f (parallel-builds build-machine-parallel-builds ; number (default 1)) (speed build-machine-speed ; inexact real @@ -391,30 +395,34 @@ (define %minimum-disk-space (* 100 (expt 2 20))) ;100 MiB (define (node-load node) - "Return the load on NODE. Return +∞ if NODE is misbehaving." + "Return the load on NODE, a normalized value between 0.0 and 1.0. The value +is derived from /proc/loadavg and normalized according to the number of +logical cores available, to give a rough estimation of CPU usage. Return +1.0 (fully loaded) if NODE is misbehaving." (let ((line (inferior-eval '(begin (use-modules (ice-9 rdelim)) (call-with-input-file "/proc/loadavg" read-string)) - node))) - (if (eof-object? line) - +inf.0 ;MACHINE does not respond, so assume it is infinitely loaded + node)) + (ncores (inferior-eval '(begin + (use-modules (ice-9 threads)) + (current-processor-count)) + node))) + (if (or (eof-object? line) (eof-object? ncores)) + 1.0 ;MACHINE does not respond, so assume it is fully loaded (match (string-tokenize line) ((one five fifteen . x) - (string->number one)) + (let ((load (/ (string->number one) ncores))) + (if (> load 1.0) + 1.0 + load))) (x - +inf.0))))) - -(define (normalized-load machine load) - "Divide LOAD by the number of parallel builds of MACHINE." - (if (rational? load) - (let* ((jobs (build-machine-parallel-builds machine)) - (normalized (/ load jobs))) - (format (current-error-port) "load on machine '~a' is ~s\ - (normalized: ~s)~%" - (build-machine-name machine) load normalized) - normalized) - load)) + 1.0))))) + +(define (report-load machine load) + (format (current-error-port) + "normalized load on machine '~a' is ~,2f~%" + (build-machine-name machine) load)) (define (random-seed) (logxor (getpid) (car (gettimeofday)))) @@ -472,11 +480,15 @@ (define (machine-faster? m1 m2) (let* ((session (false-if-exception (open-ssh-session best %short-timeout))) (node (and session (remote-inferior session))) - (load (and node (normalized-load best (node-load node)))) + (load (and node (node-load node))) + (threshold (build-machine-overload-threshold best)) (space (and node (node-free-disk-space node)))) + (when load (report-load best load)) (when node (close-inferior node)) (when session (disconnect! session)) - (if (and node (< load 2.) (>= space %minimum-disk-space)) + (if (and node + (or (not threshold) (< load threshold)) + (>= space %minimum-disk-space)) (match others (((machines slots) ...) ;; Release slots from the uninteresting machines. @@ -708,13 +720,13 @@ (define session (free (node-free-disk-space inferior))) (close-inferior inferior) (format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\ - host name: ~a~% normalized load: ~a~% free disk space: ~,2f MiB~%\ + host name: ~a~% normalized load: ~,2f~% free disk space: ~,2f MiB~%\ time difference: ~a s~%" (build-machine-name machine) (utsname:sysname uts) (utsname:release uts) (utsname:machine uts) (utsname:nodename uts) - (normalized-load machine load) + load (/ free (expt 2 20) 1.) (- time now)))))))) -- cgit v1.2.3 From b55409b2c0a0cb53f251ceab7746d35805b64ab7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 10 Oct 2020 00:03:57 +0200 Subject: svn-download, hg-download: Use 'report-invoke-error'. * guix/build/hg.scm (hg-fetch): Use 'report-invoke-error' instead of 'format'. * guix/build/svn.scm (svn-fetch): Likewise. --- guix/build/hg.scm | 8 +------- guix/build/svn.scm | 10 ++-------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'guix') diff --git a/guix/build/hg.scm b/guix/build/hg.scm index 1cceb63433..0ffad7fa2d 100644 --- a/guix/build/hg.scm +++ b/guix/build/hg.scm @@ -41,13 +41,7 @@ (define* (hg-fetch url changeset directory (mkdir-p directory) (guard (c ((invoke-error? c) - (format (current-error-port) - "hg-fetch: '~a~{ ~a~}' failed with exit code ~a~%" - (invoke-error-program c) - (invoke-error-arguments c) - (or (invoke-error-exit-status c) - (invoke-error-stop-signal c) - (invoke-error-term-signal c))) + (report-invoke-error c) (delete-file-recursively directory) #f)) (with-directory-excursion directory diff --git a/guix/build/svn.scm b/guix/build/svn.scm index f6b4ca0776..44d77a968f 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014 Ludovic Courtès +;;; Copyright © 2014, 2020 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2020 Simon Tournier @@ -40,13 +40,7 @@ (define* (svn-fetch url revision directory "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." (guard (c ((invoke-error? c) - (format (current-error-port) - "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%" - (invoke-error-program c) - (invoke-error-arguments c) - (or (invoke-error-exit-status c) - (invoke-error-stop-signal c) - (invoke-error-term-signal c))) + (report-invoke-error c) #f)) (apply invoke svn-command "export" "--non-interactive" -- cgit v1.2.3 From cda046b3eaeb60f756fa4964c4b2721a2d680192 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 11 Oct 2020 16:30:38 +0200 Subject: reconfigure: Start services not currently running. Fixes . Reported by Andreas Enge . The bug was introduced in 5c793753b31b1dcd9a554bce953124f7ae88ca9a, which changed the way TO-START is computed: as a function of the running services first, and then as a function of the live services (which includes services not currently running). * guix/scripts/system/reconfigure.scm (running-services): Serialize the 'running' field and return it. (upgrade-shepherd-services): Comput RUNNING. Compute TO-START as the difference between TARGET-SERVICES and RUNNING. --- guix/scripts/system/reconfigure.scm | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'guix') diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm index 45bb1d5d3b..d89caf80fc 100644 --- a/guix/scripts/system/reconfigure.scm +++ b/guix/scripts/system/reconfigure.scm @@ -126,22 +126,25 @@ (define (running-services eval) (define exp (with-imported-modules '((gnu services herd)) #~(begin - (use-modules (gnu services herd)) + (use-modules (gnu services herd) + (ice-9 match)) + (let ((services (current-services))) (and services - ;; 'live-service-running' is ignored, as we can't necessarily - ;; serialize arbitrary objects. This should be fine for now, - ;; since 'machine-current-services' is not exposed publicly, - ;; and the resultant objects are only used for - ;; resolving service dependencies. (map (lambda (service) (list (live-service-provision service) - (live-service-requirement service))) + (live-service-requirement service) + (match (live-service-running service) + (#f #f) + (#t #t) + ((? number? pid) pid) + (_ #t)))) ;not serializable services)))))) + (mlet %store-monad ((services (eval exp))) (return (map (match-lambda - ((provision requirement) - (live-service provision requirement #f))) + ((provision requirement running) + (live-service provision requirement running))) services)))) ;; XXX: Currently, this does NOT attempt to restart running services. See @@ -181,13 +184,14 @@ (define target-services (mlet* %store-monad ((live-services (running-services eval))) (let*-values (((to-unload to-restart) (shepherd-service-upgrade live-services target-services))) - (let* ((to-unload (map live-service-canonical-name to-unload)) + (let* ((to-unload (map live-service-canonical-name to-unload)) (to-restart (map shepherd-service-canonical-name to-restart)) - (to-start (lset-difference eqv? - (map shepherd-service-canonical-name - target-services) - (map live-service-canonical-name - live-services))) + (running (map live-service-canonical-name + (filter live-service-running live-services))) + (to-start (lset-difference eqv? + (map shepherd-service-canonical-name + target-services) + running)) (service-files (map shepherd-service-file target-services))) (eval #~(parameterize ((current-warning-port (%make-void-port "w"))) (primitive-load #$(upgrade-services-program service-files -- cgit v1.2.3 From 6c46e477eb50c6ee7c9b7c8199bdfb3708dc32b5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Oct 2020 10:10:03 +0200 Subject: channels: Address test failure. Fixes . Reported by Maxim Cournoyer . The "channel-instances->manifest" test would fail since 1d4ab335b22a93e01c2eb1eb3e93fc6534157040: 'quiet-guile' would be passed #f as GUILE, and thus 'package-version' would fail with wrong-type-arg. * guix/channels.scm (whole-package-for-legacy): Pass #:guile to 'whole-package'. * tests/channels.scm ("channel-instances->manifest"): Remove 'test-expect-fail'. --- guix/channels.scm | 3 ++- tests/channels.scm | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/channels.scm b/guix/channels.scm index ad2442f50e..916d663e9f 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -783,7 +783,8 @@ (define lib ;; derivation that builds modules. We have to infer what the ;; dependencies of these modules were. (list guile-json-3 guile-git guile-bytestructures - (ssh -> guile-ssh) (tls -> gnutls))))) + (ssh -> guile-ssh) (tls -> gnutls)) + #:guile (default-guile)))) (define (old-style-guix? drv) "Return true if DRV corresponds to a ~/.config/guix/latest style of diff --git a/tests/channels.scm b/tests/channels.scm index ba8cfe639e..1b6f640c4a 100644 --- a/tests/channels.scm +++ b/tests/channels.scm @@ -230,7 +230,6 @@ (define (validate-pull channel current commit relation) #:current-channels (list new) #:validate-pull validate-pull))))))) -(test-expect-fail 1) ;see: https://issues.guix.gnu.org/43940 (test-assert "channel-instances->manifest" ;; Compute the manifest for a graph of instances and make sure we get a ;; derivation graph that mirrors the instance graph. This test also ensures -- cgit v1.2.3 From d11f7f62b6ba2fbef8e4b00c7ae0d621f2d4281c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Oct 2020 11:19:32 +0200 Subject: http-client: 'http-fetch' and 'http-fetch/cached' accept #:timeout. * guix/http-client.scm (http-fetch): Add #:timeout and pass it to 'guix:open-connection-for-uri'. (http-fetch/cached): Add #:timeout parameter and pass it to 'http-fetch'. --- guix/http-client.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/guix/http-client.scm b/guix/http-client.scm index 5a5a33b4c0..a767175d67 100644 --- a/guix/http-client.scm +++ b/guix/http-client.scm @@ -71,7 +71,8 @@ (define-condition-type &http-get-error &error (define* (http-fetch uri #:key port (text? #f) (buffered? #t) (verify-certificate? #t) - (headers '((user-agent . "GNU Guile")))) + (headers '((user-agent . "GNU Guile"))) + timeout) "Return an input port containing the data at URI, and the expected number of bytes available or #f. If TEXT? is true, the data at URI is considered to be textual. Follow any HTTP redirection. When BUFFERED? is #f, return an @@ -80,13 +81,17 @@ (define* (http-fetch uri #:key port (text? #f) (buffered? #t) When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates. +TIMEOUT specifies the timeout in seconds for connection establishment; when +TIMEOUT is #f, connection establishment never times out. + Raise an '&http-get-error' condition if downloading fails." (let loop ((uri (if (string? uri) (string->uri uri) uri))) (let ((port (or port (guix:open-connection-for-uri uri #:verify-certificate? - verify-certificate?))) + verify-certificate? + #:timeout timeout))) (headers (match (uri-userinfo uri) ((? string? str) (cons (cons 'Authorization @@ -155,13 +160,16 @@ (define (cache-file-for-uri uri) (define* (http-fetch/cached uri #:key (ttl (%http-cache-ttl)) text? (write-cache dump-port) - (cache-miss (const #t))) + (cache-miss (const #t)) + (timeout 10)) "Like 'http-fetch', return an input port, but cache its contents in ~/.cache/guix. The cache remains valid for TTL seconds. Call WRITE-CACHE with the HTTP input port and the cache output port to write the data to cache. Call CACHE-MISS with URI just before fetching data from -URI." +URI. + +TIMEOUT specifies the timeout in seconds for connection establishment." (let ((file (cache-file-for-uri uri))) (define (update-cache cache-port) (define cache-time @@ -183,7 +191,7 @@ (define headers cache-port) (raise c)))) (let ((port (http-fetch uri #:text? text? - #:headers headers))) + #:headers headers #:timeout timeout))) (cache-miss uri) (mkdir-p (dirname file)) (when cache-port -- cgit v1.2.3 From baa4a2ef8109601dcd6d28b16d2d41c203f849e4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Oct 2020 11:25:09 +0200 Subject: lint: cve: Set a connection timeout. This (notably) works around the fact that nvd.nist.gov is currently inaccessible over IPv6. * guix/cve.scm (fetch-vulnerabilities): Add #:timeout and pass it to 'http-fetch/cached'. (current-vulnerabilities): Add #:timeout and pass it to 'fetch-vulnerabilities'. * guix/lint.scm (current-vulnerabilities*): Pass #:timeout to 'current-vulnerabilities'. --- guix/cve.scm | 12 +++++++----- guix/lint.scm | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'guix') diff --git a/guix/cve.scm b/guix/cve.scm index 57b8459d01..b3a8b13a06 100644 --- a/guix/cve.scm +++ b/guix/cve.scm @@ -336,7 +336,7 @@ (define vulns ,(map vulnerability->sexp vulns)) cache)))) -(define (fetch-vulnerabilities year ttl) +(define* (fetch-vulnerabilities year ttl #:key (timeout 10)) "Return the list of for YEAR, assuming the on-disk cache has the given TTL (fetch from the NIST web site when TTL has expired)." (define (cache-miss uri) @@ -361,16 +361,18 @@ (define (read* port) (let* ((port (http-fetch/cached (yearly-feed-uri year) #:ttl ttl #:write-cache write-cache - #:cache-miss cache-miss)) + #:cache-miss cache-miss + #:timeout timeout)) (sexp (read* port))) (close-port port) (match sexp (('vulnerabilities 1 vulns) (map sexp->vulnerability vulns))))) -(define (current-vulnerabilities) +(define* (current-vulnerabilities #:key (timeout 10)) "Return the current list of Common Vulnerabilities and Exposures (CVE) as -published by the US NIST." +published by the US NIST. TIMEOUT specifies the timeout in seconds for +connection establishment." (let ((past-years (unfold (cut > <> 3) (lambda (n) (- %current-year n)) @@ -381,7 +383,7 @@ (define (current-vulnerabilities) (* n %past-year-ttl)) 1+ 1))) - (append-map fetch-vulnerabilities + (append-map (cut fetch-vulnerabilities <> <> #:timeout timeout) (cons %current-year past-years) (cons %current-year-ttl past-ttls)))) diff --git a/guix/lint.scm b/guix/lint.scm index ec43a4dcad..e1a77e8ac7 100644 --- a/guix/lint.scm +++ b/guix/lint.scm @@ -1084,7 +1084,7 @@ (define (current-vulnerabilities*) the NIST server non-fatal." (with-networking-fail-safe (G_ "while retrieving CVE vulnerabilities") '() - (current-vulnerabilities))) + (current-vulnerabilities #:timeout 4))) (define package-vulnerabilities (let ((lookup (delay (vulnerabilities->lookup-proc -- cgit v1.2.3 From 75e72dd34ef7001ac16e1abfd117672378326aad Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Oct 2020 11:48:45 +0200 Subject: upgrade: Mention '--do-not-upgrade' in '--help' output. * guix/scripts/upgrade.scm (show-help): Add '--do-not-upgrade'. --- guix/scripts/upgrade.scm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'guix') diff --git a/guix/scripts/upgrade.scm b/guix/scripts/upgrade.scm index 8c7abd133a..5ec844328e 100644 --- a/guix/scripts/upgrade.scm +++ b/guix/scripts/upgrade.scm @@ -36,6 +36,8 @@ (define (show-help) -p, --profile=PROFILE use PROFILE instead of the user's default profile")) (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) + (display (G_ " + --do-not-upgrade[=REGEXP] do not upgrade any packages matching REGEXP")) (newline) (show-build-options-help) (newline) -- cgit v1.2.3 From 099d709caf55db44414475c27b7b39f8becb0d64 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 12 Oct 2020 17:30:35 +0200 Subject: substitute: Reduce default narinfo negative TTL to 1h. * guix/scripts/substitute.scm (%narinfo-negative-ttl): Reduce to 1h. --- guix/scripts/substitute.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 26613df68f..7ec170b08a 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -137,7 +137,7 @@ (define %narinfo-ttl (define %narinfo-negative-ttl ;; Likewise, but for negative lookups---i.e., cached lookup failures (404). - (* 3 3600)) + (* 1 3600)) (define %narinfo-transient-error-ttl ;; Likewise, but for transient errors such as 504 ("Gateway timeout"). -- cgit v1.2.3 From 46135ce4cefab9e164d75697d7ea0c8359b842e4 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 28 Sep 2020 17:36:42 +0200 Subject: packages: Add 'package-with-c-toolchain'. * guix/build-system.scm (build-system-with-c-toolchain): New procedure. * guix/packages.scm (package-with-c-toolchain): New procedure. * tests/packages.scm ("package-with-c-toolchain"): New test. * doc/guix.texi (package Reference): Document 'package-with-c-toolchain'. (Build Systems): Mention it. --- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ guix/build-system.scm | 35 +++++++++++++++++++++++++++++++++-- guix/packages.scm | 9 +++++++++ tests/packages.scm | 20 ++++++++++++++++++++ 4 files changed, 94 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 8514dfe86f..e084144a82 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6558,6 +6558,35 @@ cross-compiling: It is an error to refer to @code{this-package} outside a package definition. @end deffn +Because packages are regular Scheme objects that capture a complete +dependency graph and associated build procedures, it is often useful to +write procedures that take a package and return a modified version +thereof according to some parameters. Below are a few examples. + +@cindex tool chain, choosing a package's tool chain +@deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain} +Return a variant of @var{package} that uses @var{toolchain} instead of +the default GNU C/C++ toolchain. @var{toolchain} must be a list of +inputs (label/package tuples) providing equivalent functionality, such +as the @code{gcc-toolchain} package. + +The example below returns a variant of the @code{hello} package built +with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the +GNU C Library) instead of the default tool chain: + +@lisp +(let ((toolchain (specification->package "gcc-toolchain@@10"))) + (package-with-c-toolchain hello `(("toolchain" ,toolchain)))) +@end lisp + +The build tool chain is part of the @dfn{implicit inputs} of +packages---it's usually not listed as part of the various ``inputs'' +fields and is instead pulled in by the build system. Consequently, this +procedure works by changing the build system of @var{package} so that it +pulls in @var{toolchain} instead of the defaults. @ref{Build Systems}, +for more on build systems. +@end deffn + @node origin Reference @subsection @code{origin} Reference @@ -6694,6 +6723,9 @@ ornamentation---in other words, a bag is a lower-level representation of a package, which includes all the inputs of that package, including some that were implicitly added by the build system. This intermediate representation is then compiled to a derivation (@pxref{Derivations}). +The @code{package-with-c-toolchain} is an example of a way to change the +implicit inputs that a package's build system pulls in (@pxref{package +Reference, @code{package-with-c-toolchain}}). Build systems accept an optional list of @dfn{arguments}. In package definitions, these are passed @i{via} the @code{arguments} field diff --git a/guix/build-system.scm b/guix/build-system.scm index 4174972b98..76d670995c 100644 --- a/guix/build-system.scm +++ b/guix/build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +18,7 @@ (define-module (guix build-system) #:use-module (guix records) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (build-system build-system? @@ -37,7 +38,9 @@ (define-module (guix build-system) bag-arguments bag-build - make-bag)) + make-bag + + build-system-with-c-toolchain)) (define-record-type* build-system make-build-system build-system? @@ -98,3 +101,31 @@ (define* (make-bag build-system name #:outputs outputs #:target target arguments)))) + +(define (build-system-with-c-toolchain bs toolchain) + "Return a variant of BS, a build system, that uses TOOLCHAIN instead of the +default GNU C/C++ toolchain. TOOLCHAIN must be a list of +inputs (label/package tuples) providing equivalent functionality, such as the +'gcc-toolchain' package." + (define lower + (build-system-lower bs)) + + (define toolchain-packages + ;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTEM and + ;; all the build systems that inherit from it. Keep the list in sync with + ;; 'standard-packages' in (guix build-system gnu). + '("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) + + (define (lower* . args) + (let ((lowered (apply lower args))) + (bag + (inherit lowered) + (build-inputs + (append (fold alist-delete + (bag-build-inputs lowered) + toolchain-packages) + toolchain))))) + + (build-system + (inherit bs) + (lower lower*))) diff --git a/guix/packages.scm b/guix/packages.scm index 4f2bb432be..24d6417065 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -124,6 +124,7 @@ (define-module (guix packages) package-patched-vulnerabilities package-with-patches package-with-extra-patches + package-with-c-toolchain package/inherit transitive-input-references @@ -790,6 +791,14 @@ (define (package-with-extra-patches original patches) (append (origin-patches (package-source original)) patches))) +(define (package-with-c-toolchain package toolchain) + "Return a variant of PACKAGE that uses TOOLCHAIN instead of the default GNU +C/C++ toolchain. TOOLCHAIN must be a list of inputs (label/package tuples) +providing equivalent functionality, such as the 'gcc-toolchain' package." + (let ((bs (package-build-system package))) + (package/inherit package + (build-system (build-system-with-c-toolchain bs toolchain))))) + (define (transitive-inputs inputs) "Return the closure of INPUTS when considering the 'propagated-inputs' edges. Omit duplicate inputs, except for those already present in INPUTS diff --git a/tests/packages.scm b/tests/packages.scm index 5d5abcbd76..2d13d91344 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1430,6 +1430,26 @@ (define read-at (derivation-file-name (package-derivation %store coreutils)))))))) +(test-assert "package-with-c-toolchain" + (let* ((dep (dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("x" ,grep))))) + (p0 (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,dep))))) + (tc (dummy-package "my-toolchain")) + (p1 (package-with-c-toolchain p0 `(("toolchain" ,tc))))) + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (match (bag-build-inputs (package->bag p1)) + ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) + (and (not (any (cut member <> packages) toolchain-packages)) + (member "my-toolchain" packages) + (eq? foo grep) + (eq? bar dep)))))) + (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") -- cgit v1.2.3 From abd7a474615353149a44f4504f0b4b248dcc0716 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 28 Sep 2020 18:56:00 +0200 Subject: guix build: Add '--with-c-toolchain'. * guix/scripts/build.scm (package-dependents/spec) (package-toolchain-rewriting, transform-package-toolchain): New procedures. (%transformations): Add it. (%transformation-options, show-transformation-options-help): Add '--with-c-toolchain'. * tests/scripts-build.scm (depends-on-toolchain?): New procedure. ("options->transformation, with-c-toolchain") ("options->transformation, with-c-toolchain twice") New test. ("options->transformation, with-c-toolchain, no effect"): New tests. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 38 ++++++++++++++++++++++ guix/scripts/build.scm | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/scripts-build.scm | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index e084144a82..7150adeaa8 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9364,6 +9364,44 @@ must be compatible. If @var{replacement} is somehow incompatible with @var{package}, then the resulting package may be unusable. Use with care! +@cindex tool chain, changing the build tool chain of a package +@item --with-c-toolchain=@var{package}=@var{toolchain} +This option changes the compilation of @var{package} and everything that +depends on it so that they get built with @var{toolchain} instead of the +default GNU tool chain for C/C++. + +Consider this example: + +@example +guix build octave-cli \ + --with-c-toolchain=fftw=gcc-toolchain@@10 \ + --with-c-toolchain=fftwf=gcc-toolchain@@10 +@end example + +The command above builds a variant of the @code{fftw} and @code{fftwf} +packages using version 10 of @code{gcc-toolchain} instead of the default +tool chain, and then builds a variant of the GNU@tie{}Octave +command-line interface using them. GNU@tie{}Octave itself is also built +with @code{gcc-toolchain@@10}. + +This other example builds the Hardware Locality (@code{hwloc}) library +and its dependents up to @code{intel-mpi-benchmarks} with the Clang C +compiler: + +@example +guix build --with-c-toolchain=hwloc=clang-toolchain \ + intel-mpi-benchmarks +@end example + +@quotation Note +There can be application binary interface (ABI) incompatibilities among +tool chains. This is particularly true of the C++ standard library and +run-time support libraries such as that of OpenMP. By rebuilding all +dependents with the same tool chain, @option{--with-c-toolchain} minimizes +the risks of incompatibility but cannot entirely eliminate them. Choose +@var{package} wisely. +@end quotation + @item --with-git-url=@var{package}=@var{url} @cindex Git, using the latest commit @cindex latest commit, building diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 72a5d46347..e59e0ee67f 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -26,6 +26,7 @@ (define-module (guix scripts build) #:use-module (guix store) #:use-module (guix derivations) #:use-module (guix packages) + #:use-module (guix memoization) #:use-module (guix grafts) #:use-module (guix utils) @@ -396,6 +397,83 @@ (define rewrite (rewrite obj) obj))) +(define (package-dependents/spec top bottom) + "Return the list of dependents of BOTTOM, a spec string, that are also +dependencies of TOP, a package." + (define-values (name version) + (package-name->name+version bottom)) + + (define dependent? + (mlambda (p) + (and (package? p) + (or (and (string=? name (package-name p)) + (or (not version) + (version-prefix? version (package-version p)))) + (match (bag-direct-inputs (package->bag p)) + (((labels dependencies . _) ...) + (any dependent? dependencies))))))) + + (filter dependent? (package-closure (list top)))) + +(define (package-toolchain-rewriting p bottom toolchain) + "Return a procedure that, when passed a package that's either BOTTOM or one +of its dependents up to P so, changes it so it is built with TOOLCHAIN. +TOOLCHAIN must be an input list." + (define rewriting-property + (gensym " package-toolchain-rewriting")) + + (match (package-dependents/spec p bottom) + (() ;P does not depend on BOTTOM + identity) + (set + ;; SET is the list of packages "between" P and BOTTOM (included) whose + ;; toolchain needs to be changed. + (package-mapping (lambda (p) + (if (or (assq rewriting-property + (package-properties p)) + (not (memq p set))) + p + (let ((p (package-with-c-toolchain p toolchain))) + (package/inherit p + (properties `((,rewriting-property . #t) + ,@(package-properties p))))))) + (lambda (p) + (or (assq rewriting-property (package-properties p)) + (not (memq p set)))) + #:deep? #t)))) + +(define (transform-package-toolchain replacement-specs) + "Return a procedure that, when passed a package, changes its toolchain or +that of its dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is +a list of strings like \"fftw=gcc-toolchain@10\" meaning that the package to +the left of the equal sign must be built with the toolchain to the right of +the equal sign." + (define split-on-commas + (cute string-tokenize <> (char-set-complement (char-set #\,)))) + + (define (specification->input spec) + (let ((package (specification->package spec))) + (list (package-name package) package))) + + (define replacements + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((spec (= split-on-commas toolchain)) + (cons spec (map specification->input toolchain))) + (_ + (leave (G_ "~a: invalid toolchain replacement specification~%") + spec)))) + replacement-specs)) + + (lambda (store obj) + (if (package? obj) + (or (any (match-lambda + ((bottom . toolchain) + ((package-toolchain-rewriting obj bottom toolchain) obj))) + replacements) + obj) + obj))) + (define (transform-package-tests specs) "Return a procedure that, when passed a package, sets #:tests? #f in its 'arguments' field." @@ -426,6 +504,7 @@ (define %transformations (with-branch . ,transform-package-source-branch) (with-commit . ,transform-package-source-commit) (with-git-url . ,transform-package-source-git-url) + (with-c-toolchain . ,transform-package-toolchain) (without-tests . ,transform-package-tests))) (define (transformation-procedure key) @@ -455,6 +534,8 @@ (define %transformation-options (parser 'with-commit)) (option '("with-git-url") #t #f (parser 'with-git-url)) + (option '("with-c-toolchain") #t #f + (parser 'with-c-toolchain)) (option '("without-tests") #t #f (parser 'without-tests))))) @@ -477,6 +558,9 @@ (define (show-transformation-options-help) (display (G_ " --with-git-url=PACKAGE=URL build PACKAGE from the repository at URL")) + (display (G_ " + --with-c-toolchain=PACKAGE=TOOLCHAIN + build PACKAGE and its dependents with TOOLCHAIN")) (display (G_ " --without-tests=PACKAGE build PACKAGE without running its tests"))) diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm index 5f91360953..6925374baa 100644 --- a/tests/scripts-build.scm +++ b/tests/scripts-build.scm @@ -22,6 +22,8 @@ (define-module (test-scripts-build) #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix git-download) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) #:use-module (guix scripts build) #:use-module (guix ui) #:use-module (guix utils) @@ -30,6 +32,8 @@ (define-module (test-scripts-build) #:use-module (gnu packages base) #:use-module (gnu packages busybox) #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-64)) @@ -270,6 +274,80 @@ (define-module (test-scripts-build) ((("x" dep3)) (map package-source (list dep1 dep3)))))))))))) +(define* (depends-on-toolchain? p #:optional (toolchain "gcc-toolchain")) + "Return true if P depends on TOOLCHAIN instead of the default tool chain." + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (define (package-name* obj) + (and (package? obj) (package-name obj))) + + (match (bag-build-inputs (package->bag p)) + (((_ (= package-name* packages) . _) ...) + (and (not (any (cut member <> packages) toolchain-packages)) + (member toolchain packages))))) + +(test-assert "options->transformation, with-c-toolchain" + (let* ((dep0 (dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("y" ,grep))))) + (dep1 (dummy-package "stuff" + (native-inputs `(("x" ,dep0))))) + (p (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,dep1))))) + (t (options->transformation + '((with-c-toolchain . "chbouib=gcc-toolchain"))))) + ;; Here we check that the transformation applies to DEP0 and all its + ;; dependents: DEP0 must use GCC-TOOLCHAIN, DEP1 must use GCC-TOOLCHAIN + ;; and the DEP0 that uses GCC-TOOLCHAIN, and so on. + (with-store store + (let ((new (t store p))) + (and (depends-on-toolchain? new "gcc-toolchain") + (match (bag-build-inputs (package->bag new)) + ((("foo" dep0) ("bar" dep1) _ ...) + (and (depends-on-toolchain? dep1 "gcc-toolchain") + (not (depends-on-toolchain? dep0 "gcc-toolchain")) + (string=? (package-full-name dep0) + (package-full-name grep)) + (match (bag-build-inputs (package->bag dep1)) + ((("x" dep) _ ...) + (and (depends-on-toolchain? dep "gcc-toolchain") + (match (bag-build-inputs (package->bag dep)) + ((("y" dep) _ ...) ;this one is unchanged + (eq? dep grep)))))))))))))) + +(test-equal "options->transformation, with-c-toolchain twice" + (package-full-name grep) + (let* ((dep0 (dummy-package "chbouib")) + (dep1 (dummy-package "stuff")) + (p (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,dep0) + ("bar" ,dep1) + ("baz" ,grep))))) + (t (options->transformation + '((with-c-toolchain . "chbouib=clang-toolchain") + (with-c-toolchain . "stuff=clang-toolchain"))))) + (with-store store + (let ((new (t store p))) + (and (depends-on-toolchain? new "clang-toolchain") + (match (bag-build-inputs (package->bag new)) + ((("foo" dep0) ("bar" dep1) ("baz" dep2) _ ...) + (and (depends-on-toolchain? dep0 "clang-toolchain") + (depends-on-toolchain? dep1 "clang-toolchain") + (not (depends-on-toolchain? dep2 "clang-toolchain")) + (package-full-name dep2))))))))) + +(test-assert "options->transformation, with-c-toolchain, no effect" + (let ((p (dummy-package "thingie")) + (t (options->transformation + '((with-c-toolchain . "does-not-exist=gcc-toolchain"))))) + ;; When it has no effect, '--with-c-toolchain' returns P. + (with-store store + (eq? (t store p) p)))) + (test-assert "options->transformation, without-tests" (let* ((dep (dummy-package "dep")) (p (dummy-package "foo" @@ -286,3 +364,7 @@ (define-module (test-scripts-build) '(#:tests? #f)))))))) (test-end) + +;;; Local Variables: +;;; eval: (put 'dummy-package 'scheme-indent-function 1) +;;; End: -- cgit v1.2.3 From 2323a7120a0f3ed96fedfff42e86c0aee97995c0 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Tue, 13 Oct 2020 22:16:57 +0200 Subject: gnu: nmap: Update license. * guix/licenses.scm (nmap): Rename to ... (npsl): ... this. Adjust name and URL, and remove outdated Fedora wiki entry in favor of nmap's own annotated version. * gnu/packages/admin.scm (nmap)[license]: Adjust accordingly. --- gnu/packages/admin.scm | 2 +- guix/licenses.scm | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'guix') diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm index 27caa193d7..1b80eb8ab7 100644 --- a/gnu/packages/admin.scm +++ b/gnu/packages/admin.scm @@ -2670,7 +2670,7 @@ (define (python-path dir) results (ndiff), and a packet generation and response analysis tool (nping).") ;; This package uses nmap's bundled versions of libdnet and liblinear, which ;; both use a 3-clause BSD license. - (license (list license:nmap license:bsd-3)))) + (license (list license:npsl license:bsd-3)))) (define-public dstat (package diff --git a/guix/licenses.scm b/guix/licenses.scm index 5038f75638..cd43386102 100644 --- a/guix/licenses.scm +++ b/guix/licenses.scm @@ -76,7 +76,7 @@ (define-module (guix licenses) mpl1.0 mpl1.1 mpl2.0 ms-pl ncsa - nmap + npsl ogl-psi1.0 openldap2.8 openssl perl-license @@ -521,10 +521,10 @@ (define ncsa "http://directory.fsf.org/wiki/License:IllinoisNCSA" "https://www.gnu.org/licenses/license-list#NCSA")) -(define nmap - (license "Nmap license" - "https://svn.nmap.org/nmap/COPYING" - "https://fedoraproject.org/wiki/Licensing/Nmap")) +(define npsl + (license "Nmap Public Source License" + "https://svn.nmap.org/nmap/LICENSE" + "https://nmap.org/npsl/")) (define ogl-psi1.0 (license "Open Government Licence for Public Sector Information" -- cgit v1.2.3 From 37a8f5b281644bd5355406a4df76bbb9efc50d9c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 14 Oct 2020 10:19:38 +0200 Subject: openpgp: '&openpgp-unrecognized-packet-error' includes type tag. * guix/openpgp.scm (&openpgp-unrecognized-packet-error)[type]: New field. (get-data, parse-subpackets): Initialize 'type' field. --- guix/openpgp.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/openpgp.scm b/guix/openpgp.scm index 153752ee73..648c359621 100644 --- a/guix/openpgp.scm +++ b/guix/openpgp.scm @@ -34,6 +34,7 @@ (define-module (guix openpgp) openpgp-error? openpgp-unrecognized-packet-error? openpgp-unrecognized-packet-error-port + openpgp-unrecognized-packet-error-type openpgp-invalid-signature-error? openpgp-invalid-signature-error-port @@ -132,6 +133,7 @@ (define-condition-type &openpgp-error &error ;; Error raised when reading an unsupported or unrecognized packet tag. (define-condition-type &openpgp-unrecognized-packet-error &openpgp-error openpgp-unrecognized-packet-error? + (type openpgp-unrecognized-packet-error-type) (port openpgp-unrecognized-packet-error-port)) ;; Error raised when reading an invalid signature packet. @@ -477,7 +479,8 @@ (define (get-data p tag len) ((= tag PACKET-ONE-PASS-SIGNATURE) 'one-pass-signature) ;TODO: implement (else - (raise (condition (&openpgp-unrecognized-packet-error (port p)))))))) + (raise (condition (&openpgp-unrecognized-packet-error (type tag) + (port p)))))))) (define-record-type (make-openpgp-public-key version subkey? time value fingerprint) @@ -817,6 +820,7 @@ (define (parse tag data) (if critical? (raise (condition (&openpgp-unrecognized-packet-error + (type type) (port signature-port)))) (list 'unsupported-subpacket type data)))))) -- cgit v1.2.3 From 6b793fa66218337a1f638466753cd5326a6a6c18 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Wed, 7 Oct 2020 10:11:05 +0300 Subject: build-system/go: Install license files. * guix/build/go-build-system.scm (install-license-files): New procedure. (%standard-phases): Replace inherited 'install-license-files phase. --- guix/build/go-build-system.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'guix') diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index b9cb2bfd7b..227df820db 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2019 Maxim Cournoyer ;;; Copyright © 2020 Jack Hill ;;; Copyright © 2020 Jakub Kądziołka +;;; Copyright © 2020 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -254,6 +255,17 @@ (define* (install #:key install-source? outputs import-path unpack-path #:allow- (copy-recursively source dest #:keep-mtime? #t))) #t) +(define* (install-license-files #:key unpack-path + import-path + #:allow-other-keys + #:rest args) + "Install license files matching LICENSE-FILE-REGEXP to 'share/doc'. Adjust +the standard install-license-files phase to first enter the correct directory." + (with-directory-excursion (string-append "src/" (if (string-null? unpack-path) + import-path + unpack-path)) + (apply (assoc-ref gnu:%standard-phases 'install-license-files) args))) + (define* (remove-store-reference file file-name #:optional (store (%store-directory))) "Remove from FILE occurrences of FILE-NAME in STORE; return #t when FILE-NAME @@ -317,6 +329,7 @@ (define %standard-phases (replace 'build build) (replace 'check check) (replace 'install install) + (replace 'install-license-files install-license-files) (add-after 'install 'remove-go-references remove-go-references))) (define* (go-build #:key inputs (phases %standard-phases) -- cgit v1.2.3 From 5ef1508942ee083ed22b844f5291e59320016b79 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 15 Oct 2020 16:41:14 +0200 Subject: ui: Only suggest modules that export the unbound variable identifier. Fixes . Reported by Tobias Geerinckx-Rice . * guix/ui.scm (known-variable-definition): Check for variables in the public interface of HEAD, not in HEAD itself. * tests/guix-build.sh: Add test. --- guix/ui.scm | 3 ++- tests/guix-build.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/ui.scm b/guix/ui.scm index 8213e8ebab..8d7bc238bc 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -297,7 +297,8 @@ (define (modulelist (lambda (name module) module) (module-submodules head))))) - (match (module-local-variable head variable) + (match (and=> (module-public-interface head) + (cut module-local-variable <> variable)) (#f (loop next suggestions visited)) (_ (match (module-name head) diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 6dbb53206e..4a58ea1476 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -198,6 +198,33 @@ grep "forget.*(guix build-system gnu)" "$module_dir/err" # hint rm -f "$module_dir"/* +# Unbound variable: don't suggest modules that do not export the variable. +cat > "$module_dir/aa-private.scm" < "$module_dir/bb-public.scm" < "$module_dir/cc-user.scm" < "$module_dir/err" +cat "$module_dir/err" +grep "make-thing.*unbound" "$module_dir/err" # actual error +grep "forget.*(bb-public)" "$module_dir/err" # hint + +rm -f "$module_dir"/* + # Wrong 'define-module' clause reported by 'warn-about-load-error'. cat > "$module_dir/foo.scm" < Date: Fri, 16 Oct 2020 14:55:00 +0200 Subject: gexp: Add 'assume-valid-file-name' syntax for use with 'local-file'. * guix/gexp.scm (assume-valid-file-name): New variable. (local-file): Add clause with (assume-valid-file-name file). --- guix/gexp.scm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/gexp.scm b/guix/gexp.scm index 25e4881d21..76fffc4908 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -48,6 +48,7 @@ (define-module (guix gexp) gexp-input-output gexp-input-native? + assume-valid-file-name local-file local-file? local-file-file @@ -424,6 +425,12 @@ (define (absolute-file-name file directory) (string-append directory "/" file)) (else file)))) +(define-syntax-rule (assume-valid-file-name file) + "This is a syntactic keyword to tell 'local-file' that it can assume that +the given file name is valid, even if it's not a string literal, and thus not +warn about it." + file) + (define-syntax local-file (lambda (s) "Return an object representing local file FILE to add to the store; this @@ -442,13 +449,20 @@ (define-syntax local-file This is the declarative counterpart of the 'interned-file' monadic procedure. It is implemented as a macro to capture the current source directory where it appears." - (syntax-case s () + (syntax-case s (assume-valid-file-name) ((_ file rest ...) (string? (syntax->datum #'file)) ;; FILE is a literal, so resolve it relative to the source directory. #'(%local-file file (delay (absolute-file-name file (current-source-directory))) rest ...)) + ((_ (assume-valid-file-name file) rest ...) + ;; FILE is not a literal, so resolve it relative to the source + ;; directory. Since the user declared FILE is valid, do not pass + ;; #:literal? #f so that we do not warn about it later on. + #'(%local-file file + (delay (absolute-file-name file (current-source-directory))) + rest ...)) ((_ file rest ...) ;; Resolve FILE relative to the current directory. (with-syntax ((location (datum->syntax s (syntax-source s)))) @@ -456,7 +470,7 @@ (define-syntax local-file (delay (absolute-file-name file (getcwd))) rest ... #:location 'location - #:literal? #f))) + #:literal? #f))) ;warn if FILE is relative ((_) #'(syntax-error "missing file name")) (id -- cgit v1.2.3 From f045a7a9262c0291175533c92cdd73e43d5e2f6b Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 15 Oct 2020 18:32:59 +0200 Subject: import: utils: Fix license name mismatches and define CUA-OPL-1.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/licenses.scm (cua-opl1.0): New variable. * guix/import/utils.scm (spdx-string->license): Rename licenses to fit the internal names and add a notice pointing to guix/licenses.scm. Signed-off-by: Ludovic Courtès --- guix/import/utils.scm | 14 +++++++++----- guix/licenses.scm | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/guix/import/utils.scm b/guix/import/utils.scm index 0cfa1f8321..145515c489 100644 --- a/guix/import/utils.scm +++ b/guix/import/utils.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2017, 2019, 2020 Ricardo Wurmus ;;; Copyright © 2018 Oleg Pykhalov ;;; Copyright © 2019 Robert Vollmert +;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -124,9 +125,12 @@ (define (spdx-string->license str) ;; https://spdx.org/licenses/ ;; The psfl, gfl1.0, nmap, repoze ;; licenses doesn't have SPDX identifiers + ;; + ;; Please update guix/licenses.scm when modifying + ;; this list to avoid mismatches. (match str - ("AGPL-1.0" 'license:agpl-1.0) - ("AGPL-3.0" 'license:agpl-3.0) + ("AGPL-1.0" 'license:agpl1) + ("AGPL-3.0" 'license:agpl3) ("Apache-1.1" 'license:asl1.1) ("Apache-2.0" 'license:asl2.0) ("BSL-1.0" 'license:boost1.0) @@ -166,8 +170,8 @@ (define (spdx-string->license str) ("LGPL-2.0+" 'license:lgpl2.0+) ("LGPL-2.1" 'license:lgpl2.1) ("LGPL-2.1+" 'license:lgpl2.1+) - ("LGPL-3.0" 'license:lgpl3.0) - ("LGPL-3.0+" 'license:lgpl3.0+) + ("LGPL-3.0" 'license:lgpl3) + ("LGPL-3.0+" 'license:lgpl3+) ("MPL-1.0" 'license:mpl1.0) ("MPL-1.1" 'license:mpl1.1) ("MPL-2.0" 'license:mpl2.0) @@ -175,7 +179,7 @@ (define (spdx-string->license str) ("NCSA" 'license:ncsa) ("OpenSSL" 'license:openssl) ("OLDAP-2.8" 'license:openldap2.8) - ("CUA-OPL-1.0" 'license:opl1.0) + ("CUA-OPL-1.0" 'license:cua-opl1.0) ("QPL-1.0" 'license:qpl) ("Ruby" 'license:ruby) ("SGI-B-2.0" 'license:sgifreeb2.0) diff --git a/guix/licenses.scm b/guix/licenses.scm index cd43386102..255b755e6c 100644 --- a/guix/licenses.scm +++ b/guix/licenses.scm @@ -15,6 +15,7 @@ ;;; Copyright © 2017 Arun Isaac ;;; Copyright © 2017 Rutger Helling ;;; Copyright © 2020 André Batista +;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -49,6 +50,7 @@ (define-module (guix licenses) artistic2.0 clarified-artistic copyleft-next cpl1.0 + cua-opl1.0 edl1.0 epl1.0 epl2.0 @@ -117,6 +119,9 @@ (define-record-type ;;; https://github.com/NixOS/nixpkgs/blob/master/lib/licenses.nix ;;; https://www.gnu.org/licenses/license-list ;;; +;;; Please update spdx-string->license from guix/import/utils.scm +;;; when modifying this list to avoid mismatches. +;;; ;;; Code: (define agpl1 @@ -269,6 +274,11 @@ (define cpl1.0 "http://directory.fsf.org/wiki/License:CPLv1.0" "https://www.gnu.org/licenses/license-list#CommonPublicLicense10")) +(define cua-opl1.0 + (license "CUA Office Public License v1.0" + "https://spdx.org/licenses/CUA-OPL-1.0.html" + "https://opensource.org/licenses/CUA-OPL-1.0")) + (define edl1.0 (license "EDL 1.0" "http://directory.fsf.org/wiki/License:EDLv1.0" -- cgit v1.2.3 From 6be71461309bad19dcd96faa151ca691d87f28df Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 18 Oct 2020 00:21:33 +0200 Subject: gexp: 'assume-valid-file-name' has files looked up under the CWD. Fixes a bug introduced in 5d4ad8e1be6d60c38577e2f3d92cc5642b12eff0, whereby files enclosed in 'assume-valid-file-name' would be looked up relative to the source directory instead of relative to the current directory. * guix/gexp.scm (local-file): In the 'assume-valid-file-name' case, look up FILE relative to the current working directory. --- guix/gexp.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/gexp.scm b/guix/gexp.scm index 76fffc4908..9339b226b7 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -457,11 +457,11 @@ (define-syntax local-file (delay (absolute-file-name file (current-source-directory))) rest ...)) ((_ (assume-valid-file-name file) rest ...) - ;; FILE is not a literal, so resolve it relative to the source + ;; FILE is not a literal, so resolve it relative to the current ;; directory. Since the user declared FILE is valid, do not pass ;; #:literal? #f so that we do not warn about it later on. #'(%local-file file - (delay (absolute-file-name file (current-source-directory))) + (delay (absolute-file-name file (getcwd))) rest ...)) ((_ file rest ...) ;; Resolve FILE relative to the current directory. -- cgit v1.2.3 From eaf096398349a484bd23fd829755f7dfaf237ab4 Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Mon, 22 Apr 2019 14:44:22 +0200 Subject: system: Provide locale information to the bootloader. * gnu/machine/ssh.scm (roll-back-managed-host): Use locale information from boot-parameters. * gnu/system.scm (operating-system-bootcfg): Provide locale information to the bootloader. * guix/system/script.scm (reinstall-bootloader): Use locale information from boot-parameters. --- gnu/machine/ssh.scm | 3 +++ gnu/system.scm | 2 ++ guix/scripts/system.scm | 2 ++ 3 files changed, 7 insertions(+) (limited to 'guix') diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm index 35b42add48..5020bd362f 100644 --- a/gnu/machine/ssh.scm +++ b/gnu/machine/ssh.scm @@ -480,6 +480,8 @@ (define roll-back-failure (raise roll-back-failure))) (entries -> (map boot-parameters->menu-entry (list (second boot-parameters)))) + (locale -> (boot-parameters-locale + (second boot-parameters))) (old-entries -> (map boot-parameters->menu-entry (drop boot-parameters 2))) (bootloader -> (operating-system-bootloader @@ -489,6 +491,7 @@ (define roll-back-failure (bootloader-configuration-bootloader bootloader)) bootloader entries + #:locale locale #:old-entries old-entries))) (remote-result (machine-remote-eval machine remote-exp))) (when (eqv? 'error remote-result) diff --git a/gnu/system.scm b/gnu/system.scm index e8fe41cc24..a3122eaa65 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1242,6 +1242,7 @@ (define* (operating-system-bootcfg os #:optional (old-entries '())) (let* ((file-systems (operating-system-file-systems os)) (root-fs (operating-system-root-file-system os)) (root-device (file-system-device root-fs)) + (locale (operating-system-locale os)) (params (operating-system-boot-parameters os root-device #:system-kernel-arguments? #t)) @@ -1254,6 +1255,7 @@ (define generate-config-file (generate-config-file bootloader-conf (list entry) #:old-entries old-entries + #:locale locale #:store-directory-prefix (btrfs-store-subvolume-file-name file-systems)))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 939559e719..9ed5c26483 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -384,6 +384,7 @@ (define (reinstall-bootloader store number) ;; Make the specified system generation the default entry. (params (first (profile-boot-parameters %system-profile (list number)))) + (locale (boot-parameters-locale params)) (old-generations (delv number (reverse (generation-numbers %system-profile)))) (old-params (profile-boot-parameters @@ -396,6 +397,7 @@ (define (reinstall-bootloader store number) ((bootcfg (lower-object ((bootloader-configuration-file-generator bootloader) bootloader-config entries + #:locale locale #:old-entries old-entries))) (drvs -> (list bootcfg))) (mbegin %store-monad -- cgit v1.2.3 From 19d42e0e23a7f90ac2dcc1c279bd23a967ff0314 Mon Sep 17 00:00:00 2001 From: zimoun Date: Sun, 18 Oct 2020 00:10:06 +0200 Subject: build-system/haskell: Disable parallel builds. Fixes . * guix/build-system/haskell.scm (haskell-build): Turn off PARALLEL-BUILD? by default. Signed-off-by: Marius Bakke --- guix/build-system/haskell.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/build-system/haskell.scm b/guix/build-system/haskell.scm index 8304e3b222..18a584f782 100644 --- a/guix/build-system/haskell.scm +++ b/guix/build-system/haskell.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2020 Timothy Sample +;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -121,7 +122,9 @@ (define* (haskell-build store name inputs (haddock-flags ''()) (tests? #t) (test-target "test") - (parallel-build? #t) + ;; FIXME: Parallel builds lead to indeterministic + ;; results, see . + (parallel-build? #f) (configure-flags ''()) (extra-directories ''()) (phases '(@ (guix build haskell-build-system) -- cgit v1.2.3