From patchwork Sat Jun 12 11:57:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 30184 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B71CB27BC81; Sat, 12 Jun 2021 12:58:33 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 71EE427BC78 for ; Sat, 12 Jun 2021 12:58:33 +0100 (BST) Received: from localhost ([::1]:55438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ls2HY-0006Cv-7C for patchwork@mira.cbaines.net; Sat, 12 Jun 2021 07:58:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ls2H4-0006CM-Ec for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57140) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ls2H4-0006mB-6X for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ls2H4-00043G-6Q for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48971] [PATCH 2/2] hg-download: Support falling back to SWH. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 12 Jun 2021 11:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48971 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48971@debbugs.gnu.org Received: via spool by 48971-submit@debbugs.gnu.org id=B48971.162349905115522 (code B ref 48971); Sat, 12 Jun 2021 11:58:02 +0000 Received: (at 48971) by debbugs.gnu.org; 12 Jun 2021 11:57:31 +0000 Received: from localhost ([127.0.0.1]:40452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ls2GZ-00042I-65 for submit@debbugs.gnu.org; Sat, 12 Jun 2021 07:57:31 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:35588 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ls2GW-00041r-3N for 48971@debbugs.gnu.org; Sat, 12 Jun 2021 07:57:28 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1623499042; bh=YU8cp0av1oYsm74DHbY/+Vg/wwgpY9EcLCuzPE/apWk=; h=From:To:Subject:In-Reply-To:References:Date; b=pMiCghv1SKEKiV3Ab1+J1tPJSDMEw/rj8Z39Xn6MwYKqBwLCAdyYIn75s00/tmloG xVGwTVr9GoYbfeGzmafuq/rXv2fWLUe4loMpfDJnFqW9z8YnK0AJT5RNug+bGkBkEY ny5Hz446ggik/bQrBjxPbx7laebv2chFn3fSDkfM= In-Reply-To: References: Message-Id: <22034af85a90fb2138169465f80641b28c60fb37.1623498543.git.public@yoctocell.xyz> Date: Sat, 12 Jun 2021 13:57:22 +0200 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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 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