aboutsummaryrefslogtreecommitdiff
# GNU Guix --- Functional package management for GNU
# Copyright © 2013, 2014, 2016, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
#
# 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 <http://www.gnu.org/licenses/>.

#
# Test the `guix hash' command-line utility.
#

guix hash --version

tmpdir="guix-hash-$$"
trap 'rm -rf "$tmpdir"' EXIT

test `guix hash /dev/null` = 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
test `echo -n | guix hash -` = 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
test `guix hash -f nix-base32 /dev/null` = 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
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="

# Several files.
test "`guix hash /dev/null "$abs_top_srcdir/README"`" = "`guix hash /dev/null ; guix hash "$abs_top_srcdir/README"`"

# Zero files.
guix hash && false

# idem as `cat /dev/null | git hash-object --stdin`
test `guix hash -S git -H sha1 -f hex  /dev/null` = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391

guix hash -H abcd1234 /dev/null && false

mkdir "$tmpdir"
echo -n executable > "$tmpdir/exe"
chmod +x "$tmpdir/exe"
( cd "$tmpdir" ; ln -s exe symlink )
mkdir "$tmpdir/subdir"

test `guix hash -S nar "$tmpdir"` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p
test `guix hash -S nar "$tmpdir" -H sha512` = 301ra58c2vahczzxiyfin41mpyb0ljh4dh9zn3ijvwviaw1j40sfzw5skh9x945da88n3785ggifzig7acd6k72h0mpsc20m1f66m9n
test `guix hash -S git "$tmpdir"` = 1m9yxz99g7askm88h6hzyv4g2bfv57rp5wvwp3iq5ypsplq1xkkk
test `guix hash -S git "$tmpdir" -H sha512` = 158b10d1bsdk4pm8ym9cg9ckfak1b0cgpw7365cl6s341ir380mh2f4ylicyh8khyrfnwq5cn9766d7m8fbfwwl94ndkv456v6a8knr

# Deprecated --recursive option
test `guix hash -r "$tmpdir" 2>/dev/null` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p
test `guix hash -r "$tmpdir" -H sha512 2>/dev/null` = 301ra58c2vahczzxiyfin41mpyb0ljh4dh9zn3ijvwviaw1j40sfzw5skh9x945da88n3785ggifzig7acd6k72h0mpsc20m1f66m9n

# Without '-r', this should fail.
guix hash "$tmpdir" && false

# This should fail because /dev/null is a character device, which
# the archive format doesn't support.
guix hash -S nar /dev/null && false

# Adding a .git directory
mkdir "$tmpdir/.git"
touch "$tmpdir/.git/foo"

# ...changes the hash
test `guix hash -S nar $tmpdir` = 0a50z04zyzf7pidwxv0nwbj82pgzbrhdy9562kncnvkcfvb48m59
test `guix hash -S git $tmpdir` = 0ghlpca9xaswa1ay1g55dknwd9q899mi3ahfr43pq083v8wisjc7

# ...but remains the same when using `-x'
test `guix hash -S nar $tmpdir -x` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g7d74p
test `guix hash -S git $tmpdir -x` = 1m9yxz99g7askm88h6hzyv4g2bfv57rp5wvwp3iq5ypsplq1xkkk

# Without '-r', this should fail.
guix hash "$tmpdir" && false

exit 0
ocoa-foundation-0.1: Update to 0.1.2....* gnu/packages/crates-apple.scm (rust-cocoa-foundation-0.1): Update to 0.1.2. Change-Id: I0e2b0232e53979bbda9fb5175403edd10a14786a Efraim Flashner 2024-02-20gnu: rust-cocoa-0.24: Update to 0.24.1....* gnu/packages/crates-apple.scm (rust-cocoa-0.24): Update to 0.24.1. Change-Id: I4e9365ce4a182b3cd9be885080fbf7fc1d619b95 Efraim Flashner 2024-02-20gnu: rust-block-sys-0.2: Update to 0.2.1....* gnu/packages/crates-apple.scm (rust-block-sys-0.2): Update to 0.2.1. [arguments]: Don't skip the build. Skip the tests. Change-Id: I748fed62c881e28fcb860b482bd30d8d92e79998 Efraim Flashner 2024-02-20gnu: rust-x509-parser: Move to (gnu packages crates-tls)....* gnu/packages/crates-io.scm (rust-x509-parser-0.15, rust-x509-parser-0.14, rust-x509-parser-0.12): Move from here ... * gnu/packages/crates-tls.scm: ... to here. Change-Id: If01b17cf9b418e15616f1b80cefe6b071c8a18b0 Efraim Flashner 2024-02-20gnu: Add rust-mach2-0.4....* gnu/packages/crates-apple.scm (rust-mach2-0.4): New variable. Change-Id: I20b06f1dfcb97c1cd9d9ac70dd47138746e2fc20 Signed-off-by: Efraim Flashner <efraim@flashner.co.il> Wilko Meyer 2024-02-20gnu: Remove rust-security-framework-0.1....* gnu/packages/crates-apple.scm (rust-security-framework-0.1): Delete variable. Change-Id: I9d76a39d94e1365d43b9ef133212bae908d96d20 Efraim Flashner 2024-02-20gnu: Remove rust-security-framework-sys-0.1....* gnu/packages/crates-apple.scm (rust-security-framework-sys-0.1): Delete variable. Change-Id: I4b56205eddbe227b4a88b143c21fd020c5138402 Efraim Flashner 2024-02-20gnu: Add rust-cocoa-0.20....* gnu/packages/crates-apple.scm (rust-cocoa-0.20): New variable. Change-Id: I80b87f02d232ff46ab5709065437fdc217d85743 Efraim Flashner 2024-02-20gnu: rust-metal-0.18: Downgrade to 0.18.0....Later versions of this crate were yanked by upstream. * gnu/packages/crates-apple.scm (rust-metal-0.18): Downgrade to 0.18.0. [cargo-inputs]: Add rust-core-graphics-0.19. Replace rust-cocoa-0.22 with 0.20. Change-Id: I6d75e6bf94ebccd829c356cfe0bf1944ed1f3a0b Efraim Flashner 2024-02-20gnu: rust-fat-macho-0.4: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-fat-macho-0.4): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I94db36b2d2a02952f3ae141edbb72d7a8a445e9f Efraim Flashner 2024-02-20gnu: rust-mach: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-mach-0.3, rust-mach-0.2, rust-mach-o-sys-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I7d52ea709974637355038e8b43b4d193940529e0 Efraim Flashner 2024-02-20gnu: rust-commoncrypto: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-commoncrypto-0.2, rust-commoncrypto-sys-0.2): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I080088e9cea2631736e6fe06158f9263cbddbc5e Efraim Flashner 2024-02-20gnu: rust-metal-0.18: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-metal-0.18): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ica5be709b1a1136cdca0f8b7febf6cf0c68187a4 Efraim Flashner 2024-02-20gnu: rust-icrate-0.0.4: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-icrate-0.0.4): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I567a637f64c4f5efc5f3cc73a28aee9f9a00c627 Efraim Flashner 2024-02-20gnu: rust-fsevent: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-fsevent-2, rust-fsevent-0.4, rust-fsevent-sys-4, rust-fsevent-sys-3, rust-fsevent-sys-2): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I7455ed5e15d312dcf2cc57c1e27ae8caaa47ed8c Efraim Flashner 2024-02-20gnu: rust-cocoa: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-cocoa-0.25, rust-cocoa-0.24, rust-cocoa-0.23, rust-cocoa-0.22, rust-cocoa-0.19, rust-cocoa-0.18, rust-cocoa-foundation-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ie751274ae50082a1fcbc020dbb288d6b7370d6fe Efraim Flashner 2024-02-20gnu: rust-cargo-credential-macos-keychain: Move to crates-apple.scm....* gnu/packages/crates-io.scm (rust-cargo-credential-macos-keychain-0.4, rust-cargo-credential-macos-keychain-0.3): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I6e8becddbeeebe282227dc09c012735134c84665 Efraim Flashner 2024-02-20gnu: rust-system-configuration: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-system-configuration-0.5, rust-system-configuration-sys-0.5): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ia3794ce3ef56520dac26b44acfc91da7f7e3031f Efraim Flashner 2024-02-20gnu: rust-security-framework: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-security-framework-2, rust-security-framework-1, rust-security-framework-0.3, rust-security-framework-0.2, rust-security-framework-0.1, rust-security-framework-sys-2, rust-security-framework-sys-1, rust-security-framework-sys-0.3, rust-security-framework-sys-0.2, rust-security-framework-sys-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ic3fed59019265d19f8c0efa992566691a6a807f6 Efraim Flashner 2024-02-20gnu: rust-readkey-0.1: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-readkey-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ie24d9c158ee88d4f82572ae55326e5967b754d19 Efraim Flashner 2024-02-20gnu: rust-objc: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-objc-0.2, rust-objc-exception-0.1, rust-objc-foundation-0.1, rust-objc-id-0.1, rust-objc-sys-0.3, rust-objc-sys-0.2, rust-objc-test-utils-0.0, rust-objc2-0.4, rust-objc2-0.3, rust-objc2-encode-3, rust-objc2-encode-2, rust-objc2-proc-macros-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I7dedf9dd15aa36a6fd11c2e444499d87ef506107 Efraim Flashner 2024-02-20gnu: rust-dispatch: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-dispatch-0.2, rust-dispatch-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Ia7452e335031b66d14359f2ef9236fd210685506 Efraim Flashner 2024-02-20gnu: rust-core-text: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-core-text-20, rust-core-text-19): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: Idbad69dd6e1bcbff80e6cb3ce699120edb5fa25c Efraim Flashner 2024-02-20gnu: rust-core-foundation: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-core-foundation-0.9, rust-core-foundation-0.7, rust-core-foundation-0.6, rust-core-foundation-0.2, rust-core-foundation-sys-0.8, rust-core-foundation-sys-0.7, rust-core-foundation-sys-0.6, rust-core-foundation-sys-0.2): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I01b1ab7a3bef25d33ea3bd0edc33398acad882e8 Efraim Flashner 2024-02-20gnu: rust-coreaudio: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-coreaudio-rs-0.10, rust-coreaudio-sys-0.2): Move from here ... * gnu/packages/crates-apple.scm: ... to here. Change-Id: I3c9dec888f543cc63152d2a51f8699cc072a05f5 Efraim Flashner 2024-02-20gnu: rust-block: Move to (gnu packages crates-apple)....* gnu/packages/crates-io.scm (rust-block-0.1, rust-block2-0.3, rust-block2-0.2, rust-block-sys-0.2, rust-block-sys-0.1): Move from here ... * gnu/packages/crates-apple.scm: ... to here. * gnu/local.mk (GNU_SYSTEM_MODULES): Register new file. Change-Id: I278dfdb829340fba937d29691b1451401675c87b Efraim Flashner