From: "Ludovic Courtès" <ludo@gnu.org>
To: 48437@debbugs.gnu.org
Cc: "Timothy Sample" <samplet@ngyro.com>, "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#48437] [PATCH] lint: archival: Lookup content in Disarchive database.
Date: Sat, 15 May 2021 12:28:14 +0200 [thread overview]
Message-ID: <20210515102814.5944-1-ludo@gnu.org> (raw)
* guix/lint.scm (lookup-disarchive-spec): New procedure.
(check-archival): When 'lookup-content' returns #f, call
'lookup-disarchive-spec'.
* guix/download.scm (%disarchive-mirrors): Make public.
---
guix/download.scm | 1 +
guix/lint.scm | 31 +++++++++++++++++++++++++++----
2 files changed, 28 insertions(+), 4 deletions(-)
Hello!
This patch makes the ‘archival’ checker check the Disarchive database(s)
when SWH ‘lookup-content’ returns #f. For example, before the patch,
we get:
$ guix lint -c archival guile-json
gnu/packages/guile.scm:622:12: guile-json@4.5.2: source not archived on Software Heritage
After the patch, we get nothing (success) thanks to Disarchive metadata
available at:
https://disarchive.ngyro.com/sha256/1ab046ec36b1c44c041ac275568d818784d71fab9a5d95f9128cfe8a25051933
It assumes that the swhid found in the Disarchive metadata is valid, a
reasonable assumption IMO.
Thoughts?
Ludo’.
diff --git a/guix/download.scm b/guix/download.scm
index 72094e7318..b6eb97e6fa 100644
--- a/guix/download.scm
+++ b/guix/download.scm
@@ -35,6 +35,7 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:export (%mirrors
+ %disarchive-mirrors
(url-fetch* . url-fetch)
url-fetch/executable
url-fetch/tarbomb
diff --git a/guix/lint.scm b/guix/lint.scm
index 1bebfe03d3..c6ad54ddeb 100644
--- a/guix/lint.scm
+++ b/guix/lint.scm
@@ -30,6 +30,7 @@
(define-module (guix lint)
#:use-module (guix store)
+ #:autoload (guix base16) (bytevector->base16-string)
#:use-module (guix base32)
#:use-module (guix diagnostics)
#:use-module (guix download)
@@ -1227,6 +1228,23 @@ upstream releases")
#:field 'source)))))))
+(define (lookup-disarchive-spec hash)
+ "Return true if Disarchive mirrors have a spec for HASH, false otherwise."
+ (any (lambda (mirror)
+ (with-networking-fail-safe
+ (format #f (G_ "failed to access Disarchive database at ~a")
+ mirror)
+ #f
+ (let* ((url (string-append mirror
+ (symbol->string
+ (content-hash-algorithm hash))
+ "/"
+ (bytevector->base16-string
+ (content-hash-value hash))))
+ (response (http-head url)))
+ (= 200 (response-code response)))))
+ %disarchive-mirrors))
+
(define (check-archival package)
"Check whether PACKAGE's source code is archived on Software Heritage. If
it's not, and if its source code is a VCS snapshot, then send a \"save\"
@@ -1302,10 +1320,15 @@ try again later")
(symbol->string
(content-hash-algorithm hash)))
(#f
- (list (make-warning package
- (G_ "source not archived on Software \
-Heritage")
- #:field 'source)))
+ ;; If SWH doesn't have HASH as is, it may be because it's
+ ;; a hand-crafted tarball. In that case, check whether
+ ;; the Disarchive database has an entry for that tarball.
+ (if (lookup-disarchive-spec hash)
+ '()
+ (list (make-warning package
+ (G_ "source not archived on Software \
+Heritage and missing from the Disarchive database")
+ #:field 'source))))
((? content?)
'())))
'()))))
--
2.31.1
next reply other threads:[~2021-05-15 10:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-15 10:28 Ludovic Courtès [this message]
2021-05-18 3:19 ` [bug#48437] [PATCH] lint: archival: Lookup content in Disarchive database Timothy Sample
2021-05-18 21:47 ` Ludovic Courtès
2021-05-21 10:27 ` [bug#48437] [PATCH v2] " Ludovic Courtès
2021-05-22 21:52 ` bug#48437: [PATCH] " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210515102814.5944-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=48437@debbugs.gnu.org \
--cc=samplet@ngyro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).