From patchwork Tue Jun 23 15:55:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 22837 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 9FDA827BBE4; Tue, 23 Jun 2020 16:57:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 1885B27BBE3 for ; Tue, 23 Jun 2020 16:57:11 +0100 (BST) Received: from localhost ([::1]:45536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnlIM-00072m-IN for patchwork@mira.cbaines.net; Tue, 23 Jun 2020 11:57:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jnlIF-00070k-5m for guix-patches@gnu.org; Tue, 23 Jun 2020 11:57:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jnlIE-0000xD-Q0 for guix-patches@gnu.org; Tue, 23 Jun 2020 11:57:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jnlIE-0007MG-Q2 for guix-patches@gnu.org; Tue, 23 Jun 2020 11:57:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42020] [PATCH 4/4] packages: Recognize SHA3 and BLAKE2s for 'content-hash'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 23 Jun 2020 15:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42020 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42020@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 42020-submit@debbugs.gnu.org id=B42020.159292777328208 (code B ref 42020); Tue, 23 Jun 2020 15:57:02 +0000 Received: (at 42020) by debbugs.gnu.org; 23 Jun 2020 15:56:13 +0000 Received: from localhost ([127.0.0.1]:37005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnlHR-0007Ko-6c for submit@debbugs.gnu.org; Tue, 23 Jun 2020 11:56:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42784) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jnlHI-0007Ja-4k for 42020@debbugs.gnu.org; Tue, 23 Jun 2020 11:56:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35823) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jnlHC-0000OO-RS; Tue, 23 Jun 2020 11:55:58 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57536 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jnlHB-0006sV-E3; Tue, 23 Jun 2020 11:55:58 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 23 Jun 2020 17:55:47 +0200 Message-Id: <20200623155547.15886-4-ludo@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200623155547.15886-1-ludo@gnu.org> References: <20200623155547.15886-1-ludo@gnu.org> 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/packages.scm (build-content-hash): Add 'sha3-256', 'sha3-512', and 'blake2s-256'. * tests/packages.scm ("package-source-derivation, origin, sha3-512"): New test. --- guix/packages.scm | 5 ++++- tests/packages.scm | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/guix/packages.scm b/guix/packages.scm index 1e0ec41b76..68ef718872 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -191,7 +191,10 @@ its first argument has the right size for the chosen algorithm." (define-content-hash-constructor build-content-hash (sha256 32) - (sha512 64)) + (sha512 64) + (sha3-256 32) + (sha3-512 64) + (blake2s-256 64)) (define-syntax content-hash (lambda (s) diff --git a/tests/packages.scm b/tests/packages.scm index c7b6f669b5..26377b269b 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -524,6 +524,32 @@ (build-derivations %store (list drv)) (call-with-input-file output get-string-all))) +(test-equal "package-source-derivation, origin, sha3-512" + "hello, sha3" + (let* ((bash (search-bootstrap-binary "bash" (%current-system))) + (builder (add-text-to-store %store "my-fixed-builder.sh" + "echo -n hello, sha3 > $out" '())) + (method (lambda* (url hash-algo hash #:optional name + #:rest rest) + (and (eq? hash-algo 'sha3-512) + (raw-derivation name bash (list builder) + #:sources (list builder) + #:hash hash + #:hash-algo hash-algo)))) + (source (origin + (method method) + (uri "unused://") + (file-name "origin-sha3") + (hash (content-hash + (gcrypt:bytevector-hash (string->utf8 "hello, sha3") + (gcrypt:lookup-hash-algorithm + 'sha3-512)) + sha3-512)))) + (drv (package-source-derivation %store source)) + (output (derivation->output-path drv))) + (build-derivations %store (list drv)) + (call-with-input-file output get-string-all))) + (unless (network-reachable?) (test-skip 1)) (test-equal "package-source-derivation, snippet" "OK"