Message ID | 20201029231000.14568-1-ludo@gnu.org |
---|---|
State | Accepted |
Headers | show |
Series | Adding a (guix transformations) module | expand |
Context | Check | Description |
---|---|---|
cbaines/submitting builds | success | |
cbaines/issue | success | View issue |
cbaines/comparison | success | View comparision |
cbaines/git branch | success | View Git branch |
cbaines/applying patch | success | View Laminar job |
Hi Ludo, I've had to re-read some parts of the manual and the code of (guix store) a bit to completely understand this one, so thank you for the practical lesson too. :-) To be sure that I understood it: the main difference is that now package-with-source _stages_ (wink) the source download up to the gexp compilation, isn't it? If that's the case, this LGTM and my quick tests. Happy hacking, Miguel Ludovic Courtès <ludo@gnu.org> writes: > * guix/scripts/build.scm (<downloaded-file>): New record type. > (download-to-store*): New variable. > (compile-downloaded-file): New procedure. > (package-with-source): Remove 'store' parameter. Use 'downloaded-file' > instead of 'download-to-store'. > (transform-package-source): Adjust accordingly. > --- > guix/scripts/build.scm | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) > > diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm > index f4a8af035b..831ac8f798 100644 > --- a/guix/scripts/build.scm > +++ b/guix/scripts/build.scm > @@ -45,6 +45,7 @@ > #:use-module (ice-9 match) > #:use-module (ice-9 vlist) > #:use-module (srfi srfi-1) > + #:use-module (srfi srfi-9) > #:use-module (srfi srfi-11) > #:use-module (srfi srfi-26) > #:use-module (srfi srfi-34) > @@ -172,7 +173,25 @@ extensions." > (else > file-name))) > > -(define* (package-with-source store p uri #:optional version) > + > +;; Files to be downloaded. > +(define-record-type <downloaded-file> > + (downloaded-file uri recursive?) > + downloaded-file? > + (uri downloaded-file-uri) > + (recursive? downloaded-file-recursive?)) > + > +(define download-to-store* > + (store-lift download-to-store)) > + > +(define-gexp-compiler (compile-downloaded-file (file <downloaded-file>) > + system target) > + "Download FILE and return the result as a store item." > + (match file > + (($ <downloaded-file> uri recursive?) > + (download-to-store* uri #:recursive? recursive?)))) > + > +(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)))) > @@ -183,8 +202,7 @@ the new package's version number from URI." > (package-version p))) > > ;; Use #:recursive? #t to allow for directories. > - (source (download-to-store store uri > - #:recursive? #t)) > + (source (downloaded-file uri #t)) > > ;; Override the replacement, otherwise '--with-source' would > ;; have no effect. > @@ -226,7 +244,7 @@ matching URIs given in SOURCES." > ((? package? p) > (match (assoc-ref sources (package-name p)) > ((version source) > - (package-with-source store p source version)) > + (package-with-source p source version)) > (#f > p))) > (_
Miguel Ángel Arruga Vivas <rosen644835@gmail.com> skribis: > I've had to re-read some parts of the manual and the code of (guix > store) a bit to completely understand this one, so thank you for the > practical lesson too. :-) Heheh. :-) > To be sure that I understood it: the main difference is that now > package-with-source _stages_ (wink) the source download up to the gexp > compilation, isn't it? If that's the case, this LGTM and my quick > tests. Yes, exactly. Now ‘package-with-source’ inserts an “inert” <downloaded-file> record as the source of the package. The file is actually downloaded when that <downloaded-file> object is “lowered”, which happens when the package itself is lowered to a derivation. Thanks for the review! Ludo’.
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index f4a8af035b..831ac8f798 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -45,6 +45,7 @@ #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -172,7 +173,25 @@ extensions." (else file-name))) -(define* (package-with-source store p uri #:optional version) + +;; Files to be downloaded. +(define-record-type <downloaded-file> + (downloaded-file uri recursive?) + downloaded-file? + (uri downloaded-file-uri) + (recursive? downloaded-file-recursive?)) + +(define download-to-store* + (store-lift download-to-store)) + +(define-gexp-compiler (compile-downloaded-file (file <downloaded-file>) + system target) + "Download FILE and return the result as a store item." + (match file + (($ <downloaded-file> uri recursive?) + (download-to-store* uri #:recursive? recursive?)))) + +(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)))) @@ -183,8 +202,7 @@ the new package's version number from URI." (package-version p))) ;; Use #:recursive? #t to allow for directories. - (source (download-to-store store uri - #:recursive? #t)) + (source (downloaded-file uri #t)) ;; Override the replacement, otherwise '--with-source' would ;; have no effect. @@ -226,7 +244,7 @@ matching URIs given in SOURCES." ((? package? p) (match (assoc-ref sources (package-name p)) ((version source) - (package-with-source store p source version)) + (package-with-source p source version)) (#f p))) (_