From patchwork Sat Jun 12 11:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 30183 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 F0FD927BC81; Sat, 12 Jun 2021 12:58:32 +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 B757C27BC78 for ; Sat, 12 Jun 2021 12:58:32 +0100 (BST) Received: from localhost ([::1]:55436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ls2HX-0006Cd-RN for patchwork@mira.cbaines.net; Sat, 12 Jun 2021 07:58:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ls2H4-0006CK-5w for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ls2H3-0006m4-Po for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ls2H3-000439-QJ for guix-patches@gnu.org; Sat, 12 Jun 2021 07:58:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48971] [PATCH 1/2] swh: Support lookup of Hg tags. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 12 Jun 2021 11:58:01 +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.162349904915513 (code B ref 48971); Sat, 12 Jun 2021 11:58:01 +0000 Received: (at 48971) by debbugs.gnu.org; 12 Jun 2021 11:57:29 +0000 Received: from localhost ([127.0.0.1]:40450 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ls2GW-000429-TV for submit@debbugs.gnu.org; Sat, 12 Jun 2021 07:57:29 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:35578 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ls2GU-00041p-Ov for 48971@debbugs.gnu.org; Sat, 12 Jun 2021 07:57:27 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1623499040; bh=j9TwaveoX7r8U5DkeF2faZc327V+HOSv9Ev4TGbnfpk=; h=From:To:Subject:In-Reply-To:References:Date; b=d+iCYfPTHNvg1XuZbVJc9L+oHj8EEIsRksqA/Mb+GVKUmQaixBgngC3eFzJC+y12I +gke0Bnke3Igd7WWFnJCEw50cDeGIarPJ3OSVKNGDzFwkkdeoI97IYpMm1vWVwngqk fZ4Np2n3rTiKT4R4ctgIx4vX2TfD0KKFicSroigo= In-Reply-To: References: Message-Id: Date: Sat, 12 Jun 2021 13:57:19 +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/swh.scm (lookup-origin-revision): Support lookup of Hg tags, not just Git tags. --- I noticed that the ‘commit-id?’ procedure checks if REFERENCE is of length 40, this will result in false negatives because some packages that use ‘hg-fetch’ only specify the first ~10 or ~15 characters of the changeset revision. We should probably fix that. guix/swh.scm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/guix/swh.scm b/guix/swh.scm index f6d5241e06..b5c800011d 100644 --- a/guix/swh.scm +++ b/guix/swh.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2020 Jakub Kądziołka +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -455,8 +456,13 @@ URL could not be found." ((visit . _) (let ((snapshot (visit-snapshot visit))) (match (and=> (find (lambda (branch) - (string=? (string-append "refs/tags/" tag) - (branch-name branch))) + (or + ;; Git specific. + (string=? (string-append "refs/tags/" tag) + (branch-name branch)) + ;; Hg specific. + (string=? tag + (branch-name branch)))) (snapshot-branches snapshot)) branch-target) ((? release? release) 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