diff --git a/guix/transformations.scm b/guix/transformations.scm index 5ae1977cb2..e0f5579c28 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -46,6 +46,7 @@ #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 vlist) + #:autoload (web uri) (string->uri uri-scheme uri-path) #:export (options->transformation manifest-entry-with-transformations @@ -106,15 +107,25 @@ extensions." (define* (package-with-source p uri #:optional version) "Return a package based on P but with its source taken from URI. Extract the new package's version number from URI." - (let ((base (tarball-base-name (basename uri)))) + (let ((base (tarball-base-name (basename uri))) + (file (match (string->uri uri) + (#f uri) + (uri (and (eq? 'file (uri-scheme uri)) + (uri-path uri)))))) (let-values (((_ version*) (hyphen-package-name->name+version base))) (package (inherit p) (version (or version version* (package-version p))) - ;; Use #:recursive? #t to allow for directories. - (source (downloaded-file uri #t)))))) + ;; Default to #:recursive? #f to match what 'url-fetch' does, + ;; but use #t when URI denotes a directory. + (source (let ((recursive? + (and file + (match (stat file #f) + (#f #t) + (st (eq? 'directory (stat:type st))))))) + (downloaded-file uri recursive?))))))) ;;;