pull: Catch '&missing-dependency-error' raised by 'source-module-closure'.

Fixes <http://bugs.gnu.org/26987>.
Reported by Mathieu Othacehe <m.othacehe@gmail.com>.

* guix/build/pull.scm (depends-on-guile-ssh?): Remove.
(has-all-its-dependencies?): New procedure.
(build-guix): Use it to filter source files.
This commit is contained in:
Ludovic Courtès 2017-05-25 14:21:04 +02:00
parent bfe5264aa1
commit 20ed093977
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -28,6 +28,7 @@ (define-module (guix build pull)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-11) #:use-module (srfi srfi-11)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:export (build-guix)) #:export (build-guix))
;;; Commentary: ;;; Commentary:
@ -36,13 +37,18 @@ (define-module (guix build pull)
;;; ;;;
;;; Code: ;;; Code:
(define (depends-on-guile-ssh? file) (define (has-all-its-dependencies? file)
"Return true if FILE is a Scheme source file that depends, directly or "Return true if the dependencies of the module defined in FILE are
indirectly, on Guile-SSH." available, false otherwise."
(find (match-lambda (let ((module (call-with-input-file file
(('ssh _ ...) #t) (lambda (port)
(_ #f)) (match (read port)
(source-module-closure file #:select? (const #t)))) (('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) (define (all-scheme-files directory)
"Return a sorted list of Scheme files found in DIRECTORY." "Return a sorted list of Scheme files found in DIRECTORY."
@ -145,10 +151,7 @@ (define* (build-guix out source
;; Compile the .scm files. Load all the files before compiling them to ;; Compile the .scm files. Load all the files before compiling them to
;; work around <http://bugs.gnu.org/15602> (FIXME). ;; work around <http://bugs.gnu.org/15602> (FIXME).
;; Filter out files depending on Guile-SSH when Guile-SSH is missing. ;; Filter out files depending on Guile-SSH when Guile-SSH is missing.
(let* ((files (remove (if (false-if-exception (let* ((files (filter has-all-its-dependencies?
(resolve-interface '(ssh session)))
(const #f)
depends-on-guile-ssh?)
(all-scheme-files out))) (all-scheme-files out)))
(total (length files))) (total (length files)))
(let loop ((files files) (let loop ((files files)