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
ormance TCP/HTTP load balancer") (description "HAProxy offers @acronym{HA, high availability}, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited to Web sites crawling under very high loads while needing persistence or Layer 7 processing. Supporting tens of thousands of connections is clearly realistic with today's hardware.") (license (list license:gpl2+ license:lgpl2.1 license:lgpl2.1+)))) (define-public libqb (package (name "libqb") (version "2.0.8") (source (origin (method url-fetch) (uri (string-append "https://github.com/ClusterLabs/libqb/releases/download/v" version "/libqb-" version ".tar.xz")) (sha256 (base32 "1rifa94zrdr7d5gsy4yvkgqfx8f4yx4xr96hqvs05b5q43y329dl")))) (build-system gnu-build-system) (native-inputs (list pkg-config)) (inputs (list libxml2)) (home-page "https://clusterlabs.github.io/libqb/") (synopsis "Library providing high-performance logging, tracing, IPC, and polling") (description "Libqb is a library with the primary purpose of providing high-performance, reusable features for client-server architecture, such as logging, tracing, @acronym{IPC, inter-process communication} and polling. Libqb is not intended to be an all-encompassing library, but instead provide focused APIs that are highly tuned for maximum performance for client-server applications.") (license license:lgpl2.1))) (define-public kronosnet (package (name "kronosnet") (version "1.29") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/kronosnet/kronosnet") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0dgj8wj0s8x6z7ahgp03fvrx4xv2v7lv8d0j7qbr9jw3ssj0rdc3")))) (build-system gnu-build-system) (arguments ;; XXX: Multiple tests failed. Tests ;; require very complex environment and for some of them root privileges to ;; set network configuration. It has it's own CI based on Jenkis ;; https://ci.kronosnet.org/. (list #:tests? #f #:configure-flags #~'("--disable-static") #:phases #~(modify-phases %standard-phases (add-before 'bootstrap 'fix-version-gen (lambda _ (call-with-output-file ".tarball-version" (lambda (port) (display #$version port)))))))) (native-inputs (list autoconf automake doxygen libtool net-tools pkg-config)) (inputs (list lksctp-tools libnl libqb libxml2 lz4 lzo nss nspr openssl xz zlib `(,zstd "lib"))) (home-page "https://kronosnet.org/") (synopsis "Network abstraction layer designed for High Availability") (description "Kronosnet, often referred to as @code{knet}, is a network abstraction layer designed for High Availability use cases, where redundancy, security, fault tolerance and fast fail-over are the core requirements of your application. Kronosnet is the new underlying network protocol for Linux HA components (Corosync), that features ability to use multiple links between nodes, active/active and active/passive link failover policies, automatic link recovery, FIPS compliant encryption (nss and/or openssl), automatic PMTUd and in general better performances compared to the old network protocol.") (license (list license:gpl2+ license:lgpl2.1+)))) (define-public nats-server (package (name "nats-server") (version "2.10.16") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/nats-io/nats-server") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1l5132swcxxk1d0xdwh1aqrlkcmcss9m9y6hky2yk6b33l1w681v")))) (build-system go-build-system) (inputs (list go-github-com-klauspost-compress go-github-com-minio-highwayhash go-github-com-nats-io-jwt-v2 go-github-com-nats-io-nats-go go-github-com-nats-io-nkeys go-github-com-nats-io-nuid go-go-uber-org-automaxprocs go-golang-org-x-crypto go-golang-org-x-sys go-golang-org-x-time)) (arguments (list #:import-path "github.com/nats-io/nats-server" #:install-source? #f)) (home-page "https://github.com/nats-io/nats-server") (synopsis "High performance message broker") (description "NATS is a simple, secure and performant communications system for digital systems, services and devices. NATS is part of the Cloud Native Computing Foundation (CNCF). NATS has over 40 client language implementations, and its server can run on-premise, in the cloud, at the edge, and even on a Raspberry Pi. NATS can secure and simplify design and operation of modern distributed systems.") (license license:asl2.0))) (define-public nsq (package (name "nsq") (version "1.3.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/nsqio/nsq") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1227ricbng8r5svnpr6hkmwjafa74jdp3ivijrk55qhw43rjk05a")))) (build-system go-build-system) (arguments (list #:import-path "github.com/nsqio/nsq" #:install-source? #f #:phases #~(modify-phases %standard-phases (replace 'build (lambda* (#:key import-path #:allow-other-keys) (with-directory-excursion (string-append "src/" import-path) (invoke "make")))) (replace 'check (lambda* (#:key tests? import-path #:allow-other-keys) (when tests? (setenv "HOME" "/tmp") (with-directory-excursion (string-append "src/" import-path) ;; go test: -race is only supported on linux/amd64, ;; linux/ppc64le, linux/arm64 (invoke #$@(if (not target-x86-32?) (list "go" "test" "-v" "-race" "./...") (list "go" "test" "-v" "./..."))))))) (replace 'install (lambda* (#:key import-path #:allow-other-keys) (with-directory-excursion (string-append "src/" import-path) (invoke "make" (string-append "PREFIX=" #$output) "install"))))))) (native-inputs (list go-github-com-bitly-go-hostpool go-github-com-bitly-timer-metrics go-github-com-blang-semver go-github-com-bmizerany-perks-quantile go-github-com-burntsushi-toml go-github-com-davecgh-go-spew go-github-com-golang-snappy go-github-com-julienschmidt-httprouter go-github-com-mreiferson-go-options go-github-com-mreiferson-go-svc go-github-com-nsqio-go-diskqueue go-github-com-nsqio-go-nsq python-wrapper)) (home-page "https://nsq.io") (synopsis "Realtime distributed messaging platform") (description "NSQ is a realtime distributed messaging platform designed to operate at scale, handling billions of messages per day. Key features: @itemize @item support distributed topologies without @acronym{SPOF, Single Point of Failure} @item scale horizontally (no brokers, seamlessly add more nodes to the cluster) @item low-latency push based message delivery (performance) @item combine load-balanced and multicast style message routing @item excel at both streaming (high-throughput) and job oriented (low-throughput) workloads @item primarily in-memory (beyond a high-water mark messages are transparently kept on disk) @item runtime discovery service for consumers to find producers (nsqlookupd) @item transport layer security (TLS) @item data format agnostic @item few dependencies (easy to deploy) and a sane, bounded, default configuration @item simple TCP protocol supporting client libraries in any language @item HTTP interface for stats, admin actions, and producers (no client library needed to publish) @item integrate with @acronym{StatsD, Stats aggregation Daemon} for realtime instrumentation @item robust cluster administration interface (nsqadmin) @end itemize") (license license:expat))) (define-public corosync (package (name "corosync") (version "3.1.8") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/corosync/corosync") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "02imkif6lzhr8mwbwphdp4m6w987pqnrhai8zx06vpygiasx6cyp")))) (build-system gnu-build-system) (arguments (list #:configure-flags #~'("--disable-static") #:phases #~(modify-phases %standard-phases (add-before 'bootstrap 'fix-version-gen (lambda _ (call-with-output-file ".tarball-version" (lambda (port) (display #$version port)))))))) (native-inputs (list autoconf automake libtool pkg-config)) (inputs (list kronosnet libqb)) (home-page "https://corosync.github.io/corosync/") (synopsis "Group communication system for implementing High Availability in applications") (description "The Corosync Cluster Engine is a Group Communication System with additional features for implementing high availability within applications. The project provides four C Application Programming Interface features: @itemize @item A closed process group communication model with extended virtual synchrony guarantees for creating replicated state machines. @item A simple availability manager that restarts the application process when it has failed. @item A configuration and statistics in-memory database that provide the ability to set, retrieve, and receive change notifications of information. @item A quorum system that notifies applications when quorum is achieved or lost. @end itemize") (license (list license:bsd-0 license:gpl3+)))) (define-public pacemaker (package (name "pacemaker") (version "2.1.7") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/ClusterLabs/pacemaker") (commit (string-append "Pacemaker-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0vhimylbkwabi0hksgs66awn9iq3ik02k1n4xghxh81nhz7kjmdz")))) (build-system gnu-build-system) (arguments (list #:configure-flags #~(list "--with-corosync" "--disable-static" (string-append "--with-initdir=" #$output "/etc/init.d") (string-append "--with-ocfdir=" #$output "/lib")))) (native-inputs (list autoconf automake cmocka gettext-minimal libtool pkg-config rsync util-linux valgrind)) (inputs (list dbus corosync glib gnutls libqb libxml2 libxslt python `(,util-linux "lib"))) (home-page "https://www.clusterlabs.org/pacemaker/") (synopsis "Scalable High-Availability cluster resource manager") (description "Pacemaker is a high-availability cluster resource manager. It achieves maximum availability for your cluster services (a.k.a. resources) by detecting and recovering from node- and resource-level failures by making use of the messaging and membership capabilities provided by Corosync. It can do this for clusters of practically any size and comes with a powerful dependency model that allows the administrator to accurately express the relationships (both ordering and location) between the cluster resources. Virtually anything that can be scripted can be managed as part of a Pacemaker cluster.") (license (list license:cc-by4.0 license:gpl2+ license:lgpl2.1+))))