From e0db50c276014223234d57654dffd2a79ba9b32e Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Thu, 29 Oct 2026 16:44:52 +0800 Subject: [PATCH] utils: Add sri-hash. * modules/rosenthal/utils/packages.scm (sri-hash): New macro. --- modules/rosenthal/utils/packages.scm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/rosenthal/utils/packages.scm b/modules/rosenthal/utils/packages.scm index c5bd9fa..cdd10fd 100644 --- a/modules/rosenthal/utils/packages.scm +++ b/modules/rosenthal/utils/packages.scm @@ -23,7 +23,9 @@ #:use-module (gnu packages base) #:replace (%patch-path search-patch) - #:export (rosenthal-patches + #:export (sri-hash + + rosenthal-patches %rosenthal-package-module-path all-rosenthal-packages @@ -39,6 +41,20 @@ binary-package mapping-for-system)) +(define-syntax sri-hash + (lambda (stx) + (syntax-case stx () + ((_ str) + (let ((str (syntax->datum #'str))) + (and (string? str) + (string-index str #\-))) + (let* ((str (syntax->datum #'str)) + (dash (string-index str #\-)) + (algo (substring str 0 dash)) + (hash (substring str (1+ dash)))) + (with-syntax ((algorithm (datum->syntax #'stx (string->symbol algo)))) + #`(content-hash (base64 #,hash) algorithm))))))) + (define %rosenthal-root-directory ;; This is like %distro-root-directory from (gnu packages), with adjusted ;; paths.