From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id kj+ID6JFQmBjawAA0tVLHw (envelope-from ) for ; Fri, 05 Mar 2021 14:52:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id EOnxCqJFQmAXWQAAB5/wlQ (envelope-from ) for ; Fri, 05 Mar 2021 14:52:18 +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 2568E27E8E for ; Fri, 5 Mar 2021 15:52:17 +0100 (CET) Received: from localhost ([::1]:52552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIBoN-0005oH-NZ for larch@yhetil.org; Fri, 05 Mar 2021 09:52:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIBoA-0005nd-T6 for bug-guix@gnu.org; Fri, 05 Mar 2021 09:52:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:50056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIBoA-0000Lz-Lj for bug-guix@gnu.org; Fri, 05 Mar 2021 09:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lIBoA-0002pC-JI for bug-guix@gnu.org; Fri, 05 Mar 2021 09:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#44187: whishlist: time-machine --channel falls back to SWH Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 Mar 2021 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44187 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: zimoun Received: via spool by 44187-submit@debbugs.gnu.org id=B44187.161495587710801 (code B ref 44187); Fri, 05 Mar 2021 14:52:02 +0000 Received: (at 44187) by debbugs.gnu.org; 5 Mar 2021 14:51:17 +0000 Received: from localhost ([127.0.0.1]:33369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIBnR-0002o9-Er for submit@debbugs.gnu.org; Fri, 05 Mar 2021 09:51:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lIBnQ-0002nx-Gl for 44187@debbugs.gnu.org; Fri, 05 Mar 2021 09:51:16 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:42584) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIBnL-0008Nv-7T; Fri, 05 Mar 2021 09:51:11 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41608 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lIBnK-0000fD-Df; Fri, 05 Mar 2021 09:51:10 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <86pn581t9s.fsf@gmail.com> Date: Fri, 05 Mar 2021 15:51:08 +0100 In-Reply-To: <86pn581t9s.fsf@gmail.com> (zimoun's message of "Sat, 24 Oct 2020 00:17:51 +0200") Message-ID: <87pn0dk61v.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 44187@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -2.86 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 2568E27E8E X-Spam-Score: -2.86 X-Migadu-Scanner: scn0.migadu.com X-TUID: 6Sy/tONmDu6v --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, zimoun skribis: > Let=E2=80=99s describe the use case. Consider that: > > guix time-machine -C channels -- install foo > > is provided in some documentation, say scientific paper. Where the > channels.scm file is completly described: > > (list (channel > (name 'kikoo) > (url "https://example.org/that-great.git") > (commit > "353bdae32f72b720c7ddd706576ccc40e2b43f95"))) > > In the future, if https://example.org/that-great.git disappears, then > build/install the package =E2=80=99foo=E2=80=99 is becoming difficult, no= r impossible. > > However, let=E2=80=99s consider that the repo =E2=80=99that-great=E2=80= =99 had been saved in SWH > (say manually); since it is a regular Git repo. Guix should be able to > fallback to it transparently. I went head-down to add SWH fallback to =E2=80=98latest-repository-commit= =E2=80=99=E2=80=A6 but that=E2=80=99s of no use because (guix channels) wants a complete clone so = that it can determine commit relations (to detect downgrades). The SWH vault gives access to checkouts primarily, but it=E2=80=99s also possible to get a full repo in =E2=80=98git fast-import=E2=80=99 format, wh= ich is what we need: https://archive.softwareheritage.org/api/1/vault/revision/gitfast/doc/ However, this API will be eventually replaced by some other solution say SWH developers, possibly a bare Git repo export, so it may not be a good idea to build upon it. If we were able, using the SWH API, to map =E2=80=9Crevisions=E2=80=9D to = =E2=80=9Corigins=E2=80=9D, we could find potential mirrors hosting a given commit, but apparently that=E2=80=99s not possible. To be continued=E2=80=A6 Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/guix/git.scm b/guix/git.scm index a5103547d3..449011c51a 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -32,6 +32,7 @@ #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix sets) + #:autoload (guix swh) (swh-download) #:use-module ((guix diagnostics) #:select (leave)) #:use-module (guix progress) #:use-module (rnrs bytevectors) @@ -459,22 +460,43 @@ Log progress and checkout info to LOG-PORT." (eq? 'regular (stat:type stat)))))) (format log-port "updating checkout of '~a'...~%" url) - (let*-values - (((checkout commit _) - (update-cached-checkout url - #:recursive? recursive? - #:ref ref - #:cache-directory - (url-cache-directory url cache-directory - #:recursive? - recursive?) - #:log-port log-port)) - ((name) - (url+commit->name url commit))) - (format log-port "retrieved commit ~a~%" commit) - (values (add-to-store store name #t "sha256" checkout - #:select? (negate dot-git?)) - commit))) + + (catch 'git-error + (lambda () + (let*-values + (((checkout commit _) + (update-cached-checkout (pk 'l-r-c url) + #:recursive? recursive? + #:ref ref + #:cache-directory + (url-cache-directory url cache-directory + #:recursive? + recursive?) + #:log-port log-port)) + ((name) + (url+commit->name url commit))) + (format log-port "retrieved commit ~a~%" commit) + (values (add-to-store store name #t "sha256" checkout + #:select? (negate dot-git?)) + commit))) + (lambda (key err . rest) + ;; XXX: 'swh-download' currently doesn't support submodules. + (when recursive? + (apply throw key err rest)) + + (pk 'err key err rest) + (match ref + (('commit . commit) + ;; Attempt to fetch COMMIT from SWH. + (call-with-temporary-directory + (lambda (directory) + (unless (swh-download url commit directory) + (apply throw key err rest)) + (values (add-to-store store (url+commit->name url commit) + #t "sha256" directory) + commit)))) + (_ + (apply throw key err rest)))))) (define (print-git-error port key args default-printer) (match args --=-=-=--