summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorEfraim Flashner <efraim@flashner.co.il>2019-01-09 10:48:42 +0200
committerEfraim Flashner <efraim@flashner.co.il>2019-01-09 10:52:41 +0200
commit0e289672503a4e1599ef826d49f2fa5575081942 (patch)
treecdaec28207956090b7cebff805135754dcb22f06 /guix
parent0109b89c5834b5374f248dc3681702180013f41f (diff)
parent6df4d8338d2bf94ab729e3b12e42ace0a06687ae (diff)
downloadgnu-guix-0e289672503a4e1599ef826d49f2fa5575081942.tar
gnu-guix-0e289672503a4e1599ef826d49f2fa5575081942.tar.gz
Merge remote-tracking branch 'origin/master' into staging
Diffstat (limited to 'guix')
-rw-r--r--guix/build/git.scm52
-rw-r--r--guix/build/pull.scm154
-rw-r--r--guix/channels.scm24
-rw-r--r--guix/gexp.scm64
-rw-r--r--guix/import/cran.scm17
-rw-r--r--guix/import/github.scm30
-rw-r--r--guix/import/opam.scm126
-rw-r--r--guix/scripts/build.scm8
-rw-r--r--guix/scripts/import/opam.scm27
-rw-r--r--guix/scripts/lint.scm13
-rw-r--r--guix/scripts/pull.scm4
-rw-r--r--guix/self.scm137
-rw-r--r--guix/ui.scm4
13 files changed, 347 insertions, 313 deletions
diff --git a/guix/build/git.scm b/guix/build/git.scm
index 2d1700a9b9..669e38cd32 100644
--- a/guix/build/git.scm
+++ b/guix/build/git.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2016, 2019 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -18,6 +18,8 @@
(define-module (guix build git)
#:use-module (guix build utils)
+ #:use-module (srfi srfi-34)
+ #:use-module (ice-9 format)
#:export (git-fetch))
;;; Commentary:
@@ -39,31 +41,39 @@ recursively. Return #t on success, #f otherwise."
(mkdir-p directory)
- (with-directory-excursion directory
- (invoke git-command "init")
- (invoke git-command "remote" "add" "origin" url)
- (if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit))
- (invoke git-command "checkout" "FETCH_HEAD")
- (begin
- (setvbuf (current-output-port) 'line)
- (format #t "Failed to do a shallow fetch; retrying a full fetch...~%")
- (invoke git-command "fetch" "origin")
- (invoke git-command "checkout" commit)))
- (when recursive?
- ;; Now is the time to fetch sub-modules.
- (unless (zero? (system* git-command "submodule" "update"
- "--init" "--recursive"))
- (error "failed to fetch sub-modules" url))
+ (guard (c ((invoke-error? c)
+ (format (current-error-port)
+ "git-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
+ (invoke-error-program c)
+ (invoke-error-arguments c)
+ (or (invoke-error-exit-status c) ;XXX: not quite accurate
+ (invoke-error-stop-signal c)
+ (invoke-error-term-signal c)))
+ (delete-file-recursively directory)
+ #f))
+ (with-directory-excursion directory
+ (invoke git-command "init")
+ (invoke git-command "remote" "add" "origin" url)
+ (if (zero? (system* git-command "fetch" "--depth" "1" "origin" commit))
+ (invoke git-command "checkout" "FETCH_HEAD")
+ (begin
+ (setvbuf (current-output-port) 'line)
+ (format #t "Failed to do a shallow fetch; retrying a full fetch...~%")
+ (invoke git-command "fetch" "origin")
+ (invoke git-command "checkout" commit)))
+ (when recursive?
+ ;; Now is the time to fetch sub-modules.
+ (invoke git-command "submodule" "update" "--init" "--recursive")
- ;; In sub-modules, '.git' is a flat file, not a directory,
- ;; so we can use 'find-files' here.
- (for-each delete-file-recursively
- (find-files directory "^\\.git$")))
+ ;; In sub-modules, '.git' is a flat file, not a directory,
+ ;; so we can use 'find-files' here.
+ (for-each delete-file-recursively
+ (find-files directory "^\\.git$")))
;; The contents of '.git' vary as a function of the current
;; status of the Git repo. Since we want a fixed output, this
;; directory needs to be taken out.
(delete-file-recursively ".git")
- #t))
+ #t)))
;;; git.scm ends here
diff --git a/guix/build/pull.scm b/guix/build/pull.scm
deleted file mode 100644
index a011e366f6..0000000000
--- a/guix/build/pull.scm
+++ /dev/null
@@ -1,154 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@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 pull)
- #:use-module (guix modules)
- #:use-module (guix build utils)
- #:use-module (guix build compile)
- #:use-module (ice-9 ftw)
- #:use-module (ice-9 match)
- #:use-module (ice-9 format)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-11)
- #:use-module (srfi srfi-26)
- #:use-module (srfi srfi-34)
- #:export (build-guix))
-
-;;; Commentary:
-;;;
-;;; Helpers for the 'guix pull' command to unpack and build Guix.
-;;;
-;;; Code:
-
-(define (has-all-its-dependencies? file)
- "Return true if the dependencies of the module defined in FILE are
-available, false otherwise."
- (let ((module (call-with-input-file file
- (lambda (port)
- (match (read port)
- (('define-module name _ ...)
- name))))))
- ;; If one of the dependencies of MODULE is missing, we get a
- ;; '&missing-dependency-error'.
- (guard (c ((missing-dependency-error? c) #f))
- (source-module-closure (list module) #:select? (const #t)))))
-
-(define (all-scheme-files directory)
- "Return a sorted list of Scheme files found in DIRECTORY."
- ;; Load guix/ modules before gnu/ modules to get somewhat steadier
- ;; progress reporting.
- (sort (filter (cut string-suffix? ".scm" <>)
- (find-files directory "\\.scm"))
- (let ((guix (string-append directory "/guix"))
- (gnu (string-append directory "/gnu")))
- (lambda (a b)
- (or (and (string-prefix? guix a)
- (string-prefix? gnu b))
- (string<? a b))))))
-
-
-(define* (build-guix out source
- #:key
- system
- storedir localstatedir sysconfdir sbindir
-
- (package-name "GNU Guix")
- (package-version "0")
- (bug-report-address "bug-guix@gnu.org")
- (home-page-url "https://gnu.org/s/guix")
-
- libgcrypt zlib gzip bzip2 xz
-
- (debug-port (%make-void-port "w"))
- (log-port (current-error-port)))
- "Build and install Guix in directory OUT using SOURCE, a directory
-containing the source code. Write any debugging output to DEBUG-PORT."
- (setvbuf (current-output-port) _IOLBF)
- (setvbuf (current-error-port) _IOLBF)
-
- (with-directory-excursion source
- (format #t "copying and compiling to '~a' with Guile ~a...~%"
- out (version))
-
- ;; Copy everything under guix/ and gnu/ plus {guix,gnu}.scm.
- (copy-recursively "guix" (string-append out "/guix")
- #:log debug-port)
- (copy-recursively "gnu" (string-append out "/gnu")
- #:log debug-port)
- (copy-file "guix.scm" (string-append out "/guix.scm"))
- (copy-file "gnu.scm" (string-append out "/gnu.scm"))
-
- ;; Instantiate a (guix config) module that preserves the original
- ;; settings.
- (copy-file "guix/config.scm.in"
- (string-append out "/guix/config.scm"))
- (substitute* (string-append out "/guix/config.scm")
- (("@PACKAGE_NAME@") package-name)
- (("@PACKAGE_VERSION@") package-version)
- (("@PACKAGE_BUGREPORT@") bug-report-address)
- (("@PACKAGE_URL@") home-page-url)
- (("@storedir@") storedir)
- (("@guix_localstatedir@") localstatedir)
- (("@guix_sysconfdir@") sysconfdir)
- (("@guix_sbindir@") sbindir)
- (("@guix_system@") system)
- (("@LIBGCRYPT@") (string-append libgcrypt "/lib/libgcrypt"))
- (("@LIBZ@") (string-append zlib "/lib/libz"))
- (("@GZIP@") (string-append gzip "/bin/gzip"))
- (("@BZIP2@") (string-append bzip2 "/bin/bzip2"))
- (("@XZ@") (string-append xz "/bin/xz"))
- (("@NIX_INSTANTIATE@") "nix-instantiate")) ;for (guix import nix)
-
- ;; Augment the search path so Scheme code can be compiled.
- (set! %load-path (cons out %load-path))
- (set! %load-compiled-path (cons out %load-compiled-path))
-
- ;; Compile the .scm files. Hide warnings.
- (parameterize ((current-warning-port (%make-void-port "w")))
- ;; Filter out files depending on Guile-SSH when Guile-SSH is missing.
- (let ((files (filter has-all-its-dependencies?
- (all-scheme-files out))))
- (compile-files out out files
-
- #:workers (parallel-job-count)
-
- ;; Disable warnings.
- #:warning-options '()
-
- #:report-load
- (lambda (file total completed)
- (display #\cr log-port)
- (format log-port
- "loading...\t~5,1f% of ~d files" ;FIXME: i18n
- (* 100. (/ completed total)) total)
- (force-output log-port)
- (format debug-port "~%loading '~a'...~%" file))
-
- #:report-compilation
- (lambda (file total completed)
- (display #\cr log-port)
- (format log-port "compiling...\t~5,1f% of ~d files" ;FIXME: i18n
- (* 100. (/ completed total)) total)
- (force-output log-port)
- (format debug-port "~%compiling '~a'...~%" file))))))
-
- (newline)
- #t)
-
-;;; pull.scm ends here
diff --git a/guix/channels.scm b/guix/channels.scm
index 75503bb0ae..6b860f3bd8 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This file is part of GNU Guix.
@@ -335,6 +335,26 @@ modules in the old ~/.config/guix/latest style."
(define packages
(resolve-interface '(gnu packages guile)))
+ (define modules+compiled
+ ;; Since MODULES contains both .scm and .go files at its root, re-bundle
+ ;; it so that it has share/guile/site and lib/guile, which is what
+ ;; 'whole-package' expects.
+ (computed-file (derivation-name modules)
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ (define version
+ (effective-version))
+ (define share
+ (string-append #$output "/share/guile/site"))
+ (define lib
+ (string-append #$output "/lib/guile/" version))
+
+ (mkdir-p share) (mkdir-p lib)
+ (symlink #$modules (string-append share "/" version))
+ (symlink #$modules (string-append lib "/site-ccache"))))))
+
(letrec-syntax ((list (syntax-rules (->)
((_)
'())
@@ -346,7 +366,7 @@ modules in the old ~/.config/guix/latest style."
((_ variable rest ...)
(cons (module-ref packages 'variable)
(list rest ...))))))
- (whole-package name modules
+ (whole-package name modules+compiled
;; In the "old style", %SELF-BUILD-FILE would simply return a
;; derivation that builds modules. We have to infer what the
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 88cabc8ed5..f7c064297b 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
;;;
@@ -388,8 +388,9 @@ This is the declarative counterpart of 'gexp->derivation'."
(mlet %store-monad ((guile (lower-object guile system
#:target target)))
(apply gexp->derivation name gexp #:guile-for-build guile
- options))
- (apply gexp->derivation name gexp options)))))
+ #:system system #:target target options))
+ (apply gexp->derivation name gexp
+ #:system system #:target target options)))))
(define-record-type <program-file>
(%program-file name gexp guile path)
@@ -1314,30 +1315,33 @@ they can refer to each other."
#:key (extensions '()))
"Return as a monadic value a gexp that sets '%load-path' and
'%load-compiled-path' to point to MODULES, a list of module names. MODULES
-are searched for in PATH."
- (mlet %store-monad ((modules (imported-modules modules
- #:module-path path))
- (compiled (compiled-modules modules
- #:extensions extensions
- #:module-path path)))
- (return (gexp (eval-when (expand load eval)
- (set! %load-path
- (cons (ungexp modules)
- (append (map (lambda (extension)
- (string-append extension
- "/share/guile/site/"
- (effective-version)))
- '((ungexp-native-splicing extensions)))
- %load-path)))
- (set! %load-compiled-path
- (cons (ungexp compiled)
- (append (map (lambda (extension)
- (string-append extension
- "/lib/guile/"
- (effective-version)
- "/site-ccache"))
- '((ungexp-native-splicing extensions)))
- %load-compiled-path))))))))
+are searched for in PATH. Return #f when MODULES and EXTENSIONS are empty."
+ (if (and (null? modules) (null? extensions))
+ (with-monad %store-monad
+ (return #f))
+ (mlet %store-monad ((modules (imported-modules modules
+ #:module-path path))
+ (compiled (compiled-modules modules
+ #:extensions extensions
+ #:module-path path)))
+ (return (gexp (eval-when (expand load eval)
+ (set! %load-path
+ (cons (ungexp modules)
+ (append (map (lambda (extension)
+ (string-append extension
+ "/share/guile/site/"
+ (effective-version)))
+ '((ungexp-native-splicing extensions)))
+ %load-path)))
+ (set! %load-compiled-path
+ (cons (ungexp compiled)
+ (append (map (lambda (extension)
+ (string-append extension
+ "/lib/guile/"
+ (effective-version)
+ "/site-ccache"))
+ '((ungexp-native-splicing extensions)))
+ %load-compiled-path)))))))))
(define* (gexp->script name exp
#:key (guile (default-guile))
@@ -1361,7 +1365,11 @@ imported modules in its search path. Look up EXP's modules in MODULE-PATH."
"#!~a/bin/guile --no-auto-compile~%!#~%"
(ungexp guile))
- (write '(ungexp set-load-path) port)
+ (ungexp-splicing
+ (if set-load-path
+ (gexp ((write '(ungexp set-load-path) port)))
+ (gexp ())))
+
(write '(ungexp exp) port)
(chmod port #o555))))
#:module-path module-path)))
diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index aaa1caf035..15163bd165 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -125,7 +125,7 @@ package definition."
((package-inputs ...)
`((,type (,'quasiquote ,(format-inputs package-inputs)))))))
-(define %cran-url "http://cran.r-project.org/web/packages/")
+(define %cran-url "https://cran.r-project.org/web/packages/")
(define %bioconductor-url "https://bioconductor.org/packages/")
;; The latest Bioconductor release is 3.8. Bioconductor packages should be
@@ -161,6 +161,12 @@ bioconductor package NAME, or #F if the package is unknown."
(bioconductor-packages-list))
(cut assoc-ref <> "Version")))
+;; Little helper to download URLs only once.
+(define download
+ (memoize
+ (lambda (url)
+ (with-store store (download-to-store store url)))))
+
(define (fetch-description repository name)
"Return an alist of the contents of the DESCRIPTION file for the R package
NAME in the given REPOSITORY, or #f in case of failure. NAME is
@@ -183,7 +189,7 @@ from ~s: ~a (~s)~%"
;; download the source tarball, and then extract the DESCRIPTION file.
(and-let* ((version (latest-bioconductor-package-version name))
(url (car (bioconductor-uri name version)))
- (tarball (with-store store (download-to-store store url))))
+ (tarball (download url)))
(call-with-temporary-directory
(lambda (dir)
(parameterize ((current-error-port (%make-void-port "rw+"))
@@ -299,7 +305,7 @@ from the alist META, which was derived from the R package's DESCRIPTION file."
((url rest ...) url)
((? string? url) url)
(_ #f)))
- (tarball (with-store store (download-to-store store source-url)))
+ (tarball (download source-url))
(sysdepends (append
(if (needs-zlib? tarball) '("zlib") '())
(map string-downcase (listify meta "SystemRequirements"))))
@@ -352,9 +358,10 @@ s-expression corresponding to that package, or #f on failure."
(eq? repo 'bioconductor))
;; Retry import from CRAN
(cran->guix-package package-name 'cran)
- (description->package repo description))))))
+ (and description
+ (description->package repo description)))))))
-(define* (cran-recursive-import package-name #:optional (repo 'gnu))
+(define* (cran-recursive-import package-name #:optional (repo 'cran))
(recursive-import package-name repo
#:repo->guix-package cran->guix-package
#:guix-name cran-guix-name))
diff --git a/guix/import/github.scm b/guix/import/github.scm
index af9f56e1dc..ad662e7b02 100644
--- a/guix/import/github.scm
+++ b/guix/import/github.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,6 +25,7 @@
#:use-module (srfi srfi-34)
#:use-module (guix utils)
#:use-module ((guix download) #:prefix download:)
+ #:use-module ((guix git-download) #:prefix download:)
#:use-module (guix import utils)
#:use-module (guix import json)
#:use-module (guix packages)
@@ -52,6 +54,7 @@ false if none is recognized"
(github-user-slash-repository url)))
(repo (github-repository url)))
(cond
+ ((string-suffix? ".git" url) url)
((string-suffix? (string-append "/tarball/v" version) url)
(string-append prefix "/tarball/v" new-version))
((string-suffix? (string-append "/tarball/" version) url)
@@ -86,26 +89,29 @@ false if none is recognized"
(#t #f))) ; Some URLs are not recognised.
#f))
- (let ((source-url (and=> (package-source old-package) origin-uri))
+ (let ((source-uri (and=> (package-source old-package) origin-uri))
(fetch-method (and=> (package-source old-package) origin-method)))
- (if (eq? fetch-method download:url-fetch)
- (match source-url
- ((? string?)
- (updated-url source-url))
- ((source-url ...)
- (find updated-url source-url)))
- #f)))
+ (cond
+ ((eq? fetch-method download:url-fetch)
+ (match source-uri
+ ((? string?)
+ (updated-url source-uri))
+ ((source-uri ...)
+ (find updated-url source-uri))))
+ ((eq? fetch-method download:git-fetch)
+ (updated-url (download:git-reference-url source-uri)))
+ (else #f))))
(define (github-package? package)
"Return true if PACKAGE is a package from GitHub, else false."
- (not (eq? #f (updated-github-url package "dummy"))))
+ (->bool (updated-github-url package "dummy")))
(define (github-repository url)
"Return a string e.g. bedtools2 of the name of the repository, from a string
URL of the form 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz'"
(match (string-split (uri-path (string->uri url)) #\/)
((_ owner project . rest)
- (string-append project))))
+ (string-append (basename project ".git")))))
(define (github-user-slash-repository url)
"Return a string e.g. arq5x/bedtools2 of the owner and the name of the
@@ -113,7 +119,7 @@ repository separated by a forward slash, from a string URL of the form
'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz'"
(match (string-split (uri-path (string->uri url)) #\/)
((_ owner project . rest)
- (string-append owner "/" project))))
+ (string-append owner "/" (basename project ".git")))))
(define %github-token
;; Token to be passed to Github.com to avoid the 60-request per hour
@@ -213,6 +219,8 @@ https://github.com/settings/tokens"))
(match (origin-uri origin)
((? string? url)
url) ;surely a github.com URL
+ ((? download:git-reference? ref)
+ (download:git-reference-url ref))
((urls ...)
(find (cut string-contains <> "github.com") urls))))
diff --git a/guix/import/opam.scm b/guix/import/opam.scm
index c42a5d767d..c254db5f2c 100644
--- a/guix/import/opam.scm
+++ b/guix/import/opam.scm
@@ -27,16 +27,23 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-2)
#:use-module (web uri)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system ocaml)
#:use-module (guix http-client)
#:use-module (guix git)
#:use-module (guix ui)
+ #:use-module (guix packages)
+ #:use-module (guix upstream)
#:use-module (guix utils)
#:use-module (guix import utils)
#:use-module ((guix licenses) #:prefix license:)
- #:export (opam->guix-package))
+ #:export (opam->guix-package
+ opam-recursive-import
+ %opam-updater))
;; Define a PEG parser for the opam format
-(define-peg-pattern SP none (or " " "\n"))
+(define-peg-pattern comment none (and "#" (* STRCHR) "\n"))
+(define-peg-pattern SP none (or " " "\n" comment))
(define-peg-pattern SP2 body (or " " "\n"))
(define-peg-pattern QUOTE none "\"")
(define-peg-pattern QUOTE2 body "\"")
@@ -128,7 +135,6 @@ path to the repository."
(else (string-append "ocaml-" name))))
(define (metadata-ref file lookup)
- (pk 'file file 'lookup lookup)
(fold (lambda (record acc)
(match record
((record key val)
@@ -166,6 +172,21 @@ path to the repository."
(('conditional-value val condition)
(if (native? condition) (dependency->input val) ""))))
+(define (dependency->name dependency)
+ (match dependency
+ (('string-pat str) str)
+ (('conditional-value val condition)
+ (dependency->name val))))
+
+(define (dependency-list->names lst)
+ (filter
+ (lambda (name)
+ (not (or
+ (string-prefix? "conf-" name)
+ (equal? name "ocaml")
+ (equal? name "findlib"))))
+ (map dependency->name lst)))
+
(define (ocaml-names->guix-names names)
(map ocaml-name->guix-name
(remove (lambda (name)
@@ -190,35 +211,88 @@ path to the repository."
(list dependency (list 'unquote (string->symbol dependency))))
(ocaml-names->guix-names lst)))
-(define (opam->guix-package name)
+(define (opam-fetch name)
(and-let* ((repository (get-opam-repository))
(version (find-latest-version name repository))
- (file (string-append repository "/packages/" name "/" name "." (pk 'version version) "/opam"))
- (opam-content (get-metadata file))
- (url-dict (metadata-ref (pk 'metadata opam-content) "url"))
+ (file (string-append repository "/packages/" name "/" name "." version "/opam")))
+ `(("metadata" ,@(get-metadata file))
+ ("version" . ,version))))
+
+(define (opam->guix-package name)
+ (and-let* ((opam-file (opam-fetch name))
+ (version (assoc-ref opam-file "version"))
+ (opam-content (assoc-ref opam-file "metadata"))
+ (url-dict (metadata-ref opam-content "url"))
(source-url (metadata-ref url-dict "src"))
(requirements (metadata-ref opam-content "depends"))
+ (dependencies (dependency-list->names requirements))
(inputs (dependency-list->inputs (depends->inputs requirements)))
(native-inputs (dependency-list->inputs (depends->native-inputs requirements))))
(call-with-temporary-output-file
(lambda (temp port)
(and (url-fetch source-url temp)
- `(package
- (name ,(ocaml-name->guix-name name))
- (version ,(metadata-ref opam-content "version"))
- (source
- (origin
- (method url-fetch)
- (uri ,source-url)
- (sha256 (base32 ,(guix-hash-url temp)))))
- (build-system ocaml-build-system)
- ,@(if (null? inputs)
- '()
- `((inputs ,(list 'quasiquote inputs))))
- ,@(if (null? native-inputs)
- '()
- `((native-inputs ,(list 'quasiquote native-inputs))))
- (home-page ,(metadata-ref opam-content "homepage"))
- (synopsis ,(metadata-ref opam-content "synopsis"))
- (description ,(metadata-ref opam-content "description"))
- (license #f)))))))
+ (values
+ `(package
+ (name ,(ocaml-name->guix-name name))
+ (version ,version)
+ (source
+ (origin
+ (method url-fetch)
+ (uri ,source-url)
+ (sha256 (base32 ,(guix-hash-url temp)))))
+ (build-system ocaml-build-system)
+ ,@(if (null? inputs)
+ '()
+ `((inputs ,(list 'quasiquote inputs))))
+ ,@(if (null? native-inputs)
+ '()
+ `((native-inputs ,(list 'quasiquote native-inputs))))
+ (home-page ,(metadata-ref opam-content "homepage"))
+ (synopsis ,(metadata-ref opam-content "synopsis"))
+ (description ,(metadata-ref opam-content "description"))
+ (license #f))
+ dependencies))))))
+
+(define (opam-recursive-import package-name)
+ (recursive-import package-name #f
+ #:repo->guix-package (lambda (name repo)
+ (opam->guix-package name))
+ #:guix-name ocaml-name->guix-name))
+
+(define (guix-package->opam-name package)
+ "Given an OCaml PACKAGE built from OPAM, return the name of the
+package in OPAM."
+ (let ((upstream-name (assoc-ref
+ (package-properties package)
+ 'upstream-name))
+ (name (package-name package)))
+ (cond
+ (upstream-name upstream-name)
+ ((string-prefix? "ocaml-" name) (substring name 6))
+ (else name))))
+
+(define (opam-package? package)
+ "Return true if PACKAGE is an OCaml package from OPAM"
+ (and
+ (equal? (build-system-name (package-build-system package)) 'ocaml)
+ (not (string-prefix? "ocaml4" (package-name package)))))
+
+(define (latest-release package)
+ "Return an <upstream-source> for the latest release of PACKAGE."
+ (and-let* ((opam-name (guix-package->opam-name package))
+ (opam-file (opam-fetch opam-name))
+ (version (assoc-ref opam-file "version"))
+ (opam-content (assoc-ref opam-file "metadata"))
+ (url-dict (metadata-ref opam-content "url"))
+ (source-url (metadata-ref url-dict "src")))
+ (upstream-source
+ (package (package-name package))
+ (version version)
+ (urls (list source-url)))))
+
+(define %opam-updater
+ (upstream-updater
+ (name 'opam)
+ (description "Updater for OPAM packages")
+ (pred opam-package?)
+ (latest latest-release)))
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 0b7da3189e..564bdf0ced 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;;
;;; This file is part of GNU Guix.
@@ -788,13 +788,15 @@ package '~a' has no source~%")
((? file-like? obj)
(list (run-with-store store
(lower-object obj system
- #:target (assoc-ref opts 'target)))))
+ #:target (assoc-ref opts 'target))
+ #:system system)))
((? gexp? gexp)
(list (run-with-store store
(mbegin %store-monad
(set-guile-for-build (default-guile))
(gexp->derivation "gexp" gexp
- #:system system))))))
+ #:system system))
+ #:system system))))
(map (cut transform store <>)
(options->things-to-build opts))))))
diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm
index b549878742..2d249a213f 100644
--- a/guix/scripts/import/opam.scm
+++ b/guix/scripts/import/opam.scm
@@ -25,6 +25,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-37)
+ #:use-module (srfi srfi-41)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:export (guix-import-opam))
@@ -43,6 +44,8 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(display (G_ "
-h, --help display this help and exit"))
(display (G_ "
+ -r, --recursive import packages recursively"))
+ (display (G_ "
-V, --version display version information and exit"))
(newline)
(show-bug-report-information))
@@ -56,6 +59,9 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(option '(#\V "version") #f #f
(lambda args
(show-version-and-exit "guix import opam")))
+ (option '(#\r "recursive") #f #f
+ (lambda (opt name arg result)
+ (alist-cons 'recursive #t result)))
%standard-import-options))
@@ -81,11 +87,22 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(reverse opts))))
(match args
((package-name)
- (let ((sexp (opam->guix-package package-name)))
- (unless sexp
- (leave (G_ "failed to download meta-data for package '~a'~%")
- package-name))
- sexp))
+ (if (assoc-ref opts 'recursive)
+ ;; Recursive import
+ (map (match-lambda
+ ((and ('package ('name name) . rest) pkg)
+ `(define-public ,(string->symbol name)
+ ,pkg))
+ (_ #f))
+ (reverse
+ (stream->list
+ (opam-recursive-import package-name))))
+ ;; Single import
+ (let ((sexp (opam->guix-package package-name)))
+ (unless sexp
+ (leave (G_ "failed to download meta-data for package '~a'~%")
+ package-name))
+ sexp)))
(()
(leave (G_ "too few arguments~%")))
((many ...)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 2c1c7ec669..9acec48577 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -1,7 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org>
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015, 2016 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2016 Danny Milosavljevic <dannym+a@scratchpost.org>
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
@@ -595,7 +595,8 @@ from ~a")
'home-page)))))
(define %distro-directory
- (dirname (search-path %load-path "gnu.scm")))
+ (mlambda ()
+ (dirname (search-path %load-path "gnu.scm"))))
(define (check-patch-file-names package)
"Emit a warning if the patches requires by PACKAGE are badly named or if the
@@ -620,12 +621,12 @@ patch could not be found."
'patch-file-names))
;; Check whether we're reaching tar's maximum file name length.
- (let ((prefix (string-length %distro-directory))
+ (let ((prefix (string-length (%distro-directory)))
(margin (string-length "guix-0.13.0-10-123456789/"))
(max 99))
(for-each (match-lambda
((? string? patch)
- (when (> (+ margin (if (string-prefix? %distro-directory
+ (when (> (+ margin (if (string-prefix? (%distro-directory)
patch)
(- (string-length patch) prefix)
(string-length patch)))
@@ -1108,8 +1109,8 @@ or a list thereof")
(description "Suggest 'mirror://' URLs")
(check check-mirror-url))
(lint-checker
- (name 'github-uri)
- (description "Suggest GitHub URIs")
+ (name 'github-url)
+ (description "Suggest GitHub URLs")
(check check-github-url))
(lint-checker
(name 'source-file-name)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 862556d12b..e7ff44c0d5 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -89,6 +89,8 @@ Download and deploy the latest version of Guix.\n"))
(display (G_ "
-n, --dry-run show what would be pulled and built"))
(display (G_ "
+ -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
+ (display (G_ "
--bootstrap use the bootstrap Guile to build the new Guix"))
(newline)
(show-build-options-help)
diff --git a/guix/self.scm b/guix/self.scm
index f2db3dbf52..e9a768bc90 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -133,6 +133,30 @@ GUILE-VERSION (\"2.0\" or \"2.2\"), or #f if none of the packages matches."
#:name (file-mapping-name mapping)
#:system system))
+(define (node-source+compiled node)
+ "Return a \"bundle\" containing both the source code and object files for
+NODE's modules, under their FHS directories: share/guile/site and lib/guile."
+ (define build
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ (define source
+ (string-append #$output "/share/guile/site/"
+ (effective-version)))
+
+ (define object
+ (string-append #$output "/lib/guile/" (effective-version)
+ "/site-ccache"))
+
+ (mkdir-p (dirname source))
+ (symlink #$(node-source node) source)
+ (mkdir-p (dirname object))
+ (symlink #$(node-compiled node) object))))
+
+ (computed-file (string-append (node-name node) "-modules")
+ build))
+
(define (node-fold proc init nodes)
(let loop ((nodes nodes)
(visited (setq))
@@ -360,40 +384,64 @@ DOMAIN, a gettext domain."
(basename texi ".texi")
".info")))
(cons "guix.texi"
- (find-files "." "^guix\\.[a-z]{2}\\.texi$"))))))
+ (find-files "." "^guix\\.[a-z]{2}\\.texi$")))
+
+ ;; Compress Info files.
+ (setenv "PATH"
+ #+(file-append (specification->package "gzip") "/bin"))
+ (for-each (lambda (file)
+ (invoke "gzip" "-9n" file))
+ (find-files #$output "\\.info(-[0-9]+)?$")))))
(computed-file "guix-manual" build))
-(define* (guix-command modules #:optional compiled-modules
+(define* (guile-module-union things #:key (name "guix-module-union"))
+ "Return the union of the subset of THINGS (packages, computed files, etc.)
+that provide Guile modules."
+ (define build
+ (with-imported-modules '((guix build union))
+ #~(begin
+ (use-modules (guix build union))
+
+ (define (modules directory)
+ (string-append directory "/share/guile/site"))
+
+ (define (objects directory)
+ (string-append directory "/lib/guile"))
+
+ (union-build #$output
+ (filter (lambda (directory)
+ (or (file-exists? (modules directory))
+ (file-exists? (objects directory))))
+ '#$things)
+
+ #:log-port (%make-void-port "w")))))
+
+ (computed-file name build))
+
+(define* (guix-command modules
#:key source (dependencies '())
guile (guile-version (effective-version)))
"Return the 'guix' command such that it adds MODULES and DEPENDENCIES in its
load path."
- (define source-directories
- (map (lambda (package)
- (file-append package "/share/guile/site/"
- guile-version))
- dependencies))
-
- (define object-directories
- (map (lambda (package)
- (file-append package "/lib/guile/"
- guile-version "/site-ccache"))
- dependencies))
+ (define module-directory
+ ;; To minimize the number of 'stat' calls needed to locate a module,
+ ;; create the union of all the module directories.
+ (guile-module-union (cons modules dependencies)))
(program-file "guix-command"
#~(begin
(set! %load-path
- (append (filter file-exists? '#$source-directories)
- %load-path))
-
- (set! %load-compiled-path
- (append (filter file-exists? '#$object-directories)
- %load-compiled-path))
+ (cons (string-append #$module-directory
+ "/share/guile/site/"
+ (effective-version))
+ %load-path))
- (set! %load-path (cons #$modules %load-path))
(set! %load-compiled-path
- (cons (or #$compiled-modules #$modules)
+ (cons (string-append #$module-directory
+ "/lib/guile/"
+ (effective-version)
+ "/site-ccache")
%load-compiled-path))
(let ((guix-main (module-ref (resolve-interface '(guix ui))
@@ -436,7 +484,6 @@ load path."
(define* (whole-package name modules dependencies
#:key
(guile-version (effective-version))
- compiled-modules
info daemon miscellany
guile
(command (guix-command modules
@@ -444,10 +491,9 @@ load path."
#:guile guile
#:guile-version guile-version)))
"Return the whole Guix package NAME that uses MODULES, a derivation of all
-the modules, and DEPENDENCIES, a list of packages depended on. COMMAND is the
-'guix' program to use; INFO is the Info manual. When COMPILED-MODULES is
-true, it is linked as 'lib/guile/X.Y/site-ccache'; otherwise, .go files are
-assumed to be part of MODULES."
+the modules (under share/guile/site and lib/guile), and DEPENDENCIES, a list
+of packages depended on. COMMAND is the 'guix' program to use; INFO is the
+Info manual."
(computed-file name
(with-imported-modules '((guix build utils))
#~(begin
@@ -461,28 +507,22 @@ assumed to be part of MODULES."
(symlink (string-append #$daemon "/bin/guix-daemon")
(string-append #$output "/bin/guix-daemon")))
- (let ((modules (string-append #$output
- "/share/guile/site/"
- (effective-version)))
- (info #$info))
- (mkdir-p (dirname modules))
- (symlink #$modules modules)
+ (let ((share (string-append #$output "/share"))
+ (lib (string-append #$output "/lib"))
+ (info #$info))
+ (mkdir-p share)
+ (symlink #$(file-append modules "/share/guile")
+ (string-append share "/guile"))
(when info
- (symlink #$info
- (string-append #$output
- "/share/info"))))
+ (symlink #$info (string-append share "/info")))
+
+ (mkdir-p lib)
+ (symlink #$(file-append modules "/lib/guile")
+ (string-append lib "/guile")))
(when #$miscellany
(copy-recursively #$miscellany #$output
- #:log (%make-void-port "w")))
-
- ;; Object files.
- (when #$compiled-modules
- (let ((modules (string-append #$output "/lib/guile/"
- (effective-version)
- "/site-ccache")))
- (mkdir-p (dirname modules))
- (symlink #$compiled-modules modules)))))))
+ #:log (%make-void-port "w")))))))
(define* (compiled-guix source #:key (version %guix-version)
(pull-version 1)
@@ -624,7 +664,8 @@ assumed to be part of MODULES."
(define *cli-modules*
(scheme-node "guix-cli"
- (scheme-modules* source "/guix/scripts")
+ (append (scheme-modules* source "/guix/scripts")
+ `((gnu ci)))
(list *core-modules* *extra-modules*
*core-package-modules* *package-modules*
*system-modules*)
@@ -680,15 +721,13 @@ assumed to be part of MODULES."
;; Version 1 is when we return the full package.
(cond ((= 1 pull-version)
;; The whole package, with a standard file hierarchy.
- (let* ((modules (built-modules (compose list node-source)))
- (compiled (built-modules (compose list node-compiled)))
- (command (guix-command modules compiled
+ (let* ((modules (built-modules (compose list node-source+compiled)))
+ (command (guix-command modules
#:source source
#:dependencies dependencies
#:guile guile-for-build
#:guile-version guile-version)))
(whole-package name modules dependencies
- #:compiled-modules compiled
#:command command
#:guile guile-for-build
diff --git a/guix/ui.scm b/guix/ui.scm
index 44336ee8fd..4c31246920 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
@@ -466,7 +466,7 @@ See the \"Application Setup\" section in the manual, for more info.\n")))))
"Display version information for COMMAND and `(exit 0)'."
(simple-format #t "~a (~a) ~a~%"
command %guix-package-name %guix-version)
- (format #t "Copyright ~a 2018 ~a"
+ (format #t "Copyright ~a 2019 ~a"
;; TRANSLATORS: Translate "(C)" to the copyright symbol
;; (C-in-a-circle), if this symbol is available in the user's
;; locale. Otherwise, do not translate "(C)"; leave it as-is. */