From patchwork Tue Feb 20 19:42:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 60817 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 22F1A27BBE2; Tue, 20 Feb 2024 19:43:13 +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.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS 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 EEC7827BBEA for ; Tue, 20 Feb 2024 19:43:11 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcW0s-0004E2-DF; Tue, 20 Feb 2024 14:42:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcW0q-0004Cb-Be for guix-patches@gnu.org; Tue, 20 Feb 2024 14:42:44 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcW0q-00016T-2t; Tue, 20 Feb 2024 14:42:44 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcW1A-0002Zp-10; Tue, 20 Feb 2024 14:43:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69291] [PATCH 5/5] scripts: substitute: Extract script specific output from download-nar. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Feb 2024 19:43:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69291 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69291@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 69291-submit@debbugs.gnu.org id=B69291.17084581829876 (code B ref 69291); Tue, 20 Feb 2024 19:43:03 +0000 Received: (at 69291) by debbugs.gnu.org; 20 Feb 2024 19:43:02 +0000 Received: from localhost ([127.0.0.1]:46681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW17-0002Yy-Kj for submit@debbugs.gnu.org; Tue, 20 Feb 2024 14:43:02 -0500 Received: from mira.cbaines.net ([212.71.252.8]:43162) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcW0y-0002Y3-Db for 69291@debbugs.gnu.org; Tue, 20 Feb 2024 14:42:53 -0500 Received: from localhost (unknown [212.132.255.10]) by mira.cbaines.net (Postfix) with ESMTPSA id 1138A27BBEA for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:30 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 23ba8778 for <69291@debbugs.gnu.org>; Tue, 20 Feb 2024 19:42:29 +0000 (UTC) From: Christopher Baines Date: Tue, 20 Feb 2024 19:42:27 +0000 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches As this moves download-nar in a direction where it could be used outside the substitute script. * guix/scripts/substitute.scm (download-nar): Return more information and move status-port output to… (guix-substitute): here. Change-Id: Icbddb9a47620b3520cdd2e8095f37a99824c1ce0 --- guix/scripts/substitute.scm | 49 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 61e16b22db..94eb6d2f71 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm @@ -568,26 +568,10 @@ (define* (download-nar narinfo destination ;; Wait for the reporter to finish. (every (compose zero? cdr waitpid) pids) - ;; Skip a line after what 'progress-reporter/file' printed, and another - ;; one to visually separate substitutions. When PRINT-BUILD-TRACE? is - ;; true, leave it up to (guix status) to prettify things. - (newline (current-error-port)) - (unless print-build-trace? - (newline (current-error-port))) - - ;; Check whether we got the data announced in NARINFO. - (let ((actual (get-hash))) - (if (bytevector=? actual expected) - ;; Tell the daemon that we're done. - (format status-port "success ~a ~a~%" - (narinfo-hash narinfo) (narinfo-size narinfo)) - ;; The actual data has a different hash than that in NARINFO. - (format status-port "hash-mismatch ~a ~a ~a~%" - (hash-algorithm-name algorithm) - (bytevector->nix-base32-string expected) - (bytevector->nix-base32-string actual)))) - - cpu-usage))) + (values narinfo + expected + (get-hash) + cpu-usage)))) (define (system-error? exception) "Return true if EXCEPTION is a Guile 'system-error exception." @@ -891,7 +875,10 @@ (define-command (guix-substitute . args) ((? eof-object?) #t) ((= string-tokenize ("substitute" store-path destination)) - (let ((cpu-usage + (let ((narinfo + expected-hash + actual-hash + cpu-usage (process-substitution reply-port store-path destination #:cache-urls (substitute-urls) #:acl (current-acl) @@ -901,6 +888,26 @@ (define-command (guix-substitute . args) #:prefer-fast-decompression? prefer-fast-decompression?))) + ;; Skip a line after what 'progress-reporter/file' printed, + ;; and another one to visually separate substitutions. When + ;; PRINT-BUILD-TRACE? is true, leave it up to (guix status) + ;; to prettify things. + (newline (current-error-port)) + (unless print-build-trace? + (newline (current-error-port))) + + ;; Check whether we got the data announced in NARINFO. + (if (bytevector=? actual-hash expected-hash) + ;; Tell the daemon that we're done. + (format reply-port "success ~a ~a~%" + (narinfo-hash narinfo) (narinfo-size narinfo)) + ;; The actual data has a different hash than that in NARINFO. + (format reply-port "hash-mismatch ~a ~a ~a~%" + (hash-algorithm-name + (narinfo-hash-algorithm+value narinfo)) + (bytevector->nix-base32-string expected-hash) + (bytevector->nix-base32-string actual-hash))) + ;; Create a hysteresis: depending on CPU usage, favor ;; compression methods with faster decompression (like ztsd) ;; or methods with better compression ratios (like lzip).