Channel clones lack SWH fallback

OpenSubmitted by zimoun.
Details
2 participants
  • Ludovic Courtès
  • zimoun
Owner
unassigned
Severity
important
Z
Z
zimoun wrote on 24 Oct 2020 00:17
whishlist: time-machine --channel falls back to SWH
(address . bug-guix@gnu.org)
86pn581t9s.fsf@gmail.com
Dear,
Let’s describe the use case. Consider that:
guix time-machine -C channels -- install foo
is provided in some documentation, say scientific paper. Where thechannels.scm file is completly described:
Toggle snippet (7 lines)(list (channel (name 'kikoo) (url "https://example.org/that-great.git") (commit "353bdae32f72b720c7ddd706576ccc40e2b43f95")))
In the future, if https://example.org/that-great.gitdisappears, thenbuild/install the package ’foo’ is becoming difficult, nor impossible.
However, let’s consider that the repo ’that-great’ had been saved in SWH(say manually); since it is a regular Git repo. Guix should be able tofallback to it transparently.

Obviously, another whislist is to have something to ease the saverequest of the channel on SWH. Maybe this latter could be part of theseveral-times discussed “guix channel” subcommand. :-)

All the best,simon
L
L
Ludovic Courtès wrote on 5 Mar 15:14 +0100
control message for bug #44187
(address . control@debbugs.gnu.org)
878s71lmbq.fsf@gnu.org
severity 44187 importantquit
L
L
Ludovic Courtès wrote on 5 Mar 15:14 +0100
(address . control@debbugs.gnu.org)
877dmllmas.fsf@gnu.org
retitle 44187 Channel clones lack SWH fallbackquit
L
L
Ludovic Courtès wrote on 5 Mar 15:51 +0100
Re: bug#44187: whishlist: time-machine --channel falls back to SWH
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 44187@debbugs.gnu.org)
87pn0dk61v.fsf@gnu.org
Hi,
zimoun <zimon.toutoune@gmail.com> skribis:
Toggle quote (20 lines)> Let’s 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 ’foo’ is becoming difficult, nor impossible.>> However, let’s consider that the repo ’that-great’ 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 ‘latest-repository-commit’… butthat’s of no use because (guix channels) wants a complete clone so thatit can determine commit relations (to detect downgrades).
The SWH vault gives access to checkouts primarily, but it’s alsopossible to get a full repo in ‘git fast-import’ format, which is whatwe need:
https://archive.softwareheritage.org/api/1/vault/revision/gitfast/doc/
However, this API will be eventually replaced by some other solution saySWH developers, possibly a bare Git repo export, so it may not be a goodidea to build upon it.
If we were able, using the SWH API, to map “revisions” to “origins”, wecould find potential mirrors hosting a given commit, but apparentlythat’s not possible.
To be continued…
Ludo’.
Toggle diff (72 lines)diff --git a/guix/git.scm b/guix/git.scmindex 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
?