From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EBJCAJH/wl4GbQAA0tVLHw (envelope-from ) for ; Mon, 18 May 2020 21:35:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mCOZN5D/wl7xfgAAbx9fmQ (envelope-from ) for ; Mon, 18 May 2020 21:35:12 +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 9A781940B62 for ; Mon, 18 May 2020 21:35:12 +0000 (UTC) Received: from localhost ([::1]:55202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1janPj-00006K-JA for larch@yhetil.org; Mon, 18 May 2020 17:35:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1janOe-0007wC-Ii for guix-patches@gnu.org; Mon, 18 May 2020 17:34:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1janOc-0000W4-R4 for guix-patches@gnu.org; Mon, 18 May 2020 17:34:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1janOc-0001aS-Os for guix-patches@gnu.org; Mon, 18 May 2020 17:34:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41382] [PATCH 4/6] guix hash, guix download: Support base64 format. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 18 May 2020 21:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41382 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41382@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 41382-submit@debbugs.gnu.org id=B41382.15898375896006 (code B ref 41382); Mon, 18 May 2020 21:34:02 +0000 Received: (at 41382) by debbugs.gnu.org; 18 May 2020 21:33:09 +0000 Received: from localhost ([127.0.0.1]:48465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1janNk-0001Ym-LR for submit@debbugs.gnu.org; Mon, 18 May 2020 17:33:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1janNf-0001XM-2r for 41382@debbugs.gnu.org; Mon, 18 May 2020 17:33:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37558) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1janNZ-0000QI-RM; Mon, 18 May 2020 17:32:57 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=50964 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1janNZ-0007J8-20; Mon, 18 May 2020 17:32:57 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 18 May 2020 23:32:42 +0200 Message-Id: <20200518213244.24165-4-ludo@gnu.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518213244.24165-1-ludo@gnu.org> References: <20200518213244.24165-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 3.99 X-TUID: I0zB1Nhx0xnI * guix/scripts/download.scm (show-help, %options): Support "base64" format. * guix/scripts/hash.scm (show-help, %options): Likewise. * tests/guix-hash.sh: Test it. * doc/guix.texi (Invoking guix hash): Document it. --- doc/guix.texi | 2 +- guix/scripts/download.scm | 12 ++++++++---- guix/scripts/hash.scm | 14 +++++++++----- tests/guix-hash.sh | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0cf006770e..fdd9622211 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9076,7 +9076,7 @@ Reference Manual}). @itemx -f @var{fmt} Write the hash in the format specified by @var{fmt}. -Supported formats: @code{nix-base32}, @code{base32}, @code{base16} +Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16} (@code{hex} and @code{hexadecimal} can be used as well). If the @option{--format} option is not specified, @command{guix hash} diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm index b4446c2e2f..589f62da9d 100644 --- a/guix/scripts/download.scm +++ b/guix/scripts/download.scm @@ -23,6 +23,7 @@ #:use-module (gcrypt hash) #:use-module (guix base16) #:use-module (guix base32) + #:autoload (guix base64) (base64-encode) #:use-module ((guix download) #:hide (url-fetch)) #:use-module ((guix build download) #:select (url-fetch)) @@ -84,10 +85,11 @@ (define (show-help) (display (G_ "Usage: guix download [OPTION] URL Download the file at URL to the store or to the given file, and print its -file name and the hash of its contents. - -Supported formats: 'nix-base32' (default), 'base32', and 'base16' -('hex' and 'hexadecimal' can be used as well).\n")) +file name and the hash of its contents.\n")) + (newline) + (display (G_ "\ +Supported formats: 'base64', 'nix-base32' (default), 'base32', +and 'base16' ('hex' and 'hexadecimal' can be used as well).\n")) (format #t (G_ " -f, --format=FMT write the hash in the given format")) (format #t (G_ " @@ -111,6 +113,8 @@ Supported formats: 'nix-base32' (default), 'base32', and 'base16' (lambda (opt name arg result) (define fmt-proc (match arg + ("base64" + base64-encode) ("nix-base32" bytevector->nix-base32-string) ("base32" diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm index cfc4420260..9b4f419a24 100644 --- a/guix/scripts/hash.scm +++ b/guix/scripts/hash.scm @@ -20,12 +20,13 @@ ;;; along with GNU Guix. If not, see . (define-module (guix scripts hash) - #:use-module (guix base32) #:use-module (gcrypt hash) #:use-module (guix serialization) #:use-module (guix ui) #:use-module (guix scripts) #:use-module (guix base16) + #:use-module (guix base32) + #:autoload (guix base64) (base64-encode) #:use-module (ice-9 binary-ports) #:use-module (rnrs files) #:use-module (ice-9 match) @@ -47,10 +48,11 @@ (define (show-help) (display (G_ "Usage: guix hash [OPTION] FILE -Return the cryptographic hash of FILE. - -Supported formats: 'nix-base32' (default), 'base32', and 'base16' ('hex' -and 'hexadecimal' can be used as well).\n")) +Return the cryptographic hash of FILE.\n")) + (newline) + (display (G_ "\ +Supported formats: 'base64', 'nix-base32' (default), 'base32', +and 'base16' ('hex' and 'hexadecimal' can be used as well).\n")) (format #t (G_ " -x, --exclude-vcs exclude version control directories")) (format #t (G_ " @@ -83,6 +85,8 @@ and 'hexadecimal' can be used as well).\n")) (lambda (opt name arg result) (define fmt-proc (match arg + ("base64" + base64-encode) ("nix-base32" bytevector->nix-base32-string) ("base32" diff --git a/tests/guix-hash.sh b/tests/guix-hash.sh index 1c595b49ed..3538b9aeda 100644 --- a/tests/guix-hash.sh +++ b/tests/guix-hash.sh @@ -32,6 +32,7 @@ test `guix hash -f nix-base32 /dev/null` = 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lz test `guix hash -f hex /dev/null` = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 test `guix hash -f base32 /dev/null` = 4oymiquy7qobjgx36tejs35zeqt24qpemsnzgtfeswmrw6csxbkq test `guix hash -H sha512 -f hex /dev/null` = cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e +test `guix hash -H sha1 -f base64 /dev/null` = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=" if guix hash -H abcd1234 /dev/null; then false; else true; fi -- 2.26.2