mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
guix hash: Honor '-H' when used alongside '-r'.
* guix/scripts/hash.scm (guix-hash): When 'recursive? is true, use 'open-hash-port' instead of 'open-sha256-port'. * tests/guix-hash.sh: Add test for 'guix hash -r -H sha512'.
This commit is contained in:
parent
d005f809f8
commit
ed63b7f87e
2 changed files with 5 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2013, 2014, 2016, 2017, 2020 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012, 2013, 2014, 2016, 2017, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
||||||
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
|
;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
|
||||||
|
@ -151,7 +151,8 @@ (define (file-hash file)
|
||||||
;; Catch and gracefully report possible '&nar-error' conditions.
|
;; Catch and gracefully report possible '&nar-error' conditions.
|
||||||
(with-error-handling
|
(with-error-handling
|
||||||
(if (assoc-ref opts 'recursive?)
|
(if (assoc-ref opts 'recursive?)
|
||||||
(let-values (((port get-hash) (open-sha256-port)))
|
(let-values (((port get-hash)
|
||||||
|
(open-hash-port (assoc-ref opts 'hash-algorithm))))
|
||||||
(write-file file port #:select? select?)
|
(write-file file port #:select? select?)
|
||||||
(force-output port)
|
(force-output port)
|
||||||
(get-hash))
|
(get-hash))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# GNU Guix --- Functional package management for GNU
|
# GNU Guix --- Functional package management for GNU
|
||||||
# Copyright © 2013, 2014, 2016, 2020 Ludovic Courtès <ludo@gnu.org>
|
# Copyright © 2013, 2014, 2016, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
|
||||||
# Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
# Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Guix.
|
# This file is part of GNU Guix.
|
||||||
|
@ -43,6 +43,7 @@ chmod +x "$tmpdir/exe"
|
||||||
mkdir "$tmpdir/subdir"
|
mkdir "$tmpdir/subdir"
|
||||||
|
|
||||||
test `guix hash -r "$tmpdir"` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p
|
test `guix hash -r "$tmpdir"` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p
|
||||||
|
test `guix hash -r "$tmpdir" -H sha512` = 301ra58c2vahczzxiyfin41mpyb0ljh4dh9zn3ijvwviaw1j40sfzw5skh9x945da88n3785ggifzig7acd6k72h0mpsc20m1f66m9n
|
||||||
|
|
||||||
# Without '-r', this should fail.
|
# Without '-r', this should fail.
|
||||||
! guix hash "$tmpdir"
|
! guix hash "$tmpdir"
|
||||||
|
|
Loading…
Reference in a new issue