From patchwork Tue Jan 25 19:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pukkamustard X-Patchwork-Id: 36808 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1F48727BBEA; Tue, 25 Jan 2022 19:23:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D125C27BBE9 for ; Tue, 25 Jan 2022 19:23:32 +0000 (GMT) Received: from localhost ([::1]:47254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCRPf-0004EA-V2 for patchwork@mira.cbaines.net; Tue, 25 Jan 2022 14:23:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCRPE-000496-PQ for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCRPE-0000BV-E7 for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nCRPE-0001FA-BX for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [RFC PATCH v2 5/5] substitute: Fetch substitutes using ERIS. Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 25 Jan 2022 19:23:04 +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.16431385644699 (code B ref 52555); Tue, 25 Jan 2022 19:23:04 +0000 Received: (at 52555) by debbugs.gnu.org; 25 Jan 2022 19:22:44 +0000 Received: from localhost ([127.0.0.1]:50154 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCROt-0001De-So for submit@debbugs.gnu.org; Tue, 25 Jan 2022 14:22:44 -0500 Received: from mout01.posteo.de ([185.67.36.65]:41807) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCROf-0001CR-O1 for 52555@debbugs.gnu.org; Tue, 25 Jan 2022 14:22:30 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 2BFA2240029 for <52555@debbugs.gnu.org>; Tue, 25 Jan 2022 20:22:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1643138544; bh=j7T0v7hpPHZH+YN4wChkVCZNNIqTEpqBrEMRdms1Xc4=; h=From:To:Cc:Subject:Date:From; b=aCsMaZzdU2NgT+wR3r3pQ6awfvPTBY/ROM+4GQsQrm0YW0BD+bgZsQiRm7MdfRV2/ vx/b76cm1NwC+84qbrS2xAyMHdLiC1nNu/YHZ6oRKLoPL6akpybgp3MITSUU99pMXf IJHqO7EuONC5H0GwBXjD9Jz+PfX6nIXkl1a5huc1bKbNF0w7r1NN4pfgVUsARHdVgz 3jw2phmXQCDJ1Ta6NCAHztahZKj9mkP7lsROG9+FjJnDcRjZPThEuE6iSYk8oS7Mzp yAcXjYxeajUzQssVumj3m1pTiaguZYKhdeFVZbwU/OFD/me0V5RKu/Op0zzZeHLP1L 8bmk5mH9vFRxQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JjxZ72hWgz9rxV; Tue, 25 Jan 2022 20:22:23 +0100 (CET) From: pukkamustard Date: Tue, 25 Jan 2022 19:22:01 +0000 Message-Id: <20220125192201.7582-6-pukkamustard@posteo.net> In-Reply-To: <20220125192201.7582-1-pukkamustard@posteo.net> References: <20220125192201.7582-1-pukkamustard@posteo.net> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/scripts/substitute.scm (process-substitution): Fetch substitutes using ERIS. * guix/eris.scm (guix-eris-block-ref): New procedure. --- guix/eris.scm | 7 ++++++- guix/scripts/substitute.scm | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/guix/eris.scm b/guix/eris.scm index 163bbe05ac..0999564c1f 100644 --- a/guix/eris.scm +++ b/guix/eris.scm @@ -23,7 +23,8 @@ (define-module (guix eris) #:use-module (web response) #:use-module (srfi srfi-71) - #:export (guix-eris-block-reducer)) + #:export (guix-eris-block-reducer + guix-eris-block-ref)) (define (ipfs-daemon-alive?) "Attempt to connect to the IPFS daemon. Returns #t if the daemon is alive @@ -53,3 +54,7 @@ (define guix-eris-block-reducer (if ipfs (eris-blocks-ipfs-reducer ipfs ref-block) ipfs)))) + +(define (guix-eris-block-ref ref) + "Dereference a block for decoding ERIS content" + (eris-blocks-ipfs-ref ref)) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 908a8334a8..852264976e 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -62,6 +62,8 @@ (define-module (guix scripts substitute) #:use-module (srfi srfi-35) #:use-module (web uri) #:use-module (guix http-client) + #:use-module (guix eris) + #:use-module (eris) #:export (%allow-unauthenticated-substitutes? %reply-file-descriptor @@ -486,18 +488,27 @@ (define (fetch uri) #:port port #:keep-alive? #t #:buffered? #f))))) + (else - (leave (G_ "unsupported substitute URI scheme: ~a~%") - (uri->string uri))))) + (if (and (eris-read-capability? uri)) + (values (eris-decode->port uri + #:block-ref + guix-eris-block-ref) #f) + (leave (G_ "unsupported substitute URI scheme: ~a~%") + (uri->string uri)))))) + + (define* (best-uri narinfo #:key (eris? #f)) + (if (and eris? (narinfo-eris-urn narinfo)) + (values (narinfo-eris-urn narinfo) "zstd" #f) + (narinfo-best-uri narinfo #:fast-decompression? + %prefer-fast-decompression?))) (unless narinfo (leave (G_ "no valid substitute for '~a'~%") store-item)) (let-values (((uri compression file-size) - (narinfo-best-uri narinfo - #:fast-decompression? - %prefer-fast-decompression?))) + (best-uri narinfo #:eris? #t))) (unless print-build-trace? (format (current-error-port) (G_ "Downloading ~a...~%") (uri->string uri)))