From e3900a4d64e4bf6f426809d6bff058e5a2ae9bc8 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Sat, 6 Jan 2018 15:47:47 -0500 Subject: build-system/go: Build with a filesystem union of Go dependencies. This basically changes (guix build-system go) so that instead of looking up its dependencies in a list of directories in $GOPATH, all the Go dependencies are symlinked into a single directory. Fixes . * guix/build/go-build-system.scm (setup-go-environment): New variable. (setup-environment, install-source): Remove variables. (unpack): Unpack the source relative to $GOPATH. (install): Do not install the compiled objects in the 'pkg' directory. Install the source code in this phase, and only install the source of the package named by IMPORT-PATH. * doc/guix.texi (Build Systems): Adjust accordingly. * gnu/packages/docker.scm (docker): Import (guix build union) on the build side and adjust to build phase name changes in (guix build-system go). * gnu/packages/shellutils.scm (direnv): Likewise. * gnu/packages/databases.scm (mongo-tools)[arguments]: Set '#:install-source #f'. * gnu/packages/music.scm (demlo)[arguments]: Move the 'install-scripts' phase after the 'install' phase. --- guix/build-system/go.scm | 2 + guix/build/go-build-system.scm | 139 ++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 63 deletions(-) (limited to 'guix') diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm index cf91163275..1b916af8f9 100644 --- a/guix/build-system/go.scm +++ b/guix/build-system/go.scm @@ -39,6 +39,7 @@ (define %go-build-system-modules ;; Build-side modules imported and used by default. `((guix build go-build-system) + (guix build union) ,@%gnu-build-system-modules)) (define (default-go) @@ -87,6 +88,7 @@ (guile #f) (imported-modules %go-build-system-modules) (modules '((guix build go-build-system) + (guix build union) (guix build utils)))) (define builder `(begin diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index 022d4fe16b..1a716cea77 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Petter -;;; Copyright © 2017 Leo Famulari +;;; Copyright © 2017, 2019 Leo Famulari ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +19,7 @@ (define-module (guix build go-build-system) #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build union) #:use-module (guix build utils) #:use-module (ice-9 match) #:use-module (srfi srfi-1) @@ -38,24 +39,26 @@ ;; results. [0] ;; Go software is developed and built within a particular file system hierarchy -;; structure called a 'workspace' [1]. This workspace is found by Go -;; via the GOPATH environment variable. Typically, all Go source code -;; and compiled objects are kept in a single workspace, but it is -;; possible for GOPATH to contain a list of directories, and that is -;; what we do in this go-build-system. [2] +;; structure called a 'workspace' [1]. This workspace can be found by Go via +;; the GOPATH environment variable. Typically, all Go source code and compiled +;; objects are kept in a single workspace, but GOPATH may be a list of +;; directories [2]. In this go-build-system we create a filesystem union of +;; the Go-language dependencies. Previously, we made GOPATH a list of store +;; directories, but stopped because Go programs started keeping references to +;; these directories in Go 1.11: +;; . ;; -;; Go software, whether a package or a command, is uniquely named using -;; an 'import path'. The import path is based on the URL of the -;; software's source. Since most source code is provided over the -;; internet, the import path is typically a combination of the remote -;; URL and the source repository's file system structure. For example, -;; the Go port of the common `du` command is hosted on github.com, at -;; . Thus, the import path is -;; . [3] +;; Go software, whether a package or a command, is uniquely named using an +;; 'import path'. The import path is based on the URL of the software's source. +;; Because most source code is provided over the internet, the import path is +;; typically a combination of the remote URL and the source repository's file +;; system structure. For example, the Go port of the common `du` command is +;; hosted on github.com, at . Thus, the import +;; path is . [3] ;; -;; It may be possible to programatically guess a package's import path -;; based on the source URL, but we don't try that in this revision of -;; the go-build-system. +;; It may be possible to automatically guess a package's import path based on +;; the source URL, but we don't try that in this revision of the +;; go-build-system. ;; ;; Modules of modular Go libraries are named uniquely with their ;; file system paths. For example, the supplemental but "standardized" @@ -75,6 +78,17 @@ ;; file system union of the required modules of such libraries. I think ;; this could be improved in future revisions of the go-build-system. ;; +;; TODO: +;; * Avoid copying dependencies into the build environment and / or avoid using +;; a tmpdir when creating the inputs union. +;; * Use Go modules [4] +;; * Re-use compiled packages [5] +;; * Avoid the go-inputs hack +;; * Stop needing remove-go-references (-trimpath ? ) +;; * Remove module packages, only offering the full Git repos? This is +;; more idiomatic, I think, because Go downloads Git repos, not modules. +;; What are the trade-offs? +;; ;; [0] `go build`: ;; https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies ;; `go install`: @@ -107,18 +121,44 @@ ;; ;; [2] https://golang.org/doc/code.html#GOPATH ;; [3] https://golang.org/doc/code.html#ImportPaths +;; [4] https://golang.org/cmd/go/#hdr-Modules__module_versions__and_more +;; [5] https://bugs.gnu.org/32919 ;; ;; Code: +(define* (setup-go-environment #:key inputs outputs #:allow-other-keys) + "Prepare a Go build environment for INPUTS and OUTPUTS. Build a filesystem +union of INPUTS. Export GOPATH, which helps the compiler find the source code +of the package being built and its dependencies, and GOBIN, which determines +where executables (\"commands\") are installed to. This phase is sometimes used +by packages that use (guix build-system gnu) but have a handful of Go +dependencies, so it should be self-contained." + ;; Using the current working directory as GOPATH makes it easier for packagers + ;; who need to manipulate the unpacked source code. + (setenv "GOPATH" (getcwd)) + (setenv "GOBIN" (string-append (assoc-ref outputs "out") "/bin")) + (let ((tmpdir (tmpnam))) + (match (go-inputs inputs) + (((names . directories) ...) + (union-build tmpdir (filter directory-exists? directories) + #:create-all-directories? #t + #:log-port (%make-void-port "w")))) + ;; XXX A little dance because (guix build union) doesn't use mkdir-p. + (copy-recursively tmpdir + (string-append (getenv "GOPATH")) + #:keep-mtime? #t) + (delete-file-recursively tmpdir)) + #t) + (define* (unpack #:key source import-path unpack-path #:allow-other-keys) - "Unpack SOURCE in the UNPACK-PATH, or the IMPORT-PATH is the UNPACK-PATH is -unset. When SOURCE is a directory, copy it instead of unpacking." + "Relative to $GOPATH, unpack SOURCE in the UNPACK-PATH, or the IMPORT-PATH is +the UNPACK-PATH is unset. When SOURCE is a directory, copy it instead of +unpacking." (if (string-null? import-path) ((display "WARNING: The Go import path is unset.\n"))) (if (string-null? unpack-path) (set! unpack-path import-path)) - (mkdir "src") - (let ((dest (string-append "src/" unpack-path))) + (let ((dest (string-append (getenv "GOPATH") "/src/" unpack-path))) (mkdir-p dest) (if (file-is-directory? source) (begin @@ -128,15 +168,6 @@ unset. When SOURCE is a directory, copy it instead of unpacking." (invoke "unzip" "-d" dest source) (invoke "tar" "-C" dest "-xvf" source))))) -(define* (install-source #:key install-source? outputs #:allow-other-keys) - "Install the source code to the output directory." - (let* ((out (assoc-ref outputs "out")) - (source "src") - (dest (string-append out "/" source))) - (when install-source? - (copy-recursively source dest #:keep-mtime? #t)) - #t)) - (define (go-package? name) (string-prefix? "go-" name)) @@ -155,27 +186,6 @@ unset. When SOURCE is a directory, copy it instead of unpacking." (_ #f)) inputs)))) -(define* (setup-environment #:key inputs outputs #:allow-other-keys) - "Export the variables GOPATH and GOBIN, which are based on INPUTS and OUTPUTS, -respectively." - (let ((out (assoc-ref outputs "out"))) - ;; GOPATH is where Go looks for the source code of the build's dependencies. - (set-path-environment-variable "GOPATH" - ;; XXX Matching "." hints that we could do - ;; something simpler here... - (list ".") - (match (go-inputs inputs) - (((_ . dir) ...) - dir))) - - ;; Add the source code of the package being built to GOPATH. - (if (getenv "GOPATH") - (setenv "GOPATH" (string-append (getcwd) ":" (getenv "GOPATH"))) - (setenv "GOPATH" (getcwd))) - ;; Where to install compiled executable files ('commands' in Go parlance'). - (setenv "GOBIN" (string-append out "/bin")) - #t)) - (define* (build #:key import-path #:allow-other-keys) "Build the package named by IMPORT-PATH." (with-throw-handler @@ -193,22 +203,26 @@ respectively." "Here are the results of `go env`:\n")) (invoke "go" "env")))) +;; Can this also install commands??? (define* (check #:key tests? import-path #:allow-other-keys) "Run the tests for the package named by IMPORT-PATH." (when tests? (invoke "go" "test" import-path)) #t) -(define* (install #:key outputs #:allow-other-keys) - "Install the compiled libraries. `go install` installs these files to -$GOPATH/pkg, so we have to copy them into the output directory manually. -Compiled executable files should have already been installed to the store based -on $GOBIN in the build phase." - ;; TODO: From go-1.10 onward, the pkg folder should not be needed (see - ;; https://lists.gnu.org/archive/html/guix-devel/2018-11/msg00208.html). - ;; Remove it? - (when (file-exists? "pkg") - (copy-recursively "pkg" (string-append (assoc-ref outputs "out") "/pkg"))) +(define* (install #:key install-source? outputs import-path unpack-path #:allow-other-keys) + "Install the source code of IMPORT-PATH to the primary output directory. +Compiled executable files (Go \"commands\") should have already been installed +to the store based on $GOBIN in the build phase. +XXX We can't make us of compiled libraries (Go \"packages\")." + (when install-source? + (if (string-null? import-path) + ((display "WARNING: The Go import path is unset.\n"))) + (let* ((out (assoc-ref outputs "out")) + (source (string-append (getenv "GOPATH") "/src/" import-path)) + (dest (string-append out "/src/" import-path))) + (mkdir-p dest) + (copy-recursively source dest #:keep-mtime? #t))) #t) (define* (remove-store-reference file file-name @@ -269,9 +283,8 @@ files in OUTPUTS." (delete 'bootstrap) (delete 'configure) (delete 'patch-generated-file-shebangs) + (add-before 'unpack 'setup-go-environment setup-go-environment) (replace 'unpack unpack) - (add-after 'unpack 'install-source install-source) - (add-before 'build 'setup-environment setup-environment) (replace 'build build) (replace 'check check) (replace 'install install) -- cgit v1.2.3 From bc4cea6f0ef20a620d8bbda8ea14f9adf209c78d Mon Sep 17 00:00:00 2001 From: Guy Fleury Iteriteka Date: Fri, 15 Mar 2019 13:02:51 -0400 Subject: download: Add MATE mirrors. * guix/download.scm (%mirrors): Add mirrors for the MATE Desktop. --- guix/download.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/download.scm b/guix/download.scm index 25eaefcffa..8865777818 100644 --- a/guix/download.scm +++ b/guix/download.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2016 Alex Griffin ;;; Copyright © 2016 David Craven ;;; Copyright © 2017 Tobias Geerinckx-Rice +;;; Copyright © 2019 Guy Fleury Iteriteka ;;; ;;; This file is part of GNU Guix. ;;; @@ -360,7 +361,10 @@ "https://openbsd.mirror.constant.com/pub/OpenBSD/" "https://ftp4.usa.openbsd.org/pub/OpenBSD/" "https://ftp5.usa.openbsd.org/pub/OpenBSD/" - "https://mirror.esc7.net/pub/OpenBSD/")))) + "https://mirror.esc7.net/pub/OpenBSD/") + (mate + "https://pub.mate-desktop.org/releases/" + "http://pub.mate-desktop.org/releases/")))) (define %mirror-file ;; Copy of the list of mirrors to a file. This allows us to keep a single -- cgit v1.2.3 From ee71d44e60a128e107436e1e0405b45280cb49c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 15 Mar 2019 17:43:45 +0100 Subject: build-system/glib-or-gtk: Support #:disallowed-references. * guix/build-system/glib-or-gtk.scm (glib-or-gtk-build): Add #:disallowed-references and honor it. --- guix/build-system/glib-or-gtk.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/build-system/glib-or-gtk.scm b/guix/build-system/glib-or-gtk.scm index fcd92f2334..8de7dfbfc2 100644 --- a/guix/build-system/glib-or-gtk.scm +++ b/guix/build-system/glib-or-gtk.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2019 Ludovic Courtès ;;; Copyright © 2013 Cyril Roelandt ;;; Copyright © 2014 Federico Beffa ;;; @@ -129,7 +129,8 @@ (system (%current-system)) (imported-modules %glib-or-gtk-build-system-modules) (modules %default-modules) - allowed-references) + allowed-references + disallowed-references) "Build SOURCE with INPUTS. See GNU-BUILD for more details." (define canonicalize-reference (match-lambda @@ -190,6 +191,10 @@ (and allowed-references (map canonicalize-reference allowed-references)) + #:disallowed-references + (and disallowed-references + (map canonicalize-reference + disallowed-references)) #:guile-for-build guile-for-build)) (define glib-or-gtk-build-system -- cgit v1.2.3 From 99aec37a78e7be6a591d0e5b7439896d669a75d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 14 Mar 2019 17:02:53 +0100 Subject: pack: "-RR" produces PRoot-enabled relocatable binaries. * gnu/packages/aux-files/run-in-namespace.c (exec_with_proot): New function. (main): When 'clone' fails, call 'rm_rf'. [PROOT_PROGRAM]: When 'clone' fails, call 'exec_with_proot'. * guix/scripts/pack.scm (wrapped-package): Add #:proot?. [proot]: New procedure. [build]: Compile with -DPROOT_PROGRAM when PROOT? is true. * guix/scripts/pack.scm (%options): Set the 'relocatable?' value to 'proot when "-R" is passed several times. (guix-pack): Pass #:proot? to 'wrapped-package'. * tests/guix-pack-relocatable.sh: Use "-RR" on Intel systems that lack user namespace support. * doc/guix.texi (Invoking guix pack): Document -RR. --- guix/scripts/pack.scm | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index e2ecddfbfc..bfb8b85356 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -517,10 +517,14 @@ please email '~a'~%") ;;; (define* (wrapped-package package - #:optional (compiler (c-compiler))) + #:optional (compiler (c-compiler)) + #:key proot?) (define runner (local-file (search-auxiliary-file "run-in-namespace.c"))) + (define (proot) + (specification->package "proot-static")) + (define build (with-imported-modules (source-module-closure '((guix build utils) @@ -550,10 +554,19 @@ please email '~a'~%") (("@STORE_DIRECTORY@") (%store-directory))) (let* ((base (strip-store-prefix program)) - (result (string-append #$output "/" base))) + (result (string-append #$output "/" base)) + (proot #$(and proot? + #~(string-drop + #$(file-append (proot) "/bin/proot") + (+ (string-length (%store-directory)) + 1))))) (mkdir-p (dirname result)) - (invoke #$compiler "-std=gnu99" "-static" "-Os" "-g0" "-Wall" - "run.c" "-o" result) + (apply invoke #$compiler "-std=gnu99" "-static" "-Os" "-g0" "-Wall" + "run.c" "-o" result + (if proot + (list (string-append "-DPROOT_PROGRAM=\"" + proot "\"")) + '())) (delete-file "run.c"))) (setvbuf (current-output-port) 'line) @@ -646,7 +659,12 @@ please email '~a'~%") (exit 0))) (option '(#\R "relocatable") #f #f (lambda (opt name arg result) - (alist-cons 'relocatable? #t result))) + (match (assq-ref result 'relocatable?) + (#f + (alist-cons 'relocatable? #t result)) + (_ + (alist-cons 'relocatable? 'proot + (alist-delete 'relocatable? result)))))) (option '(#\e "expression") #t #f (lambda (opt name arg result) (alist-cons 'expression arg result))) @@ -821,11 +839,14 @@ Create a bundle of PACKAGE.\n")) #:graft? (assoc-ref opts 'graft?)))) (let* ((dry-run? (assoc-ref opts 'dry-run?)) (relocatable? (assoc-ref opts 'relocatable?)) + (proot? (eq? relocatable? 'proot)) (manifest (let ((manifest (manifest-from-args store opts))) ;; Note: We cannot honor '--bootstrap' here because ;; 'glibc-bootstrap' lacks 'libc.a'. (if relocatable? - (map-manifest-entries wrapped-package manifest) + (map-manifest-entries + (cut wrapped-package <> #:proot? proot?) + manifest) manifest))) (pack-format (assoc-ref opts 'format)) (name (string-append (symbol->string pack-format) -- cgit v1.2.3 From 41dfe40f5dbd162558c3954ae8eb991a56a65682 Mon Sep 17 00:00:00 2001 From: "P.C. Shyamshankar" Date: Fri, 22 Feb 2019 22:38:47 -0500 Subject: pack: Construct inferior package names correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/pack.scm (wrapped-package): now correctly constructs full names of inferior packages. Co-authored-by: Ludovic Courtès --- guix/scripts/pack.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index bfb8b85356..17a166d9d7 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -28,6 +28,7 @@ #:use-module (guix store) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module (guix grafts) + #:autoload (guix inferior) (inferior-package?) #:use-module (guix monads) #:use-module (guix modules) #:use-module (guix packages) @@ -586,7 +587,15 @@ please email '~a'~%") (find-files #$(file-append package "/sbin")) (find-files #$(file-append package "/libexec"))))))) - (computed-file (string-append (package-full-name package "-") "R") + (computed-file (string-append + (cond ((package? package) + (package-full-name package "-")) + ((inferior-package? package) + (string-append (inferior-package-name package) + "-" + (inferior-package-version package))) + (else "wrapper")) + "R") build)) (define (map-manifest-entries proc manifest) -- cgit v1.2.3 From 22f95e028f038cee342f455dfc55bd32b804907c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 16 Mar 2019 15:11:29 +0100 Subject: tests: Add 'with-environment-variable'. * tests/scripts.scm (with-environment-variable): Move to... * guix/tests.scm (with-environment-variable): ... here. * tests/build-utils.scm ("wrap-program, one input, multiple calls"): Use it instead of 'setenv'. --- guix/tests.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'guix') diff --git a/guix/tests.scm b/guix/tests.scm index 749a4edd7a..35ebf8464d 100644 --- a/guix/tests.scm +++ b/guix/tests.scm @@ -39,6 +39,8 @@ canonical-file? network-reachable? shebang-too-long? + with-environment-variable + mock %test-substitute-urls test-assertm @@ -195,6 +197,19 @@ store is opened." (run-with-store store exp #:guile-for-build (%guile-for-build))))) +(define-syntax-rule (with-environment-variable variable value body ...) + "Run BODY with VARIABLE set to VALUE." + (let ((orig (getenv variable))) + (dynamic-wind + (lambda () + (setenv variable value)) + (lambda () + body ...) + (lambda () + (if orig + (setenv variable orig) + (unsetenv variable)))))) + ;;; ;;; Narinfo files, as used by the substituter. -- cgit v1.2.3 From 21fcfe1ee969cc477dc41486ae4074e655d44274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 16 Mar 2019 17:09:19 +0100 Subject: bootloader: Use 'invoke/quiet' when running 'grub-install' and co. This hides potentially confusing GRUB messages from the user, such as "Installing for i386-pc platform." * gnu/bootloader/extlinux.scm (install-extlinux): Use 'invoke/quiet' instead of 'system*' and 'error'. * gnu/bootloader/grub.scm (install-grub, install-grub-efi): Likewise. * guix/scripts/system.scm (bootloader-installer-script): Guard against 'message-condition?' and handle them properly. --- guix/scripts/system.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index d67b9f8185..b4bf66819f 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -808,8 +808,17 @@ and TARGET arguments." #~(begin (use-modules (gnu build bootloader) (guix build utils) - (ice-9 binary-ports)) - (#$installer #$bootloader #$device #$target))))) + (ice-9 binary-ports) + (srfi srfi-34) + (srfi srfi-35)) + + (guard (c ((message-condition? c) ;XXX: i18n + (format (current-error-port) "error: ~a~%" + (condition-message c)) + (exit 1))) + (#$installer #$bootloader #$device #$target) + (format #t "bootloader successfully installed on '~a'~%" + device)))))) (define* (perform-action action os #:key skip-safety-checks? -- cgit v1.2.3 From b56d160944ace6e06fcfe5a36310c98e6a213b87 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Sat, 16 Mar 2019 07:01:26 +0100 Subject: guix: Match package names case-insensitively. * guix/scripts/package.scm (options->upgrade-predicate, process-query): Use REGEXP/ICASE when matching package names. --- guix/scripts/package.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'guix') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index efff511299..b0c6a7ced7 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2016 Roel Janssen ;;; Copyright © 2016 Benz Schenk ;;; Copyright © 2016 Chris Marusich +;;; Copyright © 2019 Tobias Geerinckx-Rice ;;; ;;; This file is part of GNU Guix. ;;; @@ -526,14 +527,14 @@ upgrading, #f otherwise." (define upgrade-regexps (filter-map (match-lambda (('upgrade . regexp) - (make-regexp* (or regexp ""))) + (make-regexp* (or regexp "") regexp/icase)) (_ #f)) opts)) (define do-not-upgrade-regexps (filter-map (match-lambda (('do-not-upgrade . regexp) - (make-regexp* regexp)) + (make-regexp* regexp regexp/icase)) (_ #f)) opts)) @@ -686,7 +687,7 @@ processed, #f otherwise." #t) (('list-installed regexp) - (let* ((regexp (and regexp (make-regexp* regexp))) + (let* ((regexp (and regexp (make-regexp* regexp regexp/icase))) (manifest (profile-manifest profile)) (installed (manifest-entries manifest))) (leave-on-EPIPE @@ -702,7 +703,7 @@ processed, #f otherwise." #t)) (('list-available regexp) - (let* ((regexp (and regexp (make-regexp* regexp))) + (let* ((regexp (and regexp (make-regexp* regexp regexp/icase))) (available (fold-available-packages (lambda* (name version result #:key outputs location -- cgit v1.2.3 From 8ffab257ddb6c5df1ac43b9baeb5f0373bffb482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 17 Mar 2019 16:22:43 +0100 Subject: guix system: Fix success report of the bootloader installation. Fixes . Reported by Jack Hill . Regression introduced in 21fcfe1ee969cc477dc41486ae4074e655d44274. * guix/scripts/system.scm (bootloader-installer-script): Ungexp DEVICE. --- guix/scripts/system.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index b4bf66819f..97508f4bd6 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -818,7 +818,7 @@ and TARGET arguments." (exit 1))) (#$installer #$bootloader #$device #$target) (format #t "bootloader successfully installed on '~a'~%" - device)))))) + #$device)))))) (define* (perform-action action os #:key skip-safety-checks? -- cgit v1.2.3 From cd2e4b2a8dbded85f7183d86be0747707e55d49e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 17 Mar 2019 17:01:56 +0100 Subject: describe: Add 'current-profile-date'. * guix/describe.scm (current-profile-date): New procedure. --- guix/describe.scm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/describe.scm b/guix/describe.scm index 00372bbed7..893dca2640 100644 --- a/guix/describe.scm +++ b/guix/describe.scm @@ -21,10 +21,12 @@ #:use-module (guix profiles) #:use-module (guix packages) #:use-module ((guix utils) #:select (location-file)) - #:use-module ((guix store) #:select (%store-prefix)) + #:use-module ((guix store) #:select (%store-prefix store-path?)) + #:use-module ((guix config) #:select (%state-directory)) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (current-profile + current-profile-date current-profile-entries package-path-entries @@ -55,6 +57,27 @@ or #f if this is not applicable." (and (file-exists? (string-append candidate "/manifest")) candidate))))))) +(define (current-profile-date) + "Return the creation date of the current profile (produced by 'guix pull'), +as a number of seconds since the Epoch, or #f if it could not be determined." + ;; Normally 'current-profile' will return ~/.config/guix/current. We need + ;; to 'readlink' once to get '/var/guix/…/guix-profile', whose mtime is the + ;; piece of information we're looking for. + (let loop ((profile (current-profile))) + (match profile + (#f #f) + ((? store-path?) #f) + (file + (if (string-prefix? %state-directory file) + (and=> (lstat file) stat:mtime) + (catch 'system-error + (lambda () + (let ((target (readlink file))) + (loop (if (string-prefix? "/" target) + target + (string-append (dirname file) "/" target))))) + (const #f))))))) + (define current-profile-entries (mlambda () "Return the list of entries in the 'guix pull' profile the calling process -- cgit v1.2.3 From 55da450a1fc9969d9e791d7d94da90df3aa284db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 17 Mar 2019 17:02:15 +0100 Subject: scripts: 'warn-about-old-distro' looks at the age of the running Guix. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a discrepancy that could be seen when running: sudo guix system … where 'guix' would warn about the age of root's Guix, even though the running Guix is the user's, not root's. * guix/scripts.scm (warn-about-old-distro)[false-if-not-found]: Remove. Obtain the profile date by calling 'current-profile-date' instead of stat'ing "current-guix". --- guix/scripts.scm | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'guix') diff --git a/guix/scripts.scm b/guix/scripts.scm index 5e20ecd92c..75d801a466 100644 --- a/guix/scripts.scm +++ b/guix/scripts.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2014 Deck Pickard ;;; Copyright © 2015, 2016 Alex Kost ;;; @@ -27,6 +27,7 @@ #:use-module (guix packages) #:use-module (guix derivations) #:use-module ((guix profiles) #:select (%profile-directory)) + #:autoload (guix describe) (current-profile-date) #:use-module (guix build syscalls) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) @@ -158,36 +159,25 @@ Show what and how will/would be built." #:key (suggested-command "guix package -u")) "Emit a warning if Guix is older than OLD seconds." - (let-syntax ((false-if-not-found - (syntax-rules () - ((_ exp) - (catch 'system-error - (lambda () - exp) - (lambda args - (if (= ENOENT (system-error-errno args)) - #f - (apply throw args)))))))) - (define (seconds->days seconds) - (round (/ seconds (* 3600 24)))) - - (define age - (match (false-if-not-found - (lstat (string-append %profile-directory "/current-guix"))) - (#f #f) - (stat (- (time-second (current-time time-utc)) - (stat:mtime stat))))) - - (when (and age (>= age old)) - (warning (N_ "Your Guix installation is ~a day old.\n" - "Your Guix installation is ~a days old.\n" - (seconds->days age)) - (seconds->days age))) - (when (or (not age) (>= age old)) - (warning (G_ "Consider running 'guix pull' followed by + (define (seconds->days seconds) + (round (/ seconds (* 3600 24)))) + + (define age + (match (current-profile-date) + (#f #f) + (date (- (time-second (current-time time-utc)) + date)))) + + (when (and age (>= age old)) + (warning (N_ "Your Guix installation is ~a day old.\n" + "Your Guix installation is ~a days old.\n" + (seconds->days age)) + (seconds->days age))) + (when (or (not age) (>= age old)) + (warning (G_ "Consider running 'guix pull' followed by '~a' to get up-to-date packages and security updates.\n") - suggested-command) - (newline (guix-warning-port))))) + suggested-command) + (newline (guix-warning-port)))) (define %disk-space-warning ;; The fraction (between 0 and 1) of free disk space below which a warning -- cgit v1.2.3 From 880916ac5228b9cfd6e65ac243d17f6bd12edaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 12 Mar 2019 15:50:13 +0100 Subject: guix build: Add '--with-git-url'. * guix/scripts/build.scm (%not-equal): New variable. (evaluate-git-replacement-specs): Use it instead of local variable 'not-equal'. (transform-package-source-git-url): New procedure. (%transformations): Add 'with-git-url'. (%transformation-options, show-transformation-options-help): Add '--with-git-url'. * tests/scripts-build.scm ("options->transformation, with-git-url"): New test. --- guix/scripts/build.scm | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 6b29c470fb..5883dbfb44 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -272,16 +272,16 @@ current 'gnutls' package, after which version 3.5.4 is grafted onto them." (rewrite obj) obj)))) +(define %not-equal + (char-set-complement (char-set #\=))) + (define (evaluate-git-replacement-specs specs proc) "Parse SPECS, a list of strings like \"guile=stable-2.2\", and return a list of package pairs, where (PROC PACKAGE URL BRANCH-OR-COMMIT) returns the replacement package. Raise an error if an element of SPECS uses invalid syntax, or if a package it refers to could not be found." - (define not-equal - (char-set-complement (char-set #\=))) - (map (lambda (spec) - (match (string-tokenize spec not-equal) + (match (string-tokenize spec %not-equal) ((name branch-or-commit) (let* ((old (specification->package name)) (source (package-source old)) @@ -341,6 +341,33 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (rewrite obj) obj)))) +(define (transform-package-source-git-url replacement-specs) + "Return a procedure that, when passed a package, replaces its dependencies +according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a list of strings like +\"guile-json=https://gitthing.com/…\" meaning that packages are built using +a checkout of the Git repository at the given URL." + ;; FIXME: Currently this cannot be combined with '--with-branch' or + ;; '--with-commit' because they all transform "from scratch". + (define replacements + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((name url) + (let* ((old (specification->package name)) + (new (package + (inherit old) + (source (git-checkout (url url) + (recursive? #t)))))) + (cons old new))))) + replacement-specs)) + + (define rewrite + (package-input-rewriting replacements)) + + (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 @@ -350,7 +377,8 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (with-input . ,transform-package-inputs) (with-graft . ,transform-package-inputs/graft) (with-branch . ,transform-package-source-branch) - (with-commit . ,transform-package-source-commit))) + (with-commit . ,transform-package-source-commit) + (with-git-url . ,transform-package-source-git-url))) (define %transformation-options ;; The command-line interface to the above transformations. @@ -368,7 +396,9 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (option '("with-branch") #t #f (parser 'with-branch)) (option '("with-commit") #t #f - (parser 'with-commit))))) + (parser 'with-commit)) + (option '("with-git-url") #t #f + (parser 'with-git-url))))) (define (show-transformation-options-help) (display (G_ " @@ -385,7 +415,10 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using build PACKAGE from the latest commit of BRANCH")) (display (G_ " --with-commit=PACKAGE=COMMIT - build PACKAGE from COMMIT"))) + build PACKAGE from COMMIT")) + (display (G_ " + --with-git-url=PACKAGE=URL + build PACKAGE from the repository at URL"))) (define (options->transformation opts) -- cgit v1.2.3 From f258d8862852db9779945658b3a3f2b8a2a4c217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 12 Mar 2019 21:39:48 +0100 Subject: packages: Add 'package-input-rewriting/spec'. * guix/packages.scm (package-input-rewriting/spec): New procedure. * tests/packages.scm ("package-input-rewriting/spec") ("package-input-rewriting/spec, partial match"): New tests. * doc/guix.texi (Defining Packages): Document it. --- guix/packages.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'guix') diff --git a/guix/packages.scm b/guix/packages.scm index f191327718..d20a2562c3 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -102,6 +102,7 @@ package-transitive-supported-systems package-mapping package-input-rewriting + package-input-rewriting/spec package-source-derivation package-derivation package-cross-derivation @@ -869,6 +870,43 @@ package and returns its new name after rewrite." (package-mapping rewrite (cut assq <> replacements))) +(define (package-input-rewriting/spec replacements) + "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." + (define table + (fold (lambda (replacement table) + (match replacement + ((spec . proc) + (let-values (((name version) + (package-name->name+version spec))) + (vhash-cons name (list version proc) table))))) + vlist-null + replacements)) + + (define (find-replacement package) + (vhash-fold* (lambda (item proc) + (or proc + (match item + ((#f proc) + proc) + ((version proc) + (and (version-prefix? version + (package-version package)) + proc))))) + #f + (package-name package) + table)) + + (define (rewrite package) + (match (find-replacement package) + (#f package) + (proc (proc package)))) + + (package-mapping rewrite find-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 -- cgit v1.2.3 From 0c0ff42a243b2da4f1deb52fe3961801008341da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 12 Mar 2019 22:12:18 +0100 Subject: guix build: Factorize 'package-git-url'. * guix/scripts/build.scm (package-git-url): New procedure. (evaluate-git-replacement-specs): Use it. --- guix/scripts/build.scm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 5883dbfb44..7b24cc8eb1 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -275,6 +275,19 @@ current 'gnutls' package, after which version 3.5.4 is grafted onto them." (define %not-equal (char-set-complement (char-set #\=))) +(define (package-git-url package) + "Return the URL of the Git repository for package, or raise an error if +the source of PACKAGE is not fetched from a Git repository." + (let ((source (package-source package))) + (cond ((and (origin? source) + (git-reference? (origin-uri source))) + (git-reference-url (origin-uri source))) + ((git-checkout? source) + (git-checkout-url source)) + (else + (leave (G_ "the source of ~a is not a Git reference~%") + (package-full-name package)))))) + (define (evaluate-git-replacement-specs specs proc) "Parse SPECS, a list of strings like \"guile=stable-2.2\", and return a list of package pairs, where (PROC PACKAGE URL BRANCH-OR-COMMIT) returns the @@ -285,15 +298,7 @@ syntax, or if a package it refers to could not be found." ((name branch-or-commit) (let* ((old (specification->package name)) (source (package-source old)) - (url (cond ((and (origin? source) - (git-reference? (origin-uri source))) - (git-reference-url (origin-uri source))) - ((git-checkout? source) - (git-checkout-url source)) - (else - (leave (G_ "the source of ~a is not a Git \ -reference~%") - (package-full-name old)))))) + (url (package-git-url old))) (cons old (proc old url branch-or-commit)))) (x (leave (G_ "invalid replacement specification: ~s~%") spec)))) -- cgit v1.2.3 From 14328b81a224b726f39dd030886ba8d332027427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 13 Mar 2019 10:11:54 +0100 Subject: guix build: Transformation options match packages by spec. This allows us to combine several transformations on a given package, in particular '--with-git-url' and '--with-branch'. Previously transformations would ignore each other since they would all take (specification->package SOURCE) as their replacement source, compare it by identity, which doesn't work if a previous transformation has already changed SOURCE. * guix/scripts/build.scm (evaluate-replacement-specs): Adjust to produce an alist as expected by 'package-input-rewriting/spec', with a package spec as the first element of each pair. (evaluate-git-replacement-specs): Likewise. (transform-package-inputs): Adjust accordingly and use 'package-input-rewriting/spec'. (transform-package-inputs/graft): Likewise. (transform-package-source-branch, transform-package-source-commit): Use 'package-input-rewriting/spec'. (transform-package-source-git-url): Likewise, and adjust the REPLACEMENTS alist accordingly. (options->transformation): Iterate over OPTS instead of over %TRANSFORMATIONS. Invoke transformations one by one. * tests/scripts-build.scm ("options->transformation, with-input"): Adjust test to compare packages by name rather than by identity. ("options->transformation, with-git-url + with-branch"): New test. --- guix/scripts/build.scm | 90 ++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 7b24cc8eb1..8ebcf79243 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -226,18 +226,21 @@ matching URIs given in SOURCES." obj))))) (define (evaluate-replacement-specs specs proc) - "Parse SPECS, a list of strings like \"guile=guile@2.1\", and invoke PROC on -each package pair specified by SPECS. Return the resulting list. Raise an -error if an element of SPECS uses invalid syntax, or if a package it refers to -could not be found." + "Parse SPECS, a list of strings like \"guile=guile@2.1\" and return a list +of package spec/procedure pairs as expected by 'package-input-rewriting/spec'. +PROC is called with the package to be replaced and its replacement according +to SPECS. Raise an error if an element of SPECS uses invalid syntax, or if a +package it refers to could not be found." (define not-equal (char-set-complement (char-set #\=))) (map (lambda (spec) (match (string-tokenize spec not-equal) - ((old new) - (proc (specification->package old) - (specification->package new))) + ((spec new) + (cons spec + (let ((new (specification->package new))) + (lambda (old) + (proc old new))))) (x (leave (G_ "invalid replacement specification: ~s~%") spec)))) specs)) @@ -248,8 +251,10 @@ dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a list of strings like \"guile=guile@2.1\" meaning that, any dependency on a package called \"guile\" must be replaced with a dependency on a version 2.1 of \"guile\"." - (let* ((replacements (evaluate-replacement-specs replacement-specs cons)) - (rewrite (package-input-rewriting replacements))) + (let* ((replacements (evaluate-replacement-specs replacement-specs + (lambda (old new) + new))) + (rewrite (package-input-rewriting/spec replacements))) (lambda (store obj) (if (package? obj) (rewrite obj) @@ -260,13 +265,12 @@ called \"guile\" must be replaced with a dependency on a version 2.1 of dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a list of strings like \"gnutls=gnutls@3.5.4\" meaning that packages are built using the current 'gnutls' package, after which version 3.5.4 is grafted onto them." - (define (replacement-pair old new) - (cons old - (package (inherit old) (replacement new)))) + (define (set-replacement old new) + (package (inherit old) (replacement new))) (let* ((replacements (evaluate-replacement-specs replacement-specs - replacement-pair)) - (rewrite (package-input-rewriting replacements))) + set-replacement)) + (rewrite (package-input-rewriting/spec replacements))) (lambda (store obj) (if (package? obj) (rewrite obj) @@ -295,11 +299,13 @@ replacement package. Raise an error if an element of SPECS uses invalid syntax, or if a package it refers to could not be found." (map (lambda (spec) (match (string-tokenize spec %not-equal) - ((name branch-or-commit) - (let* ((old (specification->package name)) - (source (package-source old)) - (url (package-git-url old))) - (cons old (proc old url branch-or-commit)))) + ((spec branch-or-commit) + (define (replace old) + (let* ((source (package-source old)) + (url (package-git-url old))) + (proc old url branch-or-commit))) + + (cons spec replace)) (x (leave (G_ "invalid replacement specification: ~s~%") spec)))) specs)) @@ -318,7 +324,7 @@ strings like \"guile-next=stable-3.0\" meaning that packages are built using (let* ((replacements (evaluate-git-replacement-specs replacement-specs replace)) - (rewrite (package-input-rewriting replacements))) + (rewrite (package-input-rewriting/spec replacements))) (lambda (store obj) (if (package? obj) (rewrite obj) @@ -340,7 +346,7 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (let* ((replacements (evaluate-git-replacement-specs replacement-specs replace)) - (rewrite (package-input-rewriting replacements))) + (rewrite (package-input-rewriting/spec replacements))) (lambda (store obj) (if (package? obj) (rewrite obj) @@ -351,22 +357,20 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is a list of strings like \"guile-json=https://gitthing.com/…\" meaning that packages are built using a checkout of the Git repository at the given URL." - ;; FIXME: Currently this cannot be combined with '--with-branch' or - ;; '--with-commit' because they all transform "from scratch". (define replacements (map (lambda (spec) (match (string-tokenize spec %not-equal) - ((name url) - (let* ((old (specification->package name)) - (new (package - (inherit old) - (source (git-checkout (url url) - (recursive? #t)))))) - (cons old new))))) + ((spec url) + (cons spec + (lambda (old) + (package + (inherit old) + (source (git-checkout (url url) + (recursive? #t))))))))) replacement-specs)) (define rewrite - (package-input-rewriting replacements)) + (package-input-rewriting/spec replacements)) (lambda (store obj) (if (package? obj) @@ -430,16 +434,22 @@ a checkout of the Git repository at the given URL." "Return a procedure that, when passed an object to build (package, derivation, etc.), applies the transformations specified by OPTS." (define applicable - ;; List of applicable transformations as symbol/procedure pairs. + ;; List of applicable transformations as symbol/procedure pairs in the + ;; order in which they appear on the command line. (filter-map (match-lambda - ((key . transform) - (match (filter-map (match-lambda - ((k . arg) - (and (eq? k key) arg))) - opts) - (() #f) - (args (cons key (transform args)))))) - %transformations)) + ((key . value) + (match (any (match-lambda + ((k . proc) + (and (eq? k key) proc))) + %transformations) + (#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))))))) + (reverse opts))) (lambda (store obj) (fold (match-lambda* -- cgit v1.2.3 From 845c44012c2a05436dc0a5316ff3c2a9e5bd725f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 13 Mar 2019 10:26:31 +0100 Subject: guix build: '--with-commit' makes recursive checkouts. This was an omission from commit 024a6bfba906742c136a47b4099f06880f1d3f15. * guix/scripts/build.scm (transform-package-source-commit): Add 'recursive?' field to SOURCE. * tests/scripts-build.scm ("options->transformation, with-branch") ("options->transformation, with-commit"): New tests. --- guix/scripts/build.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 8ebcf79243..20929d6110 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -342,7 +342,8 @@ strings like \"guile-next=cabba9e\" meaning that packages are built using (if (< (string-length commit) 7) commit (string-take commit 7)))) - (source (git-checkout (url url) (commit commit))))) + (source (git-checkout (url url) (commit commit) + (recursive? #t))))) (let* ((replacements (evaluate-git-replacement-specs replacement-specs replace)) -- cgit v1.2.3 From d831b1907900ea39c93cef7671acdbf9e04fafc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 13 Mar 2019 10:33:17 +0100 Subject: guix build: '--with-branch' strips slashes from the version string. This fixes things like: guix build glibc \ --with-git-url=glibc=git://sourceware.org/git/glibc.git \ --with-branch=glibc=release/2.25/master whereby slashes would before go straight to the 'version' field, leading to an invalid store file name. * guix/scripts/build.scm (transform-package-source-branch)[replace]: Replace slashes with hyphens in BRANCH when building the version string. --- guix/scripts/build.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 20929d6110..28864435df 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -318,7 +318,10 @@ strings like \"guile-next=stable-3.0\" meaning that packages are built using (define (replace old url branch) (package (inherit old) - (version (string-append "git." branch)) + (version (string-append "git." (string-map (match-lambda + (#\/ #\-) + (chr chr)) + branch))) (source (git-checkout (url url) (branch branch) (recursive? #t))))) -- cgit v1.2.3 From b6fd086a61b3004f9f5392f630155b9ad01752e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 18 Mar 2019 09:50:10 +0100 Subject: describe: Warn about 'GUIX_PACKAGE_PATH' in json and recutils format. Fixes . Reported by Pierre Neidhardt . * guix/scripts/describe.scm (display-package-search-path): Add catch-all case for FMT. --- guix/scripts/describe.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index 7d0ecb0a4d..b6287d3a4c 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018 Ludovic Courtès +;;; Copyright © 2018, 2019 Ludovic Courtès ;;; Copyright © 2018 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. @@ -85,7 +85,9 @@ Display information about the channels currently in use.\n")) (format #t "~%GUIX_PACKAGE_PATH=\"~a\"~%" string)) ('channels (format #t (G_ "~%;; warning: GUIX_PACKAGE_PATH=\"~a\"~%") - string)))))) + string)) + (_ + (warning (G_ "'GUIX_PACKAGE_PATH' is set but it is not captured~%"))))))) (define (channel->sexp channel) `(channel -- cgit v1.2.3 From 47956fa0c24efcdcba3493f0231c30e9a39ec7df Mon Sep 17 00:00:00 2001 From: ng0 Date: Thu, 14 Mar 2019 09:33:38 +0000 Subject: Correct name and email address for ng0. * .mailmap, Makefile.am, doc/guix.de.texi, doc/guix.fr.texi, doc/guix.texi, etc/completion/fish/guix.fish, gnu/packages/accessibility.scm, gnu/packages/admin.scm, gnu/packages/audio.scm, gnu/packages/autotools.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/cinnamon.scm, gnu/packages/compression.scm, gnu/packages/crypto.scm, gnu/packages/databases.scm, gnu/packages/django.scm, gnu/packages/dns.scm, gnu/packages/elixir.scm, gnu/packages/emacs-xyz.scm, gnu/packages/emacs.scm, gnu/packages/enlightenment.scm, gnu/packages/erlang.scm, gnu/packages/fonts.scm, gnu/packages/fontutils.scm, gnu/packages/forth.scm, gnu/packages/fvwm.scm, gnu/packages/games.scm, gnu/packages/gl.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gnuzilla.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm,gnu/packages/guile-xyz.scm, gnu/packages/haskell-check.scm, gnu/packages/haskell-crypto.scm, gnu/packages/haskell.scm, gnu/packages/image-viewers.scm, gnu/packages/image.scm, gnu/packages/irc.scm, gnu/packages/language.scm, gnu/packages/libcanberra.scm, gnu/packages/linux.scm, gnu/packages/lisp.scm, gnu/packages/lolcode.scm, gnu/packages/lxde.scm, gnu/packages/lxqt.scm, gnu/packages/mail.scm, gnu/packages/markup.scm, gnu/packages/mate.scm, gnu/packages/maths.scm, gnu/packages/mc.scm, gnu/packages/messaging.scm, gnu/packages/music.scm, gnu/packages/ncurses.scm, gnu/packages/networking.scm, gnu/packages/nickle.scm, gnu/packages/openbox.scm, gnu/packages/pdf.scm, gnu/packages/perl-check.scm, gnu/packages/perl.scm, gnu/packages/python-compression.scm, gnu/packages/python-crypto.scm, gnu/packages/python-web.scm, gnu/packages/python-xyz.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/ruby.scm, gnu/packages/rust.scm, gnu/packages/scheme.scm, gnu/packages/serialization.scm, gnu/packages/shells.scm, gnu/packages/ssh.scm, gnu/packages/suckless.scm, gnu/packages/tbb.scm, gnu/packages/telephony.scm, gnu/packages/text-editors.scm, gnu/packages/textutils.scm, gnu/packages/time.scm, gnu/packages/tls.scm, gnu/packages/tor.scm, gnu/packages/version-control.scm, gnu/packages/video.scm, gnu/packages/vim.scm, gnu/packages/web.scm, gnu/packages/wm.scm, gnu/packages/xdisorg.scm, gnu/packages/xfce.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/services/certbot.scm, gnu/services/desktop.scm, gnu/services/version-control.scm, gnu/services/web.scm, guix/import/hackage.scm, guix/licenses.scm: Correct name and email address for ng0. Signed-off-by: Tobias Geerinckx-Rice --- guix/import/hackage.scm | 2 +- guix/licenses.scm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/import/hackage.scm b/guix/import/hackage.scm index 48db764b3c..2a51420d14 100644 --- a/guix/import/hackage.scm +++ b/guix/import/hackage.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2016 Eric Bavier -;;; Copyright © 2016 Nils Gillmann +;;; Copyright © 2016 ng0 ;;; Copyright © 2018 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. diff --git a/guix/licenses.scm b/guix/licenses.scm index d22c3fa36e..676e71acdb 100644 --- a/guix/licenses.scm +++ b/guix/licenses.scm @@ -8,7 +8,7 @@ ;;; Copyright © 2016 Leo Famulari ;;; Copyright © 2016 Fabian Harfert ;;; Copyright © 2016 Rene Saavedra -;;; Copyright © 2016, 2017 Nils Gillmann +;;; Copyright © 2016, 2017 ng0 ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2017 Petter ;;; Copyright © 2017 Marius Bakke -- cgit v1.2.3 From ae031d453cc43f87481dcfb06051cb6a928f4c5c Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 13 Mar 2019 16:18:02 +0530 Subject: import: Add Launchpad updater. * guix/import/launchpad.scm: New file. * Makefile.am (MODULES): Register it. * doc/guix.texi (Invoking guix refresh): Mention the Launchpad updater. --- guix/import/launchpad.scm | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 guix/import/launchpad.scm (limited to 'guix') diff --git a/guix/import/launchpad.scm b/guix/import/launchpad.scm new file mode 100644 index 0000000000..ffd5e9221e --- /dev/null +++ b/guix/import/launchpad.scm @@ -0,0 +1,124 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Arun Isaac +;;; +;;; 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 . + +(define-module (guix import launchpad) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:use-module (web uri) + #:use-module ((guix download) #:prefix download:) + #:use-module (guix import json) + #:use-module (guix packages) + #:use-module (guix upstream) + #:use-module (guix utils) + #:export (%launchpad-updater)) + +(define (find-extension url) + "Return the extension of the archive e.g. '.tar.gz' given a URL, or +false if none is recognized" + (find (lambda (x) (string-suffix? x url)) + (list ".tar.gz" ".tar.bz2" ".tar.xz" + ".zip" ".tar" ".tgz" ".tbz" ".love"))) + +(define (updated-launchpad-url old-package new-version) + ;; Return a url for the OLD-PACKAGE with NEW-VERSION. If no source url in + ;; the OLD-PACKAGE is a Launchpad url, then return false. + + (define (updated-url url) + (and (string-prefix? "https://launchpad.net/" url) + (let ((ext (or (find-extension url) "")) + (name (package-name old-package)) + (version (package-version old-package)) + (repo (launchpad-repository url))) + (cond + ((and + (>= (length (string-split version #\.)) 2) + (string=? (string-append "https://launchpad.net/" + repo "/" (version-major+minor version) + "/" version "/+download/" repo "-" version ext) + url)) + (string-append "https://launchpad.net/" + repo "/" (version-major+minor new-version) + "/" new-version "/+download/" repo "-" new-version ext)) + (#t #f))))) ; Some URLs are not recognised. + + (let ((source-uri (and=> (package-source old-package) origin-uri)) + (fetch-method (and=> (package-source old-package) origin-method))) + (cond + ((eq? fetch-method download:url-fetch) + (match source-uri + ((? string?) + (updated-url source-uri)) + ((source-uri ...) + (find updated-url source-uri)))) + (else #f)))) + +(define (launchpad-package? package) + "Return true if PACKAGE is a package from Launchpad, else false." + (->bool (updated-launchpad-url package "1.0.0"))) + +(define (launchpad-repository url) + "Return a string e.g. linuxdcpp of the name of the repository, from a string +URL of the form +'https://launchpad.net/linuxdcpp/1.1/1.1.0/+download/linuxdcpp-1.1.0.tar.bz2'" + (match (string-split (uri-path (string->uri url)) #\/) + ((_ repo . rest) repo))) + +(define (latest-released-version package-name) + "Return a string of the newest released version name given the PACKAGE-NAME, +for example, 'linuxdcpp'. Return #f if there is no releases." + (define (pre-release? x) + ;; Versions containing anything other than digit characters and "." (for + ;; example, "5.1.0-rc1") are assumed to be pre-releases. + (not (string-every (char-set-union (char-set #\.) + char-set:digit) + (hash-ref x "version")))) + + (hash-ref + (last (remove + pre-release? + (hash-ref (json-fetch + (string-append "https://api.launchpad.net/1.0/" + package-name "/releases")) + "entries"))) + "version")) + +(define (latest-release pkg) + "Return an for the latest release of PKG." + (define (origin-github-uri origin) + (match (origin-uri origin) + ((? string? url) url) ; surely a Launchpad URL + ((urls ...) + (find (cut string-contains <> "launchpad.net") urls)))) + + (let* ((source-uri (origin-github-uri (package-source pkg))) + (name (package-name pkg)) + (newest-version (latest-released-version name))) + (if newest-version + (upstream-source + (package name) + (version newest-version) + (urls (list (updated-launchpad-url pkg newest-version)))) + #f))) ; On Launchpad but no proper releases + +(define %launchpad-updater + (upstream-updater + (name 'launchpad) + (description "Updater for Launchpad packages") + (pred launchpad-package?) + (latest latest-release))) -- cgit v1.2.3 From 427c87d0bdc06cc3ee7fc220fd3ad36084412533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 19 Mar 2019 11:03:35 +0100 Subject: pack: Produce relative symlinks when using '-f squashfs'. Fixes . * guix/scripts/pack.scm (squashfs-image)[build]: Use 'relative-file-name' when creating SYMLINKS. * guix/scripts/pack.scm (guix-pack): Pass #:relative-symlinks? #t when PACK-FORMAT is 'squashfs. --- guix/scripts/pack.scm | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 17a166d9d7..8685ba1d0a 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -306,11 +306,13 @@ added to the pack." (with-imported-modules (source-module-closure '((guix build utils) (guix build store-copy) + (guix build union) (gnu build install)) #:select? not-config?) #~(begin (use-modules (guix build utils) (guix build store-copy) + ((guix build union) #:select (relative-file-name)) (gnu build install) (srfi srfi-1) (srfi srfi-26) @@ -359,12 +361,18 @@ added to the pack." ,@(append-map (match-lambda ((source '-> target) - (list "-p" - (string-join - ;; name s mode uid gid symlink - (list source - "s" "777" "0" "0" - (string-append #$profile "/" target)))))) + ;; Create relative symlinks to work around a bug in + ;; Singularity 2.x: + ;; https://bugs.gnu.org/34913 + ;; https://github.com/sylabs/singularity/issues/1487 + (let ((target (string-append #$profile "/" target))) + (list "-p" + (string-join + ;; name s mode uid gid symlink + (list source + "s" "777" "0" "0" + (relative-file-name (dirname source) + target))))))) '#$symlinks) ;; Create empty mount points. @@ -881,7 +889,14 @@ Create a bundle of PACKAGE.\n")) (run-with-store store (mlet* %store-monad ((profile (profile-derivation manifest - #:relative-symlinks? relocatable? + + ;; Always produce relative + ;; symlinks for Singularity (see + ;; ). + #:relative-symlinks? + (or relocatable? + (eq? 'squashfs pack-format)) + #:hooks (if bootstrap? '() %default-profile-hooks) -- cgit v1.2.3 From 6c5e618ca004d3714d9de7676f2a984735bfe17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 19 Mar 2019 11:14:39 +0100 Subject: pack: Create an empty /home directory for '-f squashfs'. Fixes . * guix/scripts/pack.scm (squashfs-image)[build]: Pass "-p /home d 555 0 0". --- guix/scripts/pack.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index 8685ba1d0a..e5502ef9ca 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -378,7 +378,8 @@ added to the pack." ;; Create empty mount points. "-p" "/proc d 555 0 0" "-p" "/sys d 555 0 0" - "-p" "/dev d 555 0 0")) + "-p" "/dev d 555 0 0" + "-p" "/home d 555 0 0")) (when database ;; Initialize /var/guix. -- cgit v1.2.3 From ad4910eec06047124d29cb9a8d4b40dafdb71630 Mon Sep 17 00:00:00 2001 From: Marius Bakke Date: Sun, 17 Mar 2019 16:32:24 +0100 Subject: build-system/meson: Add #:allowed-references and #:disallowed-references. * guix/build-system/meson.scm (meson-build): Add support for #:allowed-references and #:disallowed-references. --- guix/build-system/meson.scm | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm index 8d49020454..370d185545 100644 --- a/guix/build-system/meson.scm +++ b/guix/build-system/meson.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 Peter Mikkelsen -;;; Copyright © 2018 Marius Bakke +;;; Copyright © 2018, 2019 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -109,9 +109,25 @@ (system (%current-system)) (imported-modules %meson-build-system-modules) (modules '((guix build meson-build-system) - (guix build utils)))) + (guix build utils))) + allowed-references + disallowed-references) "Build SOURCE using MESON, and with INPUTS, assuming that SOURCE has a 'meson.build' file." + + ;; TODO: Copied from build-system/gnu, factorize this! + (define canonicalize-reference + (match-lambda + ((? package? p) + (derivation->output-path (package-derivation store p system + #:graft? #f))) + (((? package? p) output) + (derivation->output-path (package-derivation store p system + #:graft? #f) + output)) + ((? string? output) + output))) + (define builder `(let ((build-phases (if ,glib-or-gtk? ,phases @@ -159,7 +175,15 @@ has a 'meson.build' file." #:inputs inputs #:modules imported-modules #:outputs outputs - #:guile-for-build guile-for-build)) + #:guile-for-build guile-for-build + #:allowed-references + (and allowed-references + (map canonicalize-reference + allowed-references)) + #:disallowed-references + (and disallowed-references + (map canonicalize-reference + disallowed-references)))) (define meson-build-system (build-system -- cgit v1.2.3