aboutsummaryrefslogtreecommitdiff
path: root/guix/upstream.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-01-07 10:00:50 +0100
committerLudovic Courtès <ludo@gnu.org>2021-01-19 17:45:39 +0100
commit9ab817b2a4601b4a6755983590ed7d93ebdc8d09 (patch)
tree15bab050a0fa6e6719a43aed8e08fbb85f022bf5 /guix/upstream.scm
parent30c164e3fda4b7585acc1beacc653645a8186552 (diff)
downloadguix-9ab817b2a4601b4a6755983590ed7d93ebdc8d09.tar
guix-9ab817b2a4601b4a6755983590ed7d93ebdc8d09.tar.gz
transformations: Add '--with-latest'.
* guix/upstream.scm (upstream-source-compiler): New procedure. (%updaters): Set! it. * guix/transformations.scm (transform-package-latest): New procedure. (%transformations): Add 'with-latest'. (%transformation-options, show-transformation-options-help/detailed): Add '--with-latest'. * tests/transformations.scm ("options->transformation, with-latest"): New test. * doc/guix.texi (Package Transformation Options): Document it.
Diffstat (limited to 'guix/upstream.scm')
-rw-r--r--guix/upstream.scm28
1 files changed, 26 insertions, 2 deletions
diff --git a/guix/upstream.scm b/guix/upstream.scm
index a8ed1d81cd..accd8967d8 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -31,8 +31,8 @@
#:use-module (guix base32)
#:use-module (guix gexp)
#:use-module (guix store)
- #:use-module ((guix derivations)
- #:select (built-derivations derivation->output-path))
+ #:use-module ((guix derivations) #:select (built-derivations derivation->output-path))
+ #:autoload (gcrypt hash) (port-sha256)
#:use-module (guix monads)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-9)
@@ -248,6 +248,9 @@ correspond to the same version."
'()
(importer-modules))))
+;; Tests need to mock this variable so mark it as "non-declarative".
+(set! %updaters %updaters)
+
(define* (lookup-updater package
#:optional (updaters (force %updaters)))
"Return an updater among UPDATERS that matches PACKAGE, or #f if none of
@@ -351,6 +354,27 @@ values: 'interactive' (default), 'always', and 'never'."
data url)
#f)))))))
+(define-gexp-compiler (upstream-source-compiler (source <upstream-source>)
+ system target)
+ "Download SOURCE from its first URL and lower it as a fixed-output
+derivation that would fetch it."
+ (mlet* %store-monad ((url -> (first (upstream-source-urls source)))
+ (signature
+ -> (and=> (upstream-source-signature-urls source)
+ first))
+ (tarball ((store-lift download-tarball) url signature)))
+ (unless tarball
+ (raise (formatted-message (G_ "failed to fetch source from '~a'")
+ url)))
+
+ ;; Instead of returning TARBALL, return a fixed-output derivation that
+ ;; would be able to re-download it. In practice, since TARBALL is already
+ ;; in the store, no extra download will happen, but having the derivation
+ ;; in store improves provenance tracking.
+ (let ((hash (call-with-input-file tarball port-sha256)))
+ (url-fetch url 'sha256 hash (store-path-package-name tarball)
+ #:system system))))
+
(define (find2 pred lst1 lst2)
"Like 'find', but operate on items from both LST1 and LST2. Return two
values: the item from LST1 and the item from LST2 that match PRED."