From 4e36644099b71057d01fe3299036c06204ddd326 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov
Date: Fri, 5 Apr 2013 13:10:25 +0000 Subject: [PATCH] Add 'guix hash'. * guix/scripts/hash.scm: New file. * Makefile.am (MODULES): Add it. * po/POTFILES.in: Add it. * doc/guix.texi (Invoking guix hash): New node. --- Makefile.am | 1 + doc/guix.texi | 37 +++++++++++++++ guix/scripts/hash.scm | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ po/POTFILES.in | 1 + 4 files changed, 157 insertions(+), 0 deletions(-) create mode 100644 guix/scripts/hash.scm diff --git a/Makefile.am b/Makefile.am index 136c01b..eb8b80f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ MODULES = \ guix/scripts/import.scm \ guix/scripts/package.scm \ guix/scripts/gc.scm \ + guix/scripts/hash.scm \ guix/scripts/pull.scm \ guix/scripts/substitute-binary.scm \ guix/base32.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 1be172c..b24a92e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -1087,6 +1087,7 @@ space. @menu * Invoking guix build:: Building packages from the command line. +* Invoking guix hash:: Computing the cryptographic hash of a file. @end menu @node Invoking guix build @@ -1182,6 +1183,42 @@ the @code{package-derivation} procedure of the @code{(guix packages)} module, and to the @code{build-derivations} procedure of the @code{(guix store)} module. address@hidden Invoking guix hash address@hidden Invoking @command{guix hash} + +The @command{guix hash} command computes the cryptographic hash of a +file. + +The general syntax is: + address@hidden +guix hash @var{option} @var{file} address@hidden example + address@hidden hash} has the following option: + address@hidden @code + address@hidden address@hidden address@hidden -f @var{fmt} +Write the hash in the given format. + +Supported formats: @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} +will output the hash in @code{nix-base32}. This representation is used +in the definitions of packages. + address@hidden table + address@hidden hash} is a convenient tool to check the integrity of a +file. For example, it can be used to compute the hashes of bootstrap +binaries. + +There is also @code{guix download} which computes the hash of a remote +file. + @c ********************************************************************* @node GNU Distribution @chapter GNU Distribution diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm new file mode 100644 index 0000000..424f3b9 --- /dev/null +++ b/guix/scripts/hash.scm @@ -0,0 +1,118 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2013 Nikita Karetnikov +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see