diff options
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build-system/gnu.scm | 8 | ||||
-rw-r--r-- | guix/build/gnu-build-system.scm | 16 | ||||
-rw-r--r-- | guix/build/haskell-build-system.scm | 98 | ||||
-rw-r--r-- | guix/build/python-build-system.scm | 9 | ||||
-rw-r--r-- | guix/build/ruby-build-system.scm | 13 | ||||
-rw-r--r-- | guix/build/utils.scm | 9 | ||||
-rw-r--r-- | guix/search-paths.scm | 6 |
7 files changed, 115 insertions, 44 deletions
diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index 67ae46faed..afd57668e2 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -284,7 +284,8 @@ standard packages used as implicit inputs of the GNU build system." (parallel-tests? #t) (patch-shebangs? #t) (strip-binaries? #t) - (strip-flags ''("--strip-debug")) + (strip-flags ''("--strip-debug" + "--enable-deterministic-archives")) (strip-directories ''("lib" "lib64" "libexec" "bin" "sbin")) (validate-runpath? #t) @@ -419,7 +420,8 @@ is one of `host' or `target'." (parallel-build? #t) (parallel-tests? #t) (patch-shebangs? #t) (strip-binaries? #t) - (strip-flags ''("--strip-debug")) + (strip-flags ''("--strip-debug" + "--enable-deterministic-archives")) (strip-directories ''("lib" "lib64" "libexec" "bin" "sbin")) (validate-runpath? #t) diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index ff7646b22c..2abaa6efdc 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,6 +39,13 @@ ;; ;; Code: +(define* (set-SOURCE-DATE-EPOCH #:rest _) + "Set the 'SOURCE_DATE_EPOCH' environment variable. This is used by tools +that incorporate timestamps as a way to tell them to use a fixed timestamp. +See https://reproducible-builds.org/specs/source-date-epoch/." + (setenv "SOURCE_DATE_EPOCH" "1") + #t) + (define (first-subdirectory dir) "Return the path of the first sub-directory of DIR." (file-system-fold (lambda (path stat result) @@ -329,7 +336,8 @@ makefiles." (objcopy-command (if target (string-append target "-objcopy") "objcopy")) - (strip-flags '("--strip-debug")) + (strip-flags '("--strip-debug" + "--enable-deterministic-archives")) (strip-directories '("lib" "lib64" "libexec" "bin" "sbin")) #:allow-other-keys) @@ -367,7 +375,7 @@ makefiles." ;; `bfd_fill_in_gnu_debuglink_section' function.) No reference to ;; DEBUG-OUTPUT is kept because bfd keeps only the basename of the debug ;; file. - (zero? (system* objcopy-command + (zero? (system* objcopy-command "--enable-deterministic-archives" (string-append "--add-gnu-debuglink=" (debug-file file)) file))) @@ -548,7 +556,7 @@ DOCUMENTATION-COMPRESSOR-FLAGS." ;; Standard build phases, as a list of symbol/procedure pairs. (let-syntax ((phases (syntax-rules () ((_ p ...) `((p . ,p) ...))))) - (phases set-paths install-locale unpack + (phases set-SOURCE-DATE-EPOCH set-paths install-locale unpack patch-usr-bin-file patch-source-shebangs configure patch-generated-file-shebangs build check install diff --git a/guix/build/haskell-build-system.scm b/guix/build/haskell-build-system.scm index 4506e96af9..8e2aee381d 100644 --- a/guix/build/haskell-build-system.scm +++ b/guix/build/haskell-build-system.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> +;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2015 Paul van der Walt <paul@denknerd.org> ;;; ;;; This file is part of GNU Guix. @@ -25,6 +26,7 @@ #:use-module (ice-9 rdelim) #:use-module (ice-9 regex) #:use-module (ice-9 match) + #:use-module (ice-9 vlist) #:export (%standard-phases haskell-build)) @@ -78,6 +80,7 @@ and parameters ~s~%" (((_ . dir) ...) dir) (_ '()))) + (ghc-path (getenv "GHC_PACKAGE_PATH")) (params (append `(,(string-append "--prefix=" out)) `(,(string-append "--libdir=" (or lib out) "/lib")) `(,(string-append "--bindir=" (or bin out) "/bin")) @@ -97,6 +100,10 @@ and parameters ~s~%" '("--enable-tests") '()) configure-flags))) + ;; Cabal errors if GHC_PACKAGE_PATH is set during 'configure', so unset + ;; and restore it. + (unsetenv "GHC_PACKAGE_PATH") + ;; For packages where the Cabal build-type is set to "Configure", ;; ./configure will be executed. In these cases, the following ;; environment variable is needed to be able to find the shell executable. @@ -105,7 +112,9 @@ and parameters ~s~%" ;; <https://www.haskell.org/cabal/users-guide/developing-packages.html>. (when (file-exists? "configure") (setenv "CONFIG_SHELL" "sh")) - (run-setuphs "configure" params))) + (run-setuphs "configure" params) + + (setenv "GHC_PACKAGE_PATH" ghc-path))) (define* (build #:rest empty) "Build a given Haskell package." @@ -143,6 +152,12 @@ first match and return the content of the group." (format #t "Compiler ~a not supported~%" name-version))))) +;;; TODO: Move this to (guix build utils)? +(define-syntax-rule (with-null-error-port exp) + "Evaluate EXP with the error port pointing to the bit bucket." + (with-error-to-port (%make-void-port "w") + (lambda () exp))) + (define (make-ghc-package-database system inputs outputs) "Generate the GHC package database." (let* ((haskell (assoc-ref inputs "haskell")) @@ -150,44 +165,89 @@ first match and return the content of the group." (((_ . dir) ...) dir) (_ '()))) - (conf-dirs (search-path-as-list - `(,(string-append "lib/" - (package-name-version haskell) - "/package.conf.d")) - input-dirs)) + ;; Silence 'find-files' (see 'evaluate-search-paths') + (conf-dirs (with-null-error-port + (search-path-as-list + `(,(string-append "lib/" (package-name-version haskell))) + input-dirs #:pattern ".*\\.conf.d$"))) (conf-files (append-map (cut find-files <> "\\.conf$") conf-dirs))) (mkdir-p %tmp-db-dir) (for-each (lambda (file) - (copy-file file - (string-append %tmp-db-dir "/" (basename file)))) + (let ((dest (string-append %tmp-db-dir "/" (basename file)))) + (unless (file-exists? dest) + (copy-file file dest)))) conf-files) (zero? (system* "ghc-pkg" (string-append "--package-db=" %tmp-db-dir) "recache")))) (define* (register #:key name system inputs outputs #:allow-other-keys) - "Generate the compiler registration file for a given Haskell package. Don't -generate the cache as it would clash in user profiles." + "Generate the compiler registration and binary package database files for a +given Haskell package." + + (define (conf-depends conf-file) + ;; Return a list of pkg-ids from the "depends" field in CONF-FILE + (let ((port (open-input-file conf-file)) + (field-rx (make-regexp "^(.*):"))) + (let loop ((collecting #f) + (deps '())) + (let* ((line (read-line port)) + (field (and=> (regexp-exec field-rx line) + (cut match:substring <> 1)))) + (cond + ((and=> field (cut string=? <> "depends")) + ;; The first dependency is listed on the same line as "depends:", + ;; so drop those characters. A line may list more than one .conf. + (let ((d (string-tokenize (string-drop line 8)))) + (loop #t (append d deps)))) + ((and collecting field) + (begin + (close-port port) + (reverse! deps))) + (collecting + (loop #t (append (string-tokenize line) deps))) + (else (loop #f deps))))))) + + (define (install-transitive-deps conf-file src dest) + ;; Copy .conf files from SRC to DEST for dependencies in CONF-FILE, and + ;; their dependencies, etc. + (let loop ((seen vlist-null) + (lst (conf-depends conf-file))) + (match lst + (() #t) ;done + ((id . tail) + (if (not (vhash-assoc id seen)) + (let ((dep-conf (string-append src "/" id ".conf")) + (dep-conf* (string-append dest "/" id ".conf"))) + (copy-file dep-conf dep-conf*) ;XXX: maybe symlink instead? + (loop (vhash-cons id #t seen) + (append lst (conf-depends dep-conf)))) + (loop seen tail)))))) + (let* ((out (assoc-ref outputs "out")) (haskell (assoc-ref inputs "haskell")) (lib (string-append out "/lib")) (config-dir (string-append lib "/" (package-name-version haskell) - "/package.conf.d")) + "/" name ".conf.d")) (id-rx (make-regexp "^id: *(.*)$")) (config-file (string-append out "/" name ".conf")) (params (list (string-append "--gen-pkg-config=" config-file)))) (run-setuphs "register" params) ;; The conf file is created only when there is a library to register. - (when (file-exists? config-file) - (mkdir-p config-dir) - (let ((config-file-name+id - (call-with-ascii-input-file config-file (cut grep id-rx <>)))) - (rename-file config-file - (string-append config-dir "/" config-file-name+id - ".conf")))) - #t)) + (or (not (file-exists? config-file)) + (begin + (mkdir-p config-dir) + (let* ((config-file-name+id + (call-with-ascii-input-file config-file (cut grep id-rx <>)))) + (install-transitive-deps config-file %tmp-db-dir config-dir) + (rename-file config-file + (string-append config-dir "/" + config-file-name+id ".conf")) + (zero? (system* "ghc-pkg" + (string-append "--package-db=" config-dir) + "recache"))))))) (define* (check #:key tests? test-target #:allow-other-keys) "Run the test suite of a given Haskell package." diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm index 8025b7fec6..9109fb4ac7 100644 --- a/guix/build/python-build-system.scm +++ b/guix/build/python-build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2013, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> @@ -136,18 +136,11 @@ installed with setuptools." #t)) #t)) -(define* (set-SOURCE-DATE-EPOCH #:rest _) - "Set the 'SOURCE_DATE_EPOCH' environment variable." - ;; Use zero as the timestamp in .pyc files so that builds are deterministic. - ;; TODO: Remove it when this variable is set in GNU:%STANDARD-PHASES. - (setenv "SOURCE_DATE_EPOCH" "1")) - (define %standard-phases ;; 'configure' and 'build' phases are not needed. Everything is done during ;; 'install'. (modify-phases gnu:%standard-phases (add-after 'unpack 'ensure-no-mtimes-pre-1980 ensure-no-mtimes-pre-1980) - (add-after 'unpack 'set-SOURCE-DATE-EPOCH set-SOURCE-DATE-EPOCH) (delete 'configure) (replace 'install install) (replace 'check check) diff --git a/guix/build/ruby-build-system.scm b/guix/build/ruby-build-system.scm index 6439bf69eb..a4ac3b307c 100644 --- a/guix/build/ruby-build-system.scm +++ b/guix/build/ruby-build-system.scm @@ -27,7 +27,8 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (%standard-phases - ruby-build)) + ruby-build + gem-home)) ;; Commentary: ;; @@ -141,3 +142,13 @@ GEM-FLAGS are passed to the 'gem' invokation, if present." (define* (ruby-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) (apply gnu:gnu-build #:inputs inputs #:phases phases args)) + +(define (gem-home store-path ruby-version) + "Return a string to the gem home directory in the store given a STORE-PATH +and the RUBY-VERSION used to build that ruby package" + (string-append + store-path + "/lib/ruby/gems/" + (regexp-substitute #f + (string-match "^[0-9]+\\.[0-9]+" ruby-version) + 0 ".0"))) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index e3f9edc5b5..2988193fce 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -385,10 +385,13 @@ for under the directories designated by FILES. For example: (append-map (lambda (input) (append-map (lambda (file) (let ((file (string-append input "/" file))) - ;; XXX: By using 'find-files', we implicitly - ;; assume #:type 'regular. (if pattern - (find-files file pattern) + (find-files file (lambda (file stat) + (and stat + (eq? type (stat:type stat)) + ((file-name-predicate pattern) file stat))) + #:stat stat + #:directories? #t) (let ((stat (stat file #f))) (if (and stat (eq? type (stat:type stat))) (list file) diff --git a/guix/search-paths.scm b/guix/search-paths.scm index 7fd15d440c..7a6fe67959 100644 --- a/guix/search-paths.scm +++ b/guix/search-paths.scm @@ -139,12 +139,6 @@ report only settings not already effective." (let* ((values (or (and=> (getenv variable) (cut string-tokenize* <> separator)) '())) - ;; Add a trailing slash to force symlinks to be treated as - ;; directories when 'find-files' traverses them. - (files (if pattern - (map (cut string-append <> "/") files) - files)) - ;; XXX: Silence 'find-files' when it stumbles upon non-existent ;; directories (see ;; <http://lists.gnu.org/archive/html/guix-devel/2015-01/msg00269.html>.) |