From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KALvIptQLWMMVwAAbAwnHQ (envelope-from ) for ; Fri, 23 Sep 2022 08:22:19 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id OFj8IptQLWOZkwAA9RJhRA (envelope-from ) for ; Fri, 23 Sep 2022 08:22:19 +0200 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 243E728F19 for ; Fri, 23 Sep 2022 08:22:19 +0200 (CEST) Received: from localhost ([::1]:60216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obc4n-00025s-TB for larch@yhetil.org; Fri, 23 Sep 2022 02:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obc3a-00022F-8t for bug-guix@gnu.org; Fri, 23 Sep 2022 02:21:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obc3Z-00081P-Uy for bug-guix@gnu.org; Fri, 23 Sep 2022 02:21:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obc3Z-0007Ij-Pn for bug-guix@gnu.org; Fri, 23 Sep 2022 02:21:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#57978: [PATCH 1/2] substitute: Split nar download. References: In-Reply-To: Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 23 Sep 2022 06:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57978 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 58017@debbugs.gnu.org Cc: Attila Lendvai , 57978@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= , zimoun Received: via spool by 57978-submit@debbugs.gnu.org id=B57978.166391402727984 (code B ref 57978); Fri, 23 Sep 2022 06:21:01 +0000 Received: (at 57978) by debbugs.gnu.org; 23 Sep 2022 06:20:27 +0000 Received: from localhost ([127.0.0.1]:39158 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obc30-0007H7-Fv for submit@debbugs.gnu.org; Fri, 23 Sep 2022 02:20:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obc2y-0007Gi-64; Fri, 23 Sep 2022 02:20:24 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:49284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obc2q-0007uy-5K; Fri, 23 Sep 2022 02:20:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=v8zk/MAZ5CmI+AWHnZJ9I77Ii2NvFYgBrf8bJ9F0cik=; b=q4Ut3ZolX4f1wa VAy+0BKigkFKNSD8nkjTppza1q7UGU8m2FymhjgmBq7lLwWLjjxnOsVCQ0gGKurNLiasaVaP8SLo7 eiIdoCf7F4fs5MrgfPnHobpNo1NJZUMQpw+Yn+cNXSA4GB3m7b24pyNVU3VkCdRV34MBUUXqkGqKe 6D5bxoqqVkfsguyuitdjTACqnXUUrqIHk+AwtHdJD/CUpl24PSzyEtmR6FtMcpjBRaSTOFDazX8kM ZRnDukiED9/IOZFfNF0c86gvWD2+kcNwzDd6sPY1J8bdF4QImMcGHIr0kJcvx4l2IWlwCxjb6/2/P 3J6xWL5ddlxYxs2DBOjQ==; Received: from [89.207.171.75] (port=38064 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obc2o-0007Hi-Uw; Fri, 23 Sep 2022 02:20:15 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 23 Sep 2022 08:19:56 +0200 Message-Id: <20220923061957.5658-1-ludo@gnu.org> X-Mailer: git-send-email 2.37.3 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: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1663914139; 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=zWSLzv/QP9+jRZsYevrvpn4HHfnCYYKNuSq9Huuw2rw=; b=uf2mJv4j24zCMRehbmjT8O2F82Ia5OKNilcdBpXyMnbRoBHgyCv5hRtG8uMt1IOjHpKzYd 0ePmF7a89/K2hyDVViefDnYIdQ6FIBynScmJzmjMsfg7axhnNPGD+8UdvbpXa4Kaq/NMa9 hwQb21Kmk+uzDBJaiP73IpXIwLHHyaMD4h3wsOSawvPwjn2NwmTIqt29l7HzzjX1GM4p3q KSQ5+ct9y8gvAZapgB0OV/9ISiufLr3VIFo4OdIWlDvvS47/hPd2mkcip4Op6e/dM3gRya sV5rxtpJsBPGSQw9ZrjC9VwR8twnq9D6+/AkyjPD8qDYr8PzxDg4eNwdjl6D7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1663914139; a=rsa-sha256; cv=none; b=SNEDtLSoF3ceejG09fygxFsAkQwLu9uJ4xbIIluSi7dhn7T9wPEnbikVsNmZMwOHQet/iZ ToIrTGI2ArT9QOeKex6j8jnnkbiomGBECSGaj+Ob2pi3iHhgNXNfAmzI+0RQd5ddBqA0YY Dx7DFxZcqVV3b43LhPh/hlH2sumN6VkqZiQBDW/4Pt8doitE9yTdkULDyfRBbbvqqP+vwb dGr7CLhMprW5UyOKhibhLYJ0xz/nRdmbr68QoPOZpzssx0ewD5rwUit7lI0ZtNr7k1EEb9 78HqaRDr8LUKqBeIZ0hIL5drmIDg3Ot9VvRZXD7ZKaFUNqoNTD+RiwYxnmaysw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=q4Ut3Zol; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 2.55 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=q4Ut3Zol; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 243E728F19 X-Spam-Score: 2.55 X-Migadu-Scanner: scn1.migadu.com X-TUID: CItKmICFsjRQ * guix/scripts/substitute.scm (download-nar): New procedure, with most of the code moved from... (process-substitution): ... here. Call it. --- guix/scripts/substitute.scm | 52 +++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index cdf591ac4d..e3b382d0d8 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -437,20 +437,13 @@ (define-syntax-rule (with-cached-connection uri port exp ...) "Bind PORT with EXP... to a socket connected to URI." (call-with-cached-connection uri (lambda (port) exp ...))) -(define* (process-substitution port store-item destination - #:key cache-urls acl - deduplicate? print-build-trace?) - "Substitute STORE-ITEM (a store file name) from CACHE-URLS, and write it to -DESTINATION as a nar file. Verify the substitute against ACL, and verify its -hash against what appears in the narinfo. When DEDUPLICATE? is true, and if -DESTINATION is in the store, deduplicate its files. Print a status line to -PORT." - (define narinfo - (lookup-narinfo cache-urls store-item - (if (%allow-unauthenticated-substitutes?) - (const #t) - (cut valid-narinfo? <> acl)))) - +(define* (download-nar narinfo destination + #:key status-port + deduplicate? print-build-trace?) + "Download the nar prescribed in NARINFO, which is assumed to be authentic +and authorized, and write it to DESTINATION. When DEDUPLICATE? is true, and +if DESTINATION is in the store, deduplicate its files. Print a status line to +STATUS-PORT." (define destination-in-store? (string-prefix? (string-append (%store-prefix) "/") destination)) @@ -490,10 +483,6 @@ (define (fetch uri) (leave (G_ "unsupported substitute URI scheme: ~a~%") (uri->string uri))))) - (unless narinfo - (leave (G_ "no valid substitute for '~a'~%") - store-item)) - (let ((uri compression file-size (narinfo-best-uri narinfo #:fast-decompression? @@ -575,14 +564,37 @@ (define cpu-usage (let ((actual (get-hash))) (if (bytevector=? actual expected) ;; Tell the daemon that we're done. - (format port "success ~a ~a~%" + (format status-port "success ~a ~a~%" (narinfo-hash narinfo) (narinfo-size narinfo)) ;; The actual data has a different hash than that in NARINFO. - (format port "hash-mismatch ~a ~a ~a~%" + (format status-port "hash-mismatch ~a ~a ~a~%" (hash-algorithm-name algorithm) (bytevector->nix-base32-string expected) (bytevector->nix-base32-string actual))))))) +(define* (process-substitution port store-item destination + #:key cache-urls acl + deduplicate? print-build-trace?) + "Substitute STORE-ITEM (a store file name) from CACHE-URLS, and write it to +DESTINATION as a nar file. Verify the substitute against ACL, and verify its +hash against what appears in the narinfo. When DEDUPLICATE? is true, and if +DESTINATION is in the store, deduplicate its files. Print a status line to +PORT." + (define narinfo + (lookup-narinfo cache-urls store-item + (if (%allow-unauthenticated-substitutes?) + (const #t) + (cut valid-narinfo? <> acl)))) + + (unless narinfo + (leave (G_ "no valid substitute for '~a'~%") + store-item)) + + (download-nar narinfo destination + #:status-port port + #:deduplicate? deduplicate? + #:print-build-trace? print-build-trace?)) + ;;; ;;; Entry point. -- 2.37.3