summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
Diffstat (limited to 'guix')
-rw-r--r--guix/build-system/clojure.scm195
-rw-r--r--guix/build-system/ocaml.scm24
-rw-r--r--guix/build/clojure-build-system.scm110
-rw-r--r--guix/build/clojure-utils.scm265
-rw-r--r--guix/build/ocaml-build-system.scm45
-rw-r--r--guix/download.scm35
-rw-r--r--guix/progress.scm28
-rw-r--r--guix/scripts/system.scm115
8 files changed, 713 insertions, 104 deletions
diff --git a/guix/build-system/clojure.scm b/guix/build-system/clojure.scm
new file mode 100644
index 0000000000..5a91bcba00
--- /dev/null
+++ b/guix/build-system/clojure.scm
@@ -0,0 +1,195 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
+;;;
+;;; 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-system clojure)
+ #:use-module (guix build clojure-utils)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system ant)
+ #:use-module ((guix build-system gnu)
+ #:select (standard-packages)
+ #:prefix gnu:)
+
+ #:use-module (guix derivations)
+ #:use-module (guix packages)
+ #:use-module ((guix search-paths)
+ #:select
+ ((search-path-specification->sexp . search-path-spec->sexp)))
+ #:use-module (guix utils)
+
+ #:use-module (ice-9 match)
+ #:export (%clojure-build-system-modules
+ clojure-build
+ clojure-build-system))
+
+;; Commentary:
+;;
+;; Standard build procedure for Clojure packages.
+;;
+;; Code:
+
+(define-with-docs %clojure-build-system-modules
+ "Build-side modules imported and used by default."
+ `((guix build clojure-build-system)
+ (guix build clojure-utils)
+ (guix build guile-build-system)
+ ,@%ant-build-system-modules))
+
+(define-with-docs %default-clojure
+ "The default Clojure package."
+ (delay (@* (gnu packages lisp) clojure)))
+
+(define-with-docs %default-jdk
+ "The default JDK package."
+ (delay (@* (gnu packages java) icedtea)))
+
+(define-with-docs %default-zip
+ "The default ZIP package."
+ (delay (@* (gnu packages compression) zip)))
+
+(define* (lower name
+ #:key
+ source target
+ inputs native-inputs
+ (clojure (force %default-clojure))
+ (jdk (force %default-jdk))
+ (zip (force %default-zip))
+ outputs system
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (let ((private-keywords '(#:source #:target
+ #:inputs #:native-inputs
+ #:clojure #:jdk #:zip)))
+
+ (if target
+ (error "No cross-compilation for clojure-build-system yet: LOWER"
+ target) ; FIXME
+ (bag (name name)
+ (system system)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ,@(gnu:standard-packages)))
+ (build-inputs `(("clojure" ,clojure)
+ ("jdk" ,jdk "jdk")
+ ("zip" ,zip)
+ ,@native-inputs))
+ (outputs outputs)
+ (build clojure-build)
+ (arguments (strip-keyword-arguments private-keywords
+ arguments))))))
+
+(define-with-docs source->output-path
+ "Convert source input to output path."
+ (match-lambda
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source)))
+
+(define-with-docs maybe-guile->guile
+ "Find the right guile."
+ (match-lambda
+ ((and maybe-guile (? package?))
+ maybe-guile)
+ (#f ; default
+ (@* (gnu packages commencement) guile-final))))
+
+(define* (clojure-build store name inputs
+ #:key
+ (source-dirs `',%source-dirs)
+ (test-dirs `',%test-dirs)
+ (compile-dir %compile-dir)
+
+ (jar-names `',(package-name->jar-names name))
+ (main-class %main-class)
+ (omit-source? %omit-source?)
+
+ (aot-include `',%aot-include)
+ (aot-exclude `',%aot-exclude)
+
+ doc-dirs ; no sensible default
+ (doc-regex %doc-regex)
+
+ (tests? %tests?)
+ (test-include `',%test-include)
+ (test-exclude `',%test-exclude)
+
+ (phases '(@ (guix build clojure-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (search-paths '())
+ (system (%current-system))
+ (guile #f)
+
+ (imported-modules %clojure-build-system-modules)
+ (modules %clojure-build-system-modules))
+ "Build SOURCE with INPUTS."
+ (let ((builder `(begin
+ (use-modules ,@modules)
+ (clojure-build #:name ,name
+ #:source ,(source->output-path
+ (assoc-ref inputs "source"))
+
+ #:source-dirs ,source-dirs
+ #:test-dirs ,test-dirs
+ #:compile-dir ,compile-dir
+
+ #:jar-names ,jar-names
+ #:main-class ,main-class
+ #:omit-source? ,omit-source?
+
+ #:aot-include ,aot-include
+ #:aot-exclude ,aot-exclude
+
+ #:doc-dirs ,doc-dirs
+ #:doc-regex ,doc-regex
+
+ #:tests? ,tests?
+ #:test-include ,test-include
+ #:test-exclude ,test-exclude
+
+ #:phases ,phases
+ #:outputs %outputs
+ #:search-paths ',(map search-path-spec->sexp
+ search-paths)
+ #:system ,system
+ #:inputs %build-inputs)))
+
+ (guile-for-build (package-derivation store
+ (maybe-guile->guile guile)
+ system
+ #:graft? #f)))
+
+ (build-expression->derivation store name builder
+ #:inputs inputs
+ #:system system
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build)))
+
+(define clojure-build-system
+ (build-system
+ (name 'clojure)
+ (description "Simple Clojure build system using plain old 'compile'")
+ (lower lower)))
+
+;;; clojure.scm ends here
diff --git a/guix/build-system/ocaml.scm b/guix/build-system/ocaml.scm
index 34a22ecffa..e5b715f55d 100644
--- a/guix/build-system/ocaml.scm
+++ b/guix/build-system/ocaml.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2016, 2017, 2018 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -28,7 +28,9 @@
#:use-module (srfi srfi-1)
#:export (%ocaml-build-system-modules
package-with-ocaml4.01
+ package-with-ocaml4.02
strip-ocaml4.01-variant
+ strip-ocaml4.02-variant
ocaml-build
ocaml-build-system))
@@ -82,6 +84,14 @@
(let ((module (resolve-interface '(gnu packages ocaml))))
(module-ref module 'ocaml4.01-findlib)))
+(define (default-ocaml4.02)
+ (let ((ocaml (resolve-interface '(gnu packages ocaml))))
+ (module-ref ocaml 'ocaml-4.02)))
+
+(define (default-ocaml4.02-findlib)
+ (let ((module (resolve-interface '(gnu packages ocaml))))
+ (module-ref module 'ocaml4.02-findlib)))
+
(define* (package-with-explicit-ocaml ocaml findlib old-prefix new-prefix
#:key variant-property)
"Return a procedure of one argument, P. The procedure creates a package
@@ -139,12 +149,24 @@ pre-defined variants."
"ocaml-" "ocaml4.01-"
#:variant-property 'ocaml4.01-variant))
+(define package-with-ocaml4.02
+ (package-with-explicit-ocaml (delay (default-ocaml4.02))
+ (delay (default-ocaml4.02-findlib))
+ "ocaml-" "ocaml4.02-"
+ #:variant-property 'ocaml4.02-variant))
+
(define (strip-ocaml4.01-variant p)
"Remove the 'ocaml4.01-variant' property from P."
(package
(inherit p)
(properties (alist-delete 'ocaml4.01-variant (package-properties p)))))
+(define (strip-ocaml4.02-variant p)
+ "Remove the 'ocaml4.02-variant' property from P."
+ (package
+ (inherit p)
+ (properties (alist-delete 'ocaml4.02-variant (package-properties p)))))
+
(define* (lower name
#:key source inputs native-inputs outputs system target
(ocaml (default-ocaml))
diff --git a/guix/build/clojure-build-system.scm b/guix/build/clojure-build-system.scm
new file mode 100644
index 0000000000..d8f7c89f85
--- /dev/null
+++ b/guix/build/clojure-build-system.scm
@@ -0,0 +1,110 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
+;;;
+;;; 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 clojure-build-system)
+ #:use-module ((guix build ant-build-system)
+ #:select ((%standard-phases . %standard-phases@ant)
+ ant-build))
+ #:use-module (guix build clojure-utils)
+ #:use-module (guix build java-utils)
+ #:use-module (guix build utils)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ clojure-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard build procedure for Clojure packages.
+;;
+;; Code:
+
+(define* (build #:key
+ source-dirs compile-dir
+ jar-names main-class omit-source?
+ aot-include aot-exclude
+ #:allow-other-keys)
+ "Standard 'build' phase for clojure-build-system."
+ (let* ((libs (append-map find-clojure-libs source-dirs))
+ (libs* (include-list\exclude-list aot-include
+ aot-exclude
+ #:all-list libs)))
+ (mkdir-p compile-dir)
+ (eval-with-clojure `(run! compile ',libs*)
+ source-dirs)
+ (let ((source-dir-files-alist (map (lambda (dir)
+ (cons dir (find-files* dir)))
+ source-dirs))
+ ;; workaround transitive compilation in Clojure
+ (classes (filter (lambda (class)
+ (any (cut compiled-from? class <>)
+ libs*))
+ (find-files* compile-dir))))
+ (for-each (cut create-jar <> (cons (cons compile-dir classes)
+ (if omit-source?
+ '()
+ source-dir-files-alist))
+ #:main-class main-class)
+ jar-names)
+ #t)))
+
+(define* (check #:key
+ test-dirs
+ jar-names
+ tests? test-include test-exclude
+ #:allow-other-keys)
+ "Standard 'check' phase for clojure-build-system. Note that TEST-EXCLUDE has
+priority over TEST-INCLUDE."
+ (if tests?
+ (let* ((libs (append-map find-clojure-libs test-dirs))
+ (libs* (include-list\exclude-list test-include
+ test-exclude
+ #:all-list libs)))
+ (for-each (lambda (jar)
+ (eval-with-clojure `(do (apply require
+ '(clojure.test ,@libs*))
+ (apply clojure.test/run-tests
+ ',libs*))
+ (cons jar test-dirs)))
+ jar-names)))
+ #t)
+
+(define-with-docs install
+ "Standard 'install' phase for clojure-build-system."
+ (install-jars "./"))
+
+(define-with-docs %standard-phases
+ "Standard build phases for clojure-build-system."
+ (modify-phases %standard-phases@ant
+ (replace 'build build)
+ (replace 'check check)
+ (replace 'install install)
+ (add-after 'install-license-files 'install-doc install-doc)))
+
+(define* (clojure-build #:key
+ inputs
+ (phases %standard-phases)
+ #:allow-other-keys
+ #:rest args)
+ "Build the given Clojure package, applying all of PHASES in order."
+ (apply ant-build
+ #:inputs inputs
+ #:phases phases
+ args))
+
+;;; clojure-build-system.scm ends here
diff --git a/guix/build/clojure-utils.scm b/guix/build/clojure-utils.scm
new file mode 100644
index 0000000000..027777b4d1
--- /dev/null
+++ b/guix/build/clojure-utils.scm
@@ -0,0 +1,265 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
+;;;
+;;; 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 clojure-utils)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 ftw)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-8)
+ #:use-module (srfi srfi-26)
+ #:export (@*
+ @@*
+ define-with-docs
+
+ %doc-regex
+ install-doc
+
+ %source-dirs
+ %test-dirs
+ %compile-dir
+ package-name->jar-names
+ %main-class
+ %omit-source?
+ %aot-include
+ %aot-exclude
+ %tests?
+ %test-include
+ %test-exclude
+
+ %clojure-regex
+ canonicalize-relative-path
+ find-files*
+ file-sans-extension
+ relative-path->clojure-lib-string
+ find-clojure-libs
+ compiled-from?
+ include-list\exclude-list
+ eval-with-clojure
+ create-jar))
+
+(define-syntax-rule (@* module name)
+ "Like (@ MODULE NAME), but resolves at run time."
+ (module-ref (resolve-interface 'module) 'name))
+
+(define-syntax-rule (@@* module name)
+ "Like (@@ MODULE NAME), but resolves at run time."
+ (module-ref (resolve-module 'module) 'name))
+
+(define-syntax-rule (define-with-docs name docs val)
+ "Create top-level variable named NAME with doc string DOCS and value VAL."
+ (begin (define name val)
+ (set-object-property! name 'documentation docs)))
+
+(define-with-docs %doc-regex
+ "Default regex for matching the base name of top-level documentation files."
+ (format #f
+ "(~a)|(\\.(html|markdown|md|txt)$)"
+ (@@ (guix build guile-build-system)
+ %documentation-file-regexp)))
+
+(define* (install-doc #:key
+ doc-dirs
+ (doc-regex %doc-regex)
+ outputs
+ #:allow-other-keys)
+ "Install the following to the default documentation directory:
+
+1. Top-level files with base name matching DOC-REGEX.
+2. All files (recursively) inside DOC-DIRS.
+
+DOC-REGEX can be compiled or uncompiled."
+ (let* ((out (assoc-ref outputs "out"))
+ (doc (assoc-ref outputs "doc"))
+ (name-ver (strip-store-file-name out))
+ (dest-dir (string-append (or doc out) "/share/doc/" name-ver "/"))
+ (doc-regex* (if (string? doc-regex)
+ (make-regexp doc-regex)
+ doc-regex)))
+ (for-each (cut install-file <> dest-dir)
+ (remove (compose file-exists?
+ (cut string-append dest-dir <>))
+ (scandir "./" (cut regexp-exec doc-regex* <>))))
+ (for-each (cut copy-recursively <> dest-dir)
+ doc-dirs)
+ #t))
+
+(define-with-docs %source-dirs
+ "A default list of source directories."
+ '("src/"))
+
+(define-with-docs %test-dirs
+ "A default list of test directories."
+ '("test/"))
+
+(define-with-docs %compile-dir
+ "Default directory for holding class files."
+ "classes/")
+
+(define (package-name->jar-names name)
+ "Given NAME, a package name like \"foo-0.9.1b\",
+return the list of default jar names: (\"foo-0.9.1b.jar\" \"foo.jar\")."
+ (map (cut string-append <> ".jar")
+ (list name
+ (receive (base-name _)
+ (package-name->name+version name)
+ base-name))))
+
+(define-with-docs %main-class
+ "Default name for main class. It should be a symbol or #f."
+ #f)
+
+(define-with-docs %omit-source?
+ "Include source in jars by default."
+ #f)
+
+(define-with-docs %aot-include
+ "A default list of symbols deciding what to compile. Note that the exclude
+list has priority over the include list. The special keyword #:all represents
+all libraries found under the source directories."
+ '(#:all))
+
+(define-with-docs %aot-exclude
+ "A default list of symbols deciding what not to compile.
+See the doc string of '%aot-include' for more details."
+ '())
+
+(define-with-docs %tests?
+ "Enable tests by default."
+ #t)
+
+(define-with-docs %test-include
+ "A default list of symbols deciding what tests to include. Note that the
+exclude list has priority over the include list. The special keyword #:all
+represents all tests found under the test directories."
+ '(#:all))
+
+(define-with-docs %test-exclude
+ "A default list of symbols deciding what tests to exclude.
+See the doc string of '%test-include' for more details."
+ '())
+
+(define-with-docs %clojure-regex
+ "Default regex for matching the base name of clojure source files."
+ "\\.cljc?$")
+
+(define-with-docs canonicalize-relative-path
+ "Like 'canonicalize-path', but for relative paths.
+Canonicalizations requiring the path to exist are omitted."
+ (let ((remove.. (lambda (ls)
+ (fold-right (match-lambda*
+ (((and comp (not "..")) (".." comps ...))
+ comps)
+ ((comp (comps ...))
+ (cons comp comps)))
+ '()
+ ls))))
+ (compose (match-lambda
+ (() ".")
+ (ls (string-join ls "/")))
+ remove..
+ (cut remove (cut member <> '("" ".")) <>)
+ (cut string-split <> #\/))))
+
+(define (find-files* base-dir . args)
+ "Similar to 'find-files', but with BASE-DIR stripped and result
+canonicalized."
+ (map canonicalize-relative-path
+ (with-directory-excursion base-dir
+ (apply find-files "./" args))))
+
+;;; FIXME: should be moved to (guix build utils)
+(define-with-docs file-sans-extension
+ "Strip extension from path, if any."
+ (@@ (guix build guile-build-system)
+ file-sans-extension))
+
+(define (relative-path->clojure-lib-string path)
+ "Convert PATH to a clojure library string."
+ (string-map (match-lambda
+ (#\/ #\.)
+ (#\_ #\-)
+ (chr chr))
+ (file-sans-extension path)))
+
+(define* (find-clojure-libs base-dir
+ #:key (clojure-regex %clojure-regex))
+ "Return the list of clojure libraries found under BASE-DIR.
+
+CLOJURE-REGEX can be compiled or uncompiled."
+ (map (compose string->symbol
+ relative-path->clojure-lib-string)
+ (find-files* base-dir clojure-regex)))
+
+(define (compiled-from? class lib)
+ "Given class file CLASS and clojure library symbol LIB, decide if CLASS
+results from compiling LIB."
+ (string-prefix? (symbol->string lib)
+ (relative-path->clojure-lib-string class)))
+
+(define* (include-list\exclude-list include-list exclude-list
+ #:key all-list)
+ "Given INCLUDE-LIST and EXCLUDE-LIST, replace all occurences of #:all by
+slicing ALL-LIST into them and compute their list difference."
+ (define (replace-#:all ls all-ls)
+ (append-map (match-lambda
+ (#:all all-ls)
+ (x (list x)))
+ ls))
+ (let ((include-list* (replace-#:all include-list all-list))
+ (exclude-list* (replace-#:all exclude-list all-list)))
+ (lset-difference equal? include-list* exclude-list*)))
+
+(define (eval-with-clojure expr extra-paths)
+ "Evaluate EXPR with clojure.
+
+EXPR must be a s-expression writable by guile and readable by clojure.
+For examples, '(require '[clojure.string]) will not work,
+because the guile writer converts brackets to parentheses.
+
+EXTRA-PATHS is a list of paths which will be appended to $CLASSPATH."
+ (let* ((classpath (getenv "CLASSPATH"))
+ (classpath* (string-join (cons classpath extra-paths) ":")))
+ (invoke "java"
+ "-classpath" classpath*
+ "clojure.main"
+ "--eval" (object->string expr))))
+
+(define* (create-jar output-jar dir-files-alist
+ #:key
+ (verbose? #t)
+ (compress? #f)
+ (main-class %main-class))
+ "Given DIR-FILES-ALIST, an alist of the form: ((DIR . FILES) ...)
+Create jar named OUTPUT-JAR from FILES with DIR stripped."
+ (let ((grouped-options (string-append "c"
+ (if verbose? "v" "")
+ "f"
+ (if compress? "" "0")
+ (if main-class "e" ""))))
+ (apply invoke `("jar"
+ ,grouped-options
+ ,output-jar
+ ,@(if main-class (list (symbol->string main-class)) '())
+ ,@(append-map (match-lambda
+ ((dir . files)
+ (append-map (lambda (file)
+ `("-C" ,dir ,file))
+ files)))
+ dir-files-alist)))))
diff --git a/guix/build/ocaml-build-system.scm b/guix/build/ocaml-build-system.scm
index d10431d8ef..99111ad300 100644
--- a/guix/build/ocaml-build-system.scm
+++ b/guix/build/ocaml-build-system.scm
@@ -49,37 +49,40 @@
'())
,@configure-flags)))
(format #t "running 'setup.ml' with arguments ~s~%" args)
- (zero? (apply system* "ocaml" "setup.ml" args)))
+ (apply invoke "ocaml" "setup.ml" args))
(let ((args `("-prefix" ,out ,@configure-flags)))
(format #t "running 'configure' with arguments ~s~%" args)
- (zero? (apply system* "./configure" args))))))
+ (apply invoke "./configure" args))))
+ #t)
(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))
+ (apply invoke "ocaml" "setup.ml" "-build" build-flags)
(if (file-exists? "Makefile")
- (zero? (apply system* "make" make-flags))
+ (apply invoke "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))))))
+ (apply invoke "ocaml" "-I"
+ (string-append (assoc-ref inputs "findlib")
+ "/lib/ocaml/site-lib")
+ file build-flags))))
+ #t)
(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)))
+ (invoke "ocaml" "setup.ml" (string-append "-" test-target))
(if (file-exists? "Makefile")
- (zero? (apply system* "make" test-target make-flags))
+ (apply invoke "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)))))))
+ (invoke "ocaml" "-I"
+ (string-append (assoc-ref inputs "findlib")
+ "/lib/ocaml/site-lib")
+ file test-target)))))
+ #t)
(define* (install #:key outputs (build-flags '()) (make-flags '()) (use-make? #f)
(install-target "install")
@@ -87,17 +90,19 @@
"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))
+ (apply invoke "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")))))))
+ (apply invoke "make" install-target make-flags)
+ (invoke "opam-installer" "-i" (string-append "--prefix=" out)
+ (string-append "--libdir=" out "/lib/ocaml/site-lib")))))
+ #t)
(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")))
+ (mkdir-p (string-append (assoc-ref outputs "out") "/bin"))
+ #t)
(define %standard-phases
;; Everything is as with the GNU Build System except for the `configure'
diff --git a/guix/download.scm b/guix/download.scm
index 988117885c..0f92e12c08 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -372,19 +372,28 @@
;; List of content-addressed mirrors. Each mirror is represented as a
;; procedure that takes a file name, an algorithm (symbol) and a hash
;; (bytevector), and returns a URL or #f.
- ;; Note: Avoid 'https' to mitigate <http://bugs.gnu.org/22774>.
- ;; TODO: Add more.
- '(list (lambda (file algo hash)
- ;; Files served by 'guix publish' are accessible under a single
- ;; hash algorithm.
- (string-append "http://mirror.hydra.gnu.org/file/"
- file "/" (symbol->string algo) "/"
- (bytevector->nix-base32-string hash)))
- (lambda (file algo hash)
- ;; 'tarballs.nixos.org' supports several algorithms.
- (string-append "http://tarballs.nixos.org/"
- (symbol->string algo) "/"
- (bytevector->nix-base32-string hash)))))
+ '(begin
+ (use-modules (guix base32) (guix base16))
+
+ (list (lambda (file algo hash)
+ ;; Files served by 'guix publish' are accessible under a single
+ ;; hash algorithm.
+ (string-append "https://mirror.hydra.gnu.org/file/"
+ file "/" (symbol->string algo) "/"
+ (bytevector->nix-base32-string hash)))
+ (lambda (file algo hash)
+ ;; 'tarballs.nixos.org' supports several algorithms.
+ (string-append "https://tarballs.nixos.org/"
+ (symbol->string algo) "/"
+ (bytevector->nix-base32-string hash)))
+ (lambda (file algo hash)
+ ;; Software Heritage usually archives VCS history rather than
+ ;; tarballs, but tarballs are sometimes available (and can be
+ ;; explicitly stored there.) For example, see
+ ;; <https://archive.softwareheritage.org/api/1/content/sha256:92d0fa1c311cacefa89853bdb53c62f4110cdfda3820346b59cbd098f40f955e/>.
+ (string-append "https://archive.softwareheritage.org/api/1/content/"
+ (symbol->string algo) ":"
+ (bytevector->base16-string hash) "/raw/")))))
(define %content-addressed-mirror-file
;; Content-addressed mirrors stored in a file.
diff --git a/guix/progress.scm b/guix/progress.scm
index 9da667a027..65080bcf24 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2017 Sou Bunnbu <iyzsong@gmail.com>
;;; Copyright © 2015 Steve Sprang <scs@stevesprang.com>
;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -197,7 +198,7 @@ throughput."
(define elapsed
(duration->seconds
(time-difference (current-time time-monotonic) start-time)))
- (if (number? size)
+ (if (and (number? size) (not (zero? size)))
(let* ((% (* 100.0 (/ transferred size)))
(throughput (/ transferred elapsed))
(left (format #f " ~a ~a" file
@@ -211,17 +212,20 @@ throughput."
(current-terminal-columns))
log-port)
(force-output log-port))
- (let* ((throughput (/ transferred elapsed))
- (left (format #f " ~a" file))
- (right (format #f "~a/s ~a | ~a transferred"
- (byte-count->string throughput)
- (seconds->string elapsed)
- (byte-count->string transferred))))
- (erase-current-line log-port)
- (display (string-pad-middle left right
- (current-terminal-columns))
- log-port)
- (force-output log-port))))
+ ;; If we don't know the total size, the last transfer will have a 0B
+ ;; size. Don't display it.
+ (unless (zero? transferred)
+ (let* ((throughput (/ transferred elapsed))
+ (left (format #f " ~a" file))
+ (right (format #f "~a/s ~a | ~a transferred"
+ (byte-count->string throughput)
+ (seconds->string elapsed)
+ (byte-count->string transferred))))
+ (erase-current-line log-port)
+ (display (string-pad-middle left right
+ (current-terminal-columns))
+ log-port)
+ (force-output log-port)))))
(define %progress-interval
;; Default interval between subsequent outputs for rate-limited displays.
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 9ba9428a08..00d2fe4829 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -175,12 +175,16 @@ TARGET, and register them."
(return *unspecified*)))
-(define* (install-bootloader installer-drv
+(define* (install-bootloader installer
#:key
bootcfg bootcfg-file
target)
- "Call INSTALLER-DRV with error handling, in %STORE-MONAD."
- (with-monad %store-monad
+ "Run INSTALLER, a bootloader installation script, with error handling, in
+%STORE-MONAD."
+ (mlet %store-monad ((installer-drv (if installer
+ (lower-object installer)
+ (return #f)))
+ (bootcfg (lower-object bootcfg)))
(let* ((gc-root (string-append target %gc-roots-directory
"/bootcfg"))
(temp-gc-root (string-append gc-root ".new"))
@@ -247,21 +251,21 @@ the ownership of '~a' may be incorrect!~%")
(format (lift format %store-monad))
(populate (lift2 populate-root-file-system %store-monad)))
- (mbegin %store-monad
- ;; Copy the closure of BOOTCFG, which includes OS-DIR,
- ;; eventual background image and so on.
- (maybe-copy
- (derivation->output-path bootcfg))
+ (mlet %store-monad ((bootcfg (lower-object bootcfg)))
+ (mbegin %store-monad
+ ;; Copy the closure of BOOTCFG, which includes OS-DIR,
+ ;; eventual background image and so on.
+ (maybe-copy (derivation->output-path bootcfg))
- ;; Create a bunch of additional files.
- (format log-port "populating '~a'...~%" target)
- (populate os-dir target)
+ ;; Create a bunch of additional files.
+ (format log-port "populating '~a'...~%" target)
+ (populate os-dir target)
- (mwhen install-bootloader?
- (install-bootloader bootloader-installer
- #:bootcfg bootcfg
- #:bootcfg-file bootcfg-file
- #:target target)))))
+ (mwhen install-bootloader?
+ (install-bootloader bootloader-installer
+ #:bootcfg bootcfg
+ #:bootcfg-file bootcfg-file
+ #:target target))))))
;;;
@@ -790,19 +794,18 @@ checking this by themselves in their 'check' procedure."
(warning (G_ "Consider running 'guix pull' before 'reconfigure'.~%"))
(warning (G_ "Failing to do that may downgrade your system!~%"))))
-(define (bootloader-installer-derivation installer
- bootloader device target)
+(define (bootloader-installer-script installer
+ bootloader device target)
"Return a file calling INSTALLER gexp with given BOOTLOADER, DEVICE
and TARGET arguments."
- (with-monad %store-monad
- (gexp->file "bootloader-installer"
- (with-imported-modules '((gnu build bootloader)
- (guix build utils))
- #~(begin
- (use-modules (gnu build bootloader)
- (guix build utils)
- (ice-9 binary-ports))
- (#$installer #$bootloader #$device #$target))))))
+ (scheme-file "bootloader-installer"
+ (with-imported-modules '((gnu build bootloader)
+ (guix build utils))
+ #~(begin
+ (use-modules (gnu build bootloader)
+ (guix build utils)
+ (ice-9 binary-ports))
+ (#$installer #$bootloader #$device #$target)))))
(define* (perform-action action os
#:key skip-safety-checks?
@@ -830,6 +833,25 @@ static checks."
(define println
(cut format #t "~a~%" <>))
+ (define menu-entries
+ (if (eq? 'init action)
+ '()
+ (map boot-parameters->menu-entry (profile-boot-parameters))))
+
+ (define bootloader
+ (bootloader-configuration-bootloader (operating-system-bootloader os)))
+
+ (define bootcfg
+ (and (not (eq? 'container action))
+ (operating-system-bootcfg os menu-entries)))
+
+ (define bootloader-script
+ (let ((installer (bootloader-installer bootloader))
+ (target (or target "/")))
+ (bootloader-installer-script installer
+ (bootloader-package bootloader)
+ bootloader-target target)))
+
(when (eq? action 'reconfigure)
(maybe-suggest-running-guix-pull))
@@ -849,39 +871,16 @@ static checks."
#:image-size image-size
#:full-boot? full-boot?
#:mappings mappings))
- (bootloader -> (bootloader-configuration-bootloader
- (operating-system-bootloader os)))
- (bootloader-package
- (let ((package (bootloader-package bootloader)))
- (if package
- (package->derivation package)
- (return #f))))
- (bootcfg (if (eq? 'container action)
- (return #f)
- (operating-system-bootcfg
- os
- (if (eq? 'init action)
- '()
- (map boot-parameters->menu-entry
- (profile-boot-parameters))))))
- (bootcfg-file -> (bootloader-configuration-file bootloader))
- (bootloader-installer
- (let ((installer (bootloader-installer bootloader))
- (target (or target "/")))
- (bootloader-installer-derivation installer
- bootloader-package
- bootloader-target target)))
;; For 'init' and 'reconfigure', always build BOOTCFG, even if
;; --no-bootloader is passed, because we then use it as a GC root.
;; See <http://bugs.gnu.org/21068>.
- (drvs -> (if (memq action '(init reconfigure))
- (if (and install-bootloader? bootloader-package)
- (list sys bootcfg
- bootloader-package
- bootloader-installer)
- (list sys bootcfg))
- (list sys)))
+ (drvs (mapm %store-monad lower-object
+ (if (memq action '(init reconfigure))
+ (if install-bootloader?
+ (list sys bootcfg bootloader-script)
+ (list sys bootcfg))
+ (list sys))))
(% (if derivations-only?
(return (for-each (compose println derivation-file-name)
drvs))
@@ -890,7 +889,7 @@ static checks."
(if (or dry-run? derivations-only?)
(return #f)
- (begin
+ (let ((bootcfg-file (bootloader-configuration-file bootloader)))
(for-each (compose println derivation->output-path)
drvs)
@@ -899,7 +898,7 @@ static checks."
(mbegin %store-monad
(switch-to-system os)
(mwhen install-bootloader?
- (install-bootloader bootloader-installer
+ (install-bootloader bootloader-script
#:bootcfg bootcfg
#:bootcfg-file bootcfg-file
#:target "/"))))