From 921ea4f87ca2f325a0beb09d05fce38006688f85 Mon Sep 17 00:00:00 2001 From: Hilton Chain Date: Mon, 25 Aug 2025 01:20:25 +0800 Subject: [PATCH] rosenthal: guix/hako: Fix URL for uncompressed nars in narinfo files. * modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch: Use nar/none URL for uncompressed nars. --- .../guix-change-publish-cache-storage.patch | 111 +++++++----------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch b/modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch index 40246ab..cc7fe19 100644 --- a/modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch +++ b/modules/rosenthal/packages/patches/guix-change-publish-cache-storage.patch @@ -1,38 +1,63 @@ -From 1a073e25f90223e883754052af1c73bf64fc6d87 Mon Sep 17 00:00:00 2001 -Message-ID: <1a073e25f90223e883754052af1c73bf64fc6d87.1755963523.git.hako@ultrarare.space> +From b05b945ef65c401fc499d8be65d2431749b97980 Mon Sep 17 00:00:00 2001 +Message-ID: From: Hilton Chain Date: Sat, 23 Aug 2025 14:07:19 +0800 -Subject: [PATCH] publish: Store cache in a layout identical to API endpoints. +Subject: [PATCH] publish: Store cache in a layout identical to HTTP endpoints. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows serving substitutes using a file server. +Original layout: --8<---------------cut here---------------start------------->8--- /path/to/publish/cache ├── hashes -│   ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb -│   └── ql2nxr2b587kjydfwivjsnhmqya957bq +│ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb +│ └── ql2nxr2b587kjydfwivjsnhmqya957bq +└── nar + ├── none + │ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2.narinfo + │ └── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2.nar + └── zstd + ├── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1.narinfo + └── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1.nar +--8<---------------cut here---------------end--------------->8--- + +Modified layout: +--8<---------------cut here---------------start------------->8--- +/path/to/publish/cache +├── hashes +│ ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb +│ └── ql2nxr2b587kjydfwivjsnhmqya957bq ├── nar -│   ├── none -│   │   └── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2.nar -│   └── zstd -│   └── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1.nar +│ ├── none +│ │ └── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb-hello-2.12.2 +│ └── zstd +│ └── ql2nxr2b587kjydfwivjsnhmqya957bq-helix-25.01.1 ├── k0pin1y1r0vdkdbg3lwjqc52hpwjbdyb.narinfo └── ql2nxr2b587kjydfwivjsnhmqya957bq.narinfo --8<---------------cut here---------------end--------------->8--- Change-Id: I07689f08eef23c5cd4494451678f4e1ad709f1b3 --- - guix/scripts/publish.scm | 38 +++++++++----------------------------- - 1 file changed, 9 insertions(+), 29 deletions(-) + guix/scripts/publish.scm | 16 +++++----------- + 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm -index e9c69336392..bd9553332c6 100644 +index e9c69336392..62875c926a0 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm -@@ -425,16 +425,12 @@ (define* (render-narinfo store request hash +@@ -307,8 +307,6 @@ (define* (store-item->recutils store-item + (let ((url (encode-and-join-uri-path + `(,@(split-and-decode-uri-path nar-path) + ,@(match compression +- (($ 'none) +- '()) + (($ type) + (list (symbol->string type)))) + ,(basename store-item))))) +@@ -425,16 +423,13 @@ (define* (render-narinfo store request hash (define* (nar-cache-file directory item #:key (compression %no-compression)) @@ -42,18 +67,17 @@ index e9c69336392..bd9553332c6 100644 - "/" (basename item) ".nar")) + "/" (basename item))) --(define* (narinfo-cache-file directory item -- #:key (compression %no-compression)) + (define* (narinfo-cache-file directory item + #:key (compression %no-compression)) - (string-append directory "/" - (symbol->string (compression-type compression)) - "/" (basename item) - ".narinfo")) -+(define* (narinfo-cache-file directory item) + (string-append directory "/" (string-take (basename item) 32) ".narinfo")) (define (hash-part-mapping-cache-file directory hash) (string-append directory "/hashes/" hash)) -@@ -534,9 +530,7 @@ (define* (render-narinfo/cached store request hash +@@ -534,9 +529,7 @@ (define* (render-narinfo/cached store request hash requested using POOL." (define (delete-entry narinfo) ;; Delete NARINFO and the corresponding nar from CACHE. @@ -64,38 +88,7 @@ index e9c69336392..bd9553332c6 100644 (base (basename narinfo ".narinfo")) (hash (string-take base (string-index base #\-))) (mapping (hash-part-mapping-cache-file cache hash))) -@@ -547,9 +541,7 @@ (define* (render-narinfo/cached store request hash - (let* ((item (hash-part->path* store hash cache)) - (compressions (actual-compressions item compressions)) - (cached (and (not (string-null? item)) -- (narinfo-cache-file cache item -- #:compression -- (first compressions))))) -+ (narinfo-cache-file cache item)))) - (cond ((string-null? item) - (not-found request #:ttl negative-ttl)) - ((file-exists? cached) -@@ -648,8 +640,7 @@ (define* (bake-narinfo+nar cache item - - (match compressions - ((main others ...) -- (let ((narinfo (narinfo-cache-file cache item -- #:compression main))) -+ (let ((narinfo (narinfo-cache-file cache item))) - (with-atomic-file-output narinfo - (lambda (port) - ;; Open a new connection to the store. We cannot reuse the main -@@ -672,8 +663,7 @@ (define* (bake-narinfo+nar cache item - ;; atime-based cache eviction considers either all the nars or none - ;; of them as candidates. - (for-each (lambda (other) -- (let ((other (narinfo-cache-file cache item -- #:compression other))) -+ (let ((other (narinfo-cache-file cache item))) - (link narinfo other))) - others)))))) - -@@ -1043,6 +1033,7 @@ (define (string->compression-type string) +@@ -1043,6 +1036,7 @@ (define (string->compression-type string) ("gzip" 'gzip) ("lzip" 'lzip) ("zstd" 'zstd) @@ -103,26 +96,8 @@ index e9c69336392..bd9553332c6 100644 (_ #f))) (define (effective-compression requested-type compressions) -@@ -1140,17 +1131,6 @@ (define* (make-request-handler store - #:compression compression))) - (not-found request))) - -- ;; /nar/ -- ((components ... store-item) -- (if (nar-path? components) -- (if cache -- (render-nar/cached store cache request store-item -- #:ttl narinfo-ttl -- #:compression %no-compression) -- (render-nar store request store-item -- #:compression %no-compression)) -- (not-found request))) -- - (x (not-found request))) - (not-found request))) - -base-commit: 73f943fd9f4cc69bd0463e6c64abeb65e060e1da +base-commit: 4e2e5c71cbf4a219682e77dfb8b9ac8709461999 -- 2.51.0