Subject: [PATCH maintenance] hydra: build-package-metadata: Update fields in sources.json.

From: Simon Tournier <[email-masked]>
Date: Fri, 12 May 2023 11:45:04 +0200

This format had been discussed in
<https://gitlab.softwareheritage.org/swh/infra/sysadm-environment/-/issues/4868>.

* hydra/build-package-metadata.scm (origin->json)[resolve]: Add the fields
'outputHashAlgo' and 'outputHashMode'.
---
 hydra/build-package-metadata.scm | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/hydra/build-package-metadata.scm b/hydra/build-package-metadata.scm
index 1ddb409..d110d4d 100755
--- a/hydra/build-package-metadata.scm
+++ b/hydra/build-package-metadata.scm
@@ -1,7 +1,7 @@
 #!/usr/bin/env -S guix repl --
 !#
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020, 2021 Simon Tournier <[email-masked]>
+;;; Copyright © 2020, 2021, 2023 Simon Tournier <[email-masked]>
 ;;; Copyright © 2023 Ludovic Courtès <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -160,13 +160,23 @@ superseded packages."
                  (else '()))
          ,@(if (or (eq? url-fetch method)
                    (eq? url-fetch/tarbomb method)
-                   (eq? url-fetch/zipbomb method))
+                   (eq? url-fetch/zipbomb method)
+                   (eq? git-fetch method)
+                   (eq? svn-fetch method)
+                   (eq? svn-multi-fetch method)
+                   (eq? hg-fetch method))
                (let* ((content-hash (origin-hash origin))
                       (hash-value (content-hash-value content-hash))
                       (hash-algorithm (content-hash-algorithm content-hash))
                       (algorithm-string (symbol->string hash-algorithm)))
                  `(("integrity" . ,(string-append algorithm-string "-"
-                                                  (base64-encode hash-value)))))
+                                                  (base64-encode hash-value)))
+                   ("outputHashAlgo" . ,algorithm-string)
+                   ("outputHashMode" . ,(if (or (eq? url-fetch method)
+                                                (eq? url-fetch/tarbomb method)
+                                                (eq? url-fetch/zipbomb method))
+                                            "flat"
+                                            "recursive"))))
                '())
          ,@(if (eq? method git-fetch)
                `(("git_ref" . ,(git-reference-commit uri)))

base-commit: 5a6b8cd7286d1c8906beaa35ebba6eff5bae3a79
-- 
2.38.1