From: Xinglu Chen <public@yoctocell.xyz>
To: 48971@debbugs.gnu.org
Subject: [bug#48971] [PATCH 2/2] hg-download: Support falling back to SWH.
Date: Sat, 12 Jun 2021 13:57:22 +0200 [thread overview]
Message-ID: <22034af85a90fb2138169465f80641b28c60fb37.1623498543.git.public@yoctocell.xyz> (raw)
In-Reply-To: <cover.1623498543.git.public@yoctocell.xyz>
* guix/hg-download.scm (hg-fetch): Fall back to fetching the source from SWH
if the upstream source is missing.
---
guix/hg-download.scm | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/guix/hg-download.scm b/guix/hg-download.scm
index eb7c345489..c386d2f5f3 100644
--- a/guix/hg-download.scm
+++ b/guix/hg-download.scm
@@ -67,6 +67,13 @@
"Return a fixed-output derivation that fetches REF, a <hg-reference>
object. The output is expected to have recursive hash HASH of type
HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
+ (define inputs
+ ;; The 'swh-download' procedure requires tar and gzip.
+ `(("gzip" ,(module-ref (resolve-interface '(gnu packages compression))
+ 'gzip))
+ ("tar" ,(module-ref (resolve-interface '(gnu packages base))
+ 'tar))))
+
(define guile-zlib
(module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib))
@@ -79,7 +86,8 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
(define modules
(delete '(guix config)
(source-module-closure '((guix build hg)
- (guix build download-nar)))))
+ (guix build download-nar)
+ (guix swh)))))
(define build
(with-imported-modules modules
@@ -87,13 +95,30 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
guile-zlib)
#~(begin
(use-modules (guix build hg)
- (guix build download-nar))
+ (guix build utils) ;for `set-path-environment-variable'
+ (guix build download-nar)
+ (guix swh)
+ (ice-9 match))
+
+ (set-path-environment-variable "PATH" '("bin")
+ (match '#+inputs
+ (((names dirs outputs ...) ...)
+ dirs)))
(or (hg-fetch '#$(hg-reference-url ref)
'#$(hg-reference-changeset ref)
#$output
#:hg-command (string-append #+hg "/bin/hg"))
- (download-nar #$output))))))
+ (download-nar #$output)
+ ;; As a last resort, attempt to download from Software Heritage.
+ ;; Disable X.509 certificate verification to avoid depending
+ ;; on nss-certs--we're authenticating the checkout anyway.
+ (parameterize ((%verify-swh-certificate? #f))
+ (format (current-error-port)
+ "Trying to download from Software Heritage...~%")
+ (swh-download #$(hg-reference-url ref)
+ #$(hg-reference-changeset ref)
+ #$output)))))))
(mlet %store-monad ((guile (package->derivation guile system)))
(gexp->derivation (or name "hg-checkout") build
--
2.32.0
next prev parent reply other threads:[~2021-06-12 11:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 11:52 [bug#48971] [PATCH 0/2] Add SWH support for Hg repositories Xinglu Chen
2021-06-12 11:57 ` [bug#48971] [PATCH 1/2] swh: Support lookup of Hg tags Xinglu Chen
2021-06-12 11:57 ` Xinglu Chen [this message]
2021-06-14 16:44 ` [bug#48971] [PATCH 0/2] Add SWH support for Hg repositories Ludovic Courtès
2021-06-15 5:37 ` Xinglu Chen
2021-06-16 5:23 ` zimoun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22034af85a90fb2138169465f80641b28c60fb37.1623498543.git.public@yoctocell.xyz \
--to=public@yoctocell.xyz \
--cc=48971@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.