aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-02-06 22:38:33 +0100
committerChristopher Baines <mail@cbaines.net>2023-02-06 22:38:33 +0100
commit8f7b2b24e36b306d543670b6a4d3310e5be2f944 (patch)
tree654f42df797091a8093733d4e9624d4cf7975921 /scripts
parent4d549499dc5d70944d3c350de5ea424f7a357ff2 (diff)
downloadnar-herder-8f7b2b24e36b306d543670b6a4d3310e5be2f944.tar
nar-herder-8f7b2b24e36b306d543670b6a4d3310e5be2f944.tar.gz
Add a flag to allow ensuring the references for a nar are present
Diffstat (limited to 'scripts')
-rw-r--r--scripts/nar-herder.in18
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in
index 2f4d6d1..32b467d 100644
--- a/scripts/nar-herder.in
+++ b/scripts/nar-herder.in
@@ -114,7 +114,10 @@
(cons key value)))
(or (assq-ref result 'tags)
'()))
- (alist-delete 'tags result))))))
+ (alist-delete 'tags result))))
+ (option '("ensure-references-exist") #f #f
+ (lambda (opt name _ result)
+ (alist-cons 'ensure-references-exist #t result)))))
(define %import-options-defaults
'())
@@ -316,6 +319,19 @@
;; matter
(read-narinfo port
"https://narherderdummyvalue")))))
+
+ (when (assq-ref opts 'ensure-references-exist)
+ (for-each
+ (lambda (reference)
+ (unless (database-select-narinfo-by-hash
+ database
+ (string-take (basename narinfo-file) 32))
+ (error
+ (simple-format (current-error-port)
+ "missing reference to ~A\n"
+ reference))))
+ (narinfo-references narinfo)))
+
(database-insert-narinfo
database
narinfo