From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AIhMNaVnu2EDVwEAgWs5BA (envelope-from ) for ; Thu, 16 Dec 2021 17:21:57 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id AM/wMKVnu2EPZQAAbx9fmQ (envelope-from ) for ; Thu, 16 Dec 2021 16:21:57 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5A450BECA for ; Thu, 16 Dec 2021 17:21:57 +0100 (CET) Received: from localhost ([::1]:44414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxtW0-0005Iq-I7 for larch@yhetil.org; Thu, 16 Dec 2021 11:21:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxtV8-0004SD-OX for guix-patches@gnu.org; Thu, 16 Dec 2021 11:21:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:53195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxtV8-0003Ob-Eg for guix-patches@gnu.org; Thu, 16 Dec 2021 11:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mxtV8-0003xx-3x for guix-patches@gnu.org; Thu, 16 Dec 2021 11:21:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [RFC PATCH 1/3] publish: Add ERIS URN to narinfo Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 16 Dec 2021 16:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52555@debbugs.gnu.org Cc: pukkamustard , ~pukkamustard/eris@lists.sr.ht Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.163967165715196 (code B ref 52555); Thu, 16 Dec 2021 16:21:02 +0000 Received: (at 52555) by debbugs.gnu.org; 16 Dec 2021 16:20:57 +0000 Received: from localhost ([127.0.0.1]:36502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxtV2-0003x1-HG for submit@debbugs.gnu.org; Thu, 16 Dec 2021 11:20:56 -0500 Received: from mout01.posteo.de ([185.67.36.65]:37321) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mxtUx-0003wb-RN for 52555@debbugs.gnu.org; Thu, 16 Dec 2021 11:20:54 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 43FC9240026 for <52555@debbugs.gnu.org>; Thu, 16 Dec 2021 17:20:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1639671645; bh=c506nOniPbxfWxa5Datyw8oJED0OKeKWWVS7Qozcw10=; h=From:To:Cc:Subject:Date:From; b=GgY5+Cdof2C9QGoRmOaV/LbGZ9OSD/kJwQwxbMx1W50K/MnV3OyMltuBEOI60iAWg nR0Yn7SK+x0Z2b4Epyp3+0gYiVGKkR06lmq2UnI+KYz/gSSr3wwtUD7/f5MFdGxBt8 0BuI1Led8qyeypkADSsiR29ra02FPhd3oFu/TXE5/DiHS6iDjYUzmGpjINGoifaYmV bRtVXXWvp/4GUSzYGqVko3EgfwQnTPt4+tNpjlrhNCmgeoofH1OYeufxysrdBwsOOE zvNVgEOpGA2V9kjDQ+Lm9wSlZV5MdEgaBI0Mv92FojJy83vOrTqJsWZ9iWR+NUVIoB JpsinZnAntYtA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JFHR01ll4z9rxT; Thu, 16 Dec 2021 17:20:43 +0100 (CET) From: pukkamustard Date: Thu, 16 Dec 2021 16:20:34 +0000 Message-Id: <20211216162036.694-1-pukkamustard@posteo.net> In-Reply-To: <20211216161724.547-1-pukkamustard@posteo.net> References: <20211216161724.547-1-pukkamustard@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1639671717; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=vOGW+gBbnUy2PHLzeuUV4qBvHmP1pY2niZsnX8077hI=; b=ho+KS9DWEK1eob4qn9vHowGNVPxPaWrOuw2rjdw7vjZdqw2h/FLTbzTGGQp0QWXwqM5oP7 b4yOMx2yAzP1yc5JYJ6vP4b3QTh7X01v4NRLXQfqolVV5v9NRTJzJ+MzEorh5W8b6Yv5Hz fshMMTMoRyjjm3MaB3V0SMHshUzH+EjJOsqAsORzCSuxu7PQ5KDXqDKrFQXTwT/BtDQK71 bFB7vAbjvhC8NLe99ze5Nn45iRHZJSd8bGBc4z7r/LO7Mznipr4EaERe0Vb0XQGRgcwqmP ONozNob4QQ7JQqC6CwSifGnZjECjLJgYuLq9ezs/oBcSRh+BgQK18DjhJEgsng== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1639671717; a=rsa-sha256; cv=none; b=ViiJxBEcbLE/Ft9QonhNQ64OE3lD+GLKKg9H23sKGs3GUju0vdAzA/UQe38kJIbxjEWGrg Hnes/VhkNvtMt65H/D6k+ZKspIPw62VXRKvpPSaSi3UO5hdhRHLp/cU6KzklAUogJ2SWgy 1KLLjZHOnOtshFOy132BN0LSvMw55TZF95md4NyJCMfYIgOXfmapYu7w9y9Kl12kW1rIJf cgbcIlyFrNWD3gE8AMTbUpSXEaWKmju4xXbPZKtxk1aYAscOu+kOeBB1ArG4QZmd7602wl U+ZV8hRjqj1lhy4Q6PDBgQWkqJcub1W0nPg7ML3uzRVxFS4SW6p2A+nO0Qu17g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=GgY5+Cdo; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -1.69 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=GgY5+Cdo; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 5A450BECA X-Spam-Score: -1.69 X-Migadu-Scanner: scn0.migadu.com X-TUID: dXP0F/Qj2xls * guix/scripts/publish.scm: (bake-narinfo+nar): Compute ERIS URN of compressed nars. (narinfo-string): Add #:eris-urns parameter and honor it. (store-item->recutils): Add #:eris-urn parameter and honor it. * guix/scripts/narinfo.scm: ()[eris-urns]: New field. (narinfo-maker): Handle ERIS URN. * configure.ac: (HAVE_GUILE_ERIS): New conditional. * gnu/packages/package-management.scm: (guix)[native-inputs]: Add guile-eris. --- configure.ac | 5 +++++ gnu/packages/package-management.scm | 1 + guix/narinfo.scm | 10 ++++++---- guix/scripts/publish.scm | 31 +++++++++++++++++++++-------- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 341cff8fbd..72396be8aa 100644 --- a/configure.ac +++ b/configure.ac @@ -170,6 +170,11 @@ GUILE_MODULE_AVAILABLE([have_guile_avahi], [(avahi)]) AM_CONDITIONAL([HAVE_GUILE_AVAHI], [test "x$have_guile_avahi" = "xyes"]) +dnl Check for Guile-eris. +GUILE_MODULE_AVAILABLE([have_guile_eris], [(eris)]) +AM_CONDITIONAL([HAVE_GUILE_ERIS], + [test "x$have_guile_eris" = "xyes"]) + dnl Guile-newt is used by the graphical installer. GUILE_MODULE_AVAILABLE([have_guile_newt], [(newt)]) diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index 9496499850..5c49167782 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -394,6 +394,7 @@ (define code ("guile-zstd" ,guile-zstd) ("guile-ssh" ,guile-ssh) ("guile-git" ,guile-git) + ("guile-eris" ,guile-eris) ;; XXX: Keep the development inputs here even though ;; they're unnecessary, just so that 'guix environment diff --git a/guix/narinfo.scm b/guix/narinfo.scm index 4fc550aa6c..0972ede3c1 100644 --- a/guix/narinfo.scm +++ b/guix/narinfo.scm @@ -67,13 +67,14 @@ (define-module (guix narinfo) equivalent-narinfo?)) (define-record-type - (%make-narinfo path uri-base uris compressions file-sizes file-hashes - nar-hash nar-size references deriver system + (%make-narinfo path uri-base uris eris-urns compressions file-sizes + file-hashes nar-hash nar-size references deriver system signature contents) narinfo? (path narinfo-path) (uri-base narinfo-uri-base) ;URI of the cache it originates from (uris narinfo-uris) ;list of strings + (eris-urns narinfo-eris-urns) ;list of (strings | #f) (compressions narinfo-compressions) ;list of strings (file-sizes narinfo-file-sizes) ;list of (integers | #f) (file-hashes narinfo-file-hashes) @@ -134,7 +135,7 @@ (define (narinfo-signature->canonical-sexp str) (define (narinfo-maker str cache-url) "Return a narinfo constructor for narinfos originating from CACHE-URL. STR must contain the original contents of a narinfo file." - (lambda (path urls compressions file-hashes file-sizes + (lambda (path urls eris-urns compressions file-hashes file-sizes nar-hash nar-size references deriver system signature) "Return a new object." @@ -148,6 +149,7 @@ (define len (length urls)) (string-append cache-url url) (string-append cache-url "/" url))))) urls) + eris-urns compressions (match file-sizes (() (make-list len #f)) @@ -186,7 +188,7 @@ (define* (read-narinfo port #:optional url "FileHash" "FileSize" "NarHash" "NarSize" "References" "Deriver" "System" "Signature") - '("URL" "Compression" "FileSize" "FileHash")))) + '("URL" "ERIS" "Compression" "FileSize" "FileHash")))) (define (narinfo-sha256 narinfo) "Return the sha256 hash of NARINFO as a bytevector, or #f if NARINFO lacks a diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 6e2b4368da..8e4b90789b 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -58,6 +58,7 @@ (define-module (guix scripts publish) #:use-module (guix workers) #:use-module (guix store) #:use-module ((guix serialization) #:select (write-file)) + #:use-module (eris) #:use-module (zlib) #:autoload (lzlib) (call-with-lzip-output-port make-lzip-output-port) @@ -308,7 +309,7 @@ (define* (store-item->recutils store-item #:key (nar-path "nar") (compression %no-compression) - file-size) + file-size eris-urn) "Return the 'Compression' and 'URL' fields of the narinfo for STORE-ITEM, with COMPRESSION, starting at NAR-PATH." (let ((url (encode-and-join-uri-path @@ -319,19 +320,22 @@ (define* (store-item->recutils store-item (($ type) (list (symbol->string type)))) ,(basename store-item))))) - (format #f "URL: ~a~%Compression: ~a~%~@[FileSize: ~a~%~]" - url (compression-type compression) file-size))) + (format #f "URL: ~a~%Compression: ~a~%~@[FileSize: ~a~%~]~@[ERIS: ~a~%~]" + url (compression-type compression) file-size eris-urn))) (define* (narinfo-string store store-path #:key (compressions (list %no-compression)) - (nar-path "nar") (file-sizes '())) + (nar-path "nar") (file-sizes '()) (eris-urns '())) "Generate a narinfo key/value string for STORE-PATH; an exception is raised if STORE-PATH is invalid. Produce a URL that corresponds to COMPRESSION. The narinfo is signed with KEY. NAR-PATH specifies the prefix for nar URLs. Optionally, FILE-SIZES is a list of compression/integer pairs, where the integer is size in bytes of the compressed NAR; it informs the client of how -much needs to be downloaded." +much needs to be downloaded. + +Optionally, ERIS-URNS is a list of compression/string pairs, where the +string is the ERIS URN of the compressed NAR." (let* ((path-info (query-path-info store store-path)) (compressions (actual-compressions store-path compressions)) (hash (bytevector->nix-base32-string @@ -352,9 +356,12 @@ (define* (narinfo-string store store-path store-path (map (lambda (compression) (let ((size (assoc-ref file-sizes - compression))) + compression)) + (eris-urn (assoc-ref eris-urns + compression))) (store-item->recutils store-path #:file-size size + #:eris-urn eris-urn #:nar-path nar-path #:compression compression))) @@ -632,6 +639,12 @@ (define (compressed-nar-size compression) (and stat (cons compression (stat:size stat))))) + (define (compressed-eris-urn compression) + (let* ((nar (nar-cache-file cache item #:compression compression)) + (stat (stat nar #f))) + (and stat + (cons compression (call-with-input-file nar eris-encode->urn))))) + (let ((compression (actual-compressions item compressions))) (for-each (cut compress-nar cache item <>) compressions) @@ -646,11 +659,13 @@ (define (compressed-nar-size compression) ;; thread's connection to the store since we would end up sending ;; stuff concurrently on the same channel. (with-store store - (let ((sizes (filter-map compressed-nar-size compression))) + (let ((sizes (filter-map compressed-nar-size compression)) + (eris-urns (filter-map compressed-eris-urn compression))) (display (narinfo-string store item #:nar-path nar-path #:compressions compressions - #:file-sizes sizes) + #:file-sizes sizes + #:eris-urns eris-urns) port))) ;; Make the cached narinfo world-readable, contrary to what -- 2.34.0