diff options
author | Leo Famulari <leo@famulari.name> | 2017-01-13 10:21:17 -0500 |
---|---|---|
committer | Leo Famulari <leo@famulari.name> | 2017-01-13 10:21:17 -0500 |
commit | cc0725914e74c4c4dec369f3e7cdb6f201b3fecd (patch) | |
tree | e68b452ed625a2db8ed10914fb0968fdc36c655d /guix/build | |
parent | a25b6880f1398ad36aea1d0e4e4105936a8b7e70 (diff) | |
parent | ce195ba12277ec4286ad0d8ddf7294655987ea9d (diff) |
Merge branch 'master' into python-tests
Diffstat (limited to 'guix/build')
-rw-r--r-- | guix/build/cargo-build-system.scm | 110 | ||||
-rw-r--r-- | guix/build/download.scm | 9 | ||||
-rw-r--r-- | guix/build/make-bootstrap.scm | 5 | ||||
-rw-r--r-- | guix/build/ocaml-build-system.scm | 119 | ||||
-rw-r--r-- | guix/build/syscalls.scm | 6 |
5 files changed, 242 insertions, 7 deletions
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm new file mode 100644 index 0000000000..7d656a8d58 --- /dev/null +++ b/guix/build/cargo-build-system.scm @@ -0,0 +1,110 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016 David Craven <david@craven.ch> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix build cargo-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 ftw) + #:use-module (ice-9 format) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%standard-phases + cargo-build)) + +;; Commentary: +;; +;; Builder-side code of the standard Rust package build procedure. +;; +;; Code: + +;; FIXME: Needs to be parsed from url not package name. +(define (package-name->crate-name name) + "Return the crate name of NAME." + (match (string-split name #\-) + (("rust" rest ...) + (string-join rest "-")) + (_ #f))) + +(define* (configure #:key inputs #:allow-other-keys) + "Replace Cargo.toml [dependencies] section with guix inputs." + ;; Make sure Cargo.toml is writeable when the crate uses git-fetch. + (chmod "Cargo.toml" #o644) + (let ((port (open-file "Cargo.toml" "a" #:encoding "utf-8"))) + (format port "~%[replace]~%") + (for-each + (match-lambda + ((name . path) + (let ((crate (package-name->crate-name name))) + (when (and crate path) + (match (string-split (basename path) #\-) + ((_ ... version) + (format port "\"~a:~a\" = { path = \"~a/share/rust-source\" }~%" + crate version path))))))) + inputs) + (close-port port)) + #t) + +(define* (build #:key (cargo-build-flags '("--release" "--frozen")) + #:allow-other-keys) + "Build a given Cargo package." + (if (file-exists? "Cargo.lock") + (zero? (apply system* `("cargo" "build" ,@cargo-build-flags))) + #t)) + +(define* (check #:key tests? #:allow-other-keys) + "Run tests for a given Cargo package." + (if (and tests? (file-exists? "Cargo.lock")) + (zero? (system* "cargo" "test")) + #t)) + +(define* (install #:key inputs outputs #:allow-other-keys) + "Install a given Cargo package." + (let* ((out (assoc-ref outputs "out")) + (src (assoc-ref inputs "source")) + (rsrc (string-append (assoc-ref outputs "src") + "/share/rust-source"))) + (mkdir-p rsrc) + ;; Rust doesn't have a stable ABI yet. Because of this + ;; Cargo doesn't have a search path for binaries yet. + ;; Until this changes we are working around this by + ;; distributing crates as source and replacing + ;; references in Cargo.toml with store paths. + (copy-recursively "src" (string-append rsrc "/src")) + (install-file "Cargo.toml" rsrc) + ;; When the package includes executables we install + ;; it using cargo install. This fails when the crate + ;; doesn't contain an executable. + (if (file-exists? "Cargo.lock") + (system* "cargo" "install" "--root" out) + (mkdir out)))) + +(define %standard-phases + ;; 'configure' phase is not needed. + (modify-phases gnu:%standard-phases + (replace 'configure configure) + (replace 'build build) + (replace 'check check) + (replace 'install install))) + +(define* (cargo-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Cargo package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +;;; cargo-build-system.scm ends here diff --git a/guix/build/download.scm b/guix/build/download.scm index 8e32b3d7ff..203338b527 100644 --- a/guix/build/download.scm +++ b/guix/build/download.scm @@ -289,9 +289,12 @@ DIRECTORY. Those authority certificates are checked when (string-suffix? ".pem" file))) '()))) (for-each (lambda (file) - (set-certificate-credentials-x509-trust-file! - cred (string-append directory "/" file) - x509-certificate-format/pem)) + (let ((file (string-append directory "/" file))) + ;; Protect against dangling symlinks. + (when (file-exists? file) + (set-certificate-credentials-x509-trust-file! + cred file + x509-certificate-format/pem)))) (or files '())) cred)) diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm index bc4c0e3d5f..21c78cc8f5 100644 --- a/guix/build/make-bootstrap.scm +++ b/guix/build/make-bootstrap.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com> +;;; Copyright © 2015, 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com> ;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. @@ -64,7 +64,8 @@ when producing a bootstrap libc." #t)) (define %libc-object-files-rx "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|\ -util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|libc(rt|)_nonshared\\.a)$") +util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|(libc(rt|)|libpthread)\ +_nonshared\\.a)$") (setvbuf (current-output-port) _IOLBF) (let* ((libdir (string-append output "/lib"))) diff --git a/guix/build/ocaml-build-system.scm b/guix/build/ocaml-build-system.scm new file mode 100644 index 0000000000..f77251ca09 --- /dev/null +++ b/guix/build/ocaml-build-system.scm @@ -0,0 +1,119 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016, 2017 Julien Lepiller <julien@lepiller.eu> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (guix build ocaml-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:export (%standard-phases + ocaml-build)) + +;; Commentary: +;; +;; Builder-side code of the standard ocaml build procedure. +;; +;; Code: + +(define* (ocaml-findlib-environment #:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out"))) + (setenv "OCAMLFIND_DESTDIR" (string-append out "/lib/ocaml/site-lib")) + (setenv "OCAMLFIND_LDCONF" "ignore")) + #t) + +(define* (configure #:key outputs (configure-flags '()) + (test-flags '("--enable-tests")) tests? + #:allow-other-keys) + "Configure the given package." + (let* ((out (assoc-ref outputs "out"))) + (format #t "build directory: ~s~%" (getcwd)) + (if (file-exists? "setup.ml") + (let ((args `("-configure" + "--prefix" ,out + ,@(if tests? + test-flags + '()) + ,@configure-flags))) + (format #t "running 'setup.ml' with arguments ~s~%" args) + (zero? (apply system* "ocaml" "setup.ml" args))) + (let ((args `("-prefix" ,out ,@configure-flags))) + (format #t "running 'configure' with arguments ~s~%" args) + (zero? (apply system* "./configure" args)))))) + +(define* (build #:key inputs outputs (build-flags '()) (make-flags '()) + (use-make? #f) #:allow-other-keys) + "Build the given package." + (if (and (file-exists? "setup.ml") (not use-make?)) + (zero? (apply system* "ocaml" "setup.ml" "-build" build-flags)) + (if (file-exists? "Makefile") + (zero? (apply system* "make" make-flags)) + (let ((file (if (file-exists? "pkg/pkg.ml") "pkg/pkg.ml" "pkg/build.ml"))) + (zero? (apply system* "ocaml" "-I" + (string-append (assoc-ref inputs "findlib") + "/lib/ocaml/site-lib") + file build-flags)))))) + +(define* (check #:key inputs outputs (make-flags '()) (test-target "test") tests? + (use-make? #f) #:allow-other-keys) + "Install the given package." + (when tests? + (if (and (file-exists? "setup.ml") (not use-make?)) + (zero? (system* "ocaml" "setup.ml" (string-append "-" test-target))) + (if (file-exists? "Makefile") + (zero? (apply system* "make" test-target make-flags)) + (let ((file (if (file-exists? "pkg/pkg.ml") "pkg/pkg.ml" "pkg/build.ml"))) + (zero? (system* "ocaml" "-I" + (string-append (assoc-ref inputs "findlib") + "/lib/ocaml/site-lib") + file test-target))))))) + +(define* (install #:key outputs (build-flags '()) (make-flags '()) (use-make? #f) + (install-target "install") + #:allow-other-keys) + "Install the given package." + (let ((out (assoc-ref outputs "out"))) + (if (and (file-exists? "setup.ml") (not use-make?)) + (zero? (apply system* "ocaml" "setup.ml" + (string-append "-" install-target) build-flags)) + (if (file-exists? "Makefile") + (zero? (apply system* "make" install-target make-flags)) + (zero? (system* "opam-installer" "-i" (string-append "--prefix=" out) + (string-append "--libdir=" out "/lib/ocaml/site-lib"))))))) + +(define* (prepare-install #:key outputs #:allow-other-keys) + "Prepare for building the given package." + (mkdir-p (string-append (assoc-ref outputs "out") "/lib/ocaml/site-lib")) + (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))) + +(define %standard-phases + ;; Everything is as with the GNU Build System except for the `configure' + ;; , `build', `check' and `install' phases. + (modify-phases gnu:%standard-phases + (add-before 'configure 'ocaml-findlib-environment + ocaml-findlib-environment) + (add-before 'install 'prepare-install prepare-install) + (replace 'configure configure) + (replace 'build build) + (replace 'check check) + (replace 'install install))) + +(define* (ocaml-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given package, applying all of PHASES in order." + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +;;; ocaml-build-system.scm ends here diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 9386c0f5d0..2e37846ff0 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> ;;; @@ -1474,7 +1474,9 @@ always a positive integer." ;; ENOTTY is what we're after but 2012-and-earlier Linux versions ;; would return EINVAL instead in some cases: ;; <https://bugs.ruby-lang.org/issues/10494>. - (if (or (= errno ENOTTY) (= errno EINVAL)) + ;; Furthermore, some FUSE file systems like unionfs return ENOSYS for + ;; that ioctl. + (if (memv errno (list ENOTTY EINVAL ENOSYS)) (fall-back) (apply throw args)))))) |