From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KOuvAGyhxGACBwAAgWs5BA (envelope-from ) for ; Sat, 12 Jun 2021 13:58:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id g/rTN2uhxGDlMgAA1q6Kng (envelope-from ) for ; Sat, 12 Jun 2021 11:58:35 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8739B19F77 for ; Sat, 12 Jun 2021 13:58:35 +0200 (CEST) Received: from localhost ([::1]:55438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ls2Ha-0006Cv-Kj for larch@yhetil.org; Sat, 12 Jun 2021 07:58:34 -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 Content-Type: text/plain 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1623499115; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=IfD4n4Um+iXCIv1dPSwmCslTZoHPaHp6G6sKck54dN8=; b=Wygt8FRaLQasruMSm3yzgcgHR8NechUK+R+XPEVylHYq9qWqZZ1UAUv0FJWS8znniG/mho RI3B1q0BXngU5ZGus3GCsM7CjYL4Uc0ZTI65gpJHxHh1iQJ8fE2KONLczI/Q7yOPdJaqrI b8tSQ7y4SlJcWYalYbtkF9GC+FhouQ4A3aqb/LSsr1Ib+R3KwAz7eRgPs8YxxyW0Jbp1uJ t5Hepc/wk1kl4xqaJPrB1gZg3saKOMbWqkGq+EAUB+zniV5WfWP5pA+VTs/dsf6sox3bLg VKW0V8x+UqTW9qynI45m0BYBc66suM3nAy4TsV7ixmDSpiGmnwtbyNRDMIhCmQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623499115; a=rsa-sha256; cv=none; b=okTVQVIWzHjuVohznlg9yArtOiAIpVTQcMECnoevJ4xh9Q+pGYa8o8PESR43E1ThWVrh4d eXa/mPJUEw1u4qQEACHz7wVbxhOKOfuD6MmI+G3DLDPUFgPHQo52RwkUshiyZCCGj1ooIx kzSHGsZj7chx5bkaX+xHM89M7Wk84aPyJ0CezjsNaRIZLQ3fDnK5E9Quh9NazT42JMlvh/ /hvNLXheRV86WdZJWXm5abeKiTpTVHbosaUpDf5GSao9L3yPKJoYCc2YiCf0gOWDNaSUk3 1avWBrWOpVvSNsxPHNiUW6QCqLclQSnH1ymZX4fnHn/oH5xxkvRJn6QZTvJRfw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=pMiCghv1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=pMiCghv1; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 8739B19F77 X-Spam-Score: -0.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: eJueW0xskPZP * 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 -- 2.32.0