packages: 'expand-input' accepts any file-like object.

* guix/packages.scm (expand-input)[valid?]: Remove.
Call 'file-like?' instead of 'valid?'.  Remove 'struct?' clause.
* tests/packages.scm ("&package-input-error"): Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2021-03-07 14:40:03 +01:00
parent 83bdaf3150
commit e7477dd59b
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
2 changed files with 3 additions and 11 deletions

View File

@ -1213,13 +1213,10 @@ Return the cached result when available."
(define* (expand-input package input #:key native?)
"Expand INPUT, an input tuple, to a name/<gexp-input> tuple. PACKAGE is
only used to provide contextual information in exceptions."
(define (valid? x)
(or (package? x) (origin? x) (derivation? x)))
(match input
(((? string? name) (? valid? thing))
(((? string? name) (? file-like? thing))
(list name (gexp-input thing #:native? native?)))
(((? string? name) (? valid? thing) (? string? output))
(((? string? name) (? file-like? thing) (? string? output))
(list name (gexp-input thing output #:native? native?)))
(((? string? name)
(and (? string?) (? file-exists? file)))
@ -1228,11 +1225,6 @@ only used to provide contextual information in exceptions."
;; source.
(list name (gexp-input (local-file file #:recursive? #t)
#:native? native?)))
(((? string? name) (? struct? source))
;; 'package-source-derivation' calls 'lower-object', which can throw
;; '&gexp-input-error'. However '&gexp-input-error' lacks source
;; location info, so we used to catch and rethrow here (FIXME!).
(list name (gexp-input source)))
(x
(raise (condition (&package-input-error
(package package)

View File

@ -744,7 +744,7 @@
(let ((dummy (dummy-package "foo" (inputs `(("x" ,(current-module)))))))
(test-equal "&package-input-error"
(list dummy (current-module))
(list dummy `("x" ,(current-module)))
(guard (c ((package-input-error? c)
(list (package-error-package c)
(package-error-invalid-input c))))