From 8b888de4cff44b42b8215afac5dcdadba9b7394d Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 15 Feb 2023 16:31:20 +0000 Subject: Handle self references when doing checks on narinfo imports --- scripts/nar-herder.in | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 9e70b77..c8726b8 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -51,6 +51,7 @@ (fibers conditions) (fibers web server) ((guix ui) #:select (read/eval string->duration)) + (guix store) (guix progress) (guix narinfo) (guix derivations) @@ -321,16 +322,23 @@ "https://narherderdummyvalue"))))) (when (assq-ref opts 'ensure-references-exist) - (for-each - (lambda (reference) - (unless (database-select-narinfo-by-hash - database - (string-take reference 32)) - (error - (simple-format (current-error-port) - "missing reference to ~A\n" - reference)))) - (narinfo-references narinfo))) + (let ((self-reference + (store-path-base + (narinfo-path narinfo)))) + (for-each + (lambda (reference) + (when (and + (not + (string=? reference self-reference)) + (not + (database-select-narinfo-by-hash + database + (string-take reference 32)))) + (error + (simple-format (current-error-port) + "missing reference to ~A\n" + reference)))) + (narinfo-references narinfo)))) (database-insert-narinfo database -- cgit v1.2.3