aboutsummaryrefslogtreecommitdiff
#pragma once

#include <gcrypt.h>

#include "types.hh"
#include "serialise.hh"


namespace nix {


extern const string base32Chars;

typedef enum {
    htUnknown = 0,
    htMD5 = GCRY_MD_MD5,
    htSHA1 = GCRY_MD_SHA1,
    htSHA256 = GCRY_MD_SHA256,
    htSHA512 = GCRY_MD_SHA512,
    htSHA3_256 = GCRY_MD_SHA3_256,
    htSHA3_512 = GCRY_MD_SHA3_512,
    htBLAKE2s_256 = GCRY_MD_BLAKE2S_256
} HashType;

struct Hash
{
    static const unsigned int maxHashSize = 64;
    unsigned int hashSize;
    unsigned char hash[maxHashSize];

    HashType type;

    /* Create an unusable hash object. */
    Hash();

    /* Create a zero-filled hash object. */
    Hash(HashType type);

    /* Check whether two hash are equal. */
    bool operator == (const Hash & h2) const;

    /* Check whether two hash are not equal. */
    bool operator != (const Hash & h2) const;

    /* For sorting. */
    bool operator < (const Hash & h) const;
};


/* Convert a hash to a hexadecimal representation. */
string printHash(const Hash & hash);

/* Parse a hexadecimal representation of a hash code. */
Hash parseHash(HashType ht, const string & s);

/* Returns the length of a base-32 hash representation. */
unsigned int hashLength32(const Hash & hash);

/* Convert a hash to a base-32 representation. */
string printHash32(const Hash & hash);

/* Print a hash in base-16 if it's MD5, or base-32 otherwise. */
string printHash16or32(const Hash & hash);

/* Parse a base-32 representation of a hash code. */
Hash parseHash32(HashType ht, const string & s);

/* Parse a base-16 or base-32 representation of a hash code. */
Hash parseHash16or32(HashType ht, const string & s);

/* Verify that the given string is a valid hash code. */
bool isHash(const string & s);

/* Compute the hash of the given string. */
Hash hashString(HashType ht, const string & s);

/* Compute the hash of the given file. */
Hash hashFile(HashType ht, const Path & path);

/* Compute the hash of the given path.  The hash is defined as
   (essentially) hashString(ht, dumpPath(path)). */
struct PathFilter;
extern PathFilter defaultPathFilter;
typedef std::pair<Hash, unsigned long long> HashResult;
HashResult hashPath(HashType ht, const Path & path,
    PathFilter & filter = defaultPathFilter);

/* Compress a hash to the specified number of bytes by cyclically
   XORing bytes together. */
Hash compressHash(const Hash & hash, unsigned int newSize);

/* Parse a string representing a hash type. */
HashType parseHashType(const string & s);

/* And the reverse. */
string printHashType(HashType ht);


struct Ctx;

class HashSink : public BufferedSink
{
private:
    HashType ht;
    Ctx * ctx;
    unsigned long long bytes;

public:
    HashSink(HashType ht);
    HashSink(const HashSink & h);
    ~HashSink();
    void write(const unsigned char * data, size_t len);
    HashResult finish();
    HashResult currentHash();
};


}
, fixing spacing. [configure-flags]: Use gexp. [propagated-inputs]: Use modify-inputs to replace libsoup with libsoup-minimal-2. * gnu/packages/patches/webkitgtk-bind-all-fonts.patch: Delete file. * gnu/packages/patches/webkitgtk-canonicalize-paths.patch: Likewise. * gnu/local.mk: De-register them. Maxim Cournoyer 2022-04-11gnu: hwloc@1: Update to 1.11.13....* gnu/packages/patches/hwloc-1-test-btrfs.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/mpi.scm (hwloc-1): Use it and update to 1.11.13. Co-authored-by: Ludovic Courtès <ludovic.courtes@inria.fr> Philippe SWARTVAGHER 2022-04-10gnu: efivar: Fix build errors on i686-linux....* gnu/packages/patches/efivar-211.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/linux.scm (efivar)[source]<origin>: Use it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> itd 2022-04-09gnu: ganeti: Update to 3.0.2....* gnu/packages/patches/ganeti-haskell-compat.patch, gnu/packages/patches/ganeti-sphinx-compat.patch: Delete files. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/virtualization.scm (ganeti): Update to 3.0.2. [source](patches): Remove obsolete. [arguments]: Remove obsolete phases. Disable one more test. Marius Bakke 2022-04-09gnu: ganeti: Fix test failure with PyYAML 6.0....This fixes a regression that was introduced in 27720d0fe14ee4cd413a6745e0782a698a011924. * gnu/packages/patches/ganeti-pyyaml-compat.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/virtualization.scm (ganeti)[source](patches): Add it. Marius Bakke 2022-04-07gnu: LLVM, Clang: Add 14.0.0....* gnu/packages/llvm.scm (%llvm-monorepo-hashes, %llvm-patches, llvm-monorepo): New variables. (clang-runtime-from-llvm): Make HASH optional; use monorepo when not present. (clang-from-llvm): Likewise. (llvm-14, clang-runtime-14, clang-14, clang-toolchain-14, lld-14): New variables. (llvm-13): Inherit from LLVM-14. (lld-13): Inherit from LLD-14. (lld): Turn into alias for LLD-14. * gnu/packages/patches/clang-14.0-libc-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/zig.scm (zig): Change from LLD to LLD-13. Marius Bakke 2022-04-05gnu: u-boot: Update to 2022.04....* gnu/packages/bootloaders.scm (u-boot): Update to 2022.01. [native-inputs]: Add gnutls, tinfo, libuuid. (u-boot-qemu-riscv64-smode): Drop custom patches. * gnu/packages/patches/u-boot-allow-disabling-openssl.patch: Refresh patch. * gnu/packages/patches/u-boot-riscv64-fix-extlinux.patch: Remove patch, applied upstream. * gnu/local.mk (dist_patch_DATA): Update with removed patches. Co-authored-by: Ricardo Wurmus <rekado@elephly.net> Vagrant Cascadian 2022-04-05gnu: python-w3lib: Fix build....* gnu/packages/python-web.scm (python-w3lib): Fix build. [source]: Add python-w3lib-fix-test-failure.patch. [arguments]: Use pytest in the 'check phase. [native-inputs]: Add python-pytest. * gnu/packages/patches/python-w3lib-fix-test-failure.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Felix Gruber 2022-04-05gnu: pigx-scrnaseq: Update to 1.1.8....* gnu/packages/bioinformatics.scm (pigx-scrnaseq): Update to 1.1.8. [patches]: Remove. [native-inputs]: Remove. * gnu/packages/patches/pigx-scrnaseq-no-citeproc.patch: Remove file. * gnu/local.mk (dist_patch_DATA): Remove it. Ricardo Wurmus 2022-04-04gnu: gtk: Update to 4.6.1....* gnu/local.mk (dist_patch_DATA): Remove gtk-introspection-test.patch. * gnu/packages/patches/gtk-introspection-test.patch: Remove. * gnu/packages/gtk.scm (gtk): Update to 4.6.1. [source]: Remove stale patch. [arguments]<phases>: Add 'patch-rst2man' phase, correct the binary name of rst2man to 'rst2man.py' [inputs]: Add libjpeg-turbo, libpng, libtiff. [native-inputs]: Add python-docutils. [propagated-inputs]: Use pango-next. * gnu/packages/fcitx5.scm (fcitx5-gtk)[arguments]: Disable GTK4 build. <configure-flags>: Add "-DENABLE_GTK_IM_MODULE=OFF". <phases>: In phase "patch-install-prefix", Remove GTK4 code. [inputs]: Remove package gtk. [outputs]: Remove output "gtk4". Signed-off-by: Ludovic Courtès <ludo@gnu.org> Zhu Zihao 2022-04-03gnu: xterm: Make big cursors work....* gnu/packages/patches/xterm-370-explicit-xcursor.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/xorg.scm (xterm)[source]: Add it. [arguments]<#:configure-flags>: Add "-lXcursor". Danny Milosavljevic 2022-04-03gnu: Add rust-ndarray-0.14....* gnu/packages/crates-io.scm (rust-ndarray-0.14): New variable. * gnu/packages/patches/rust-ndarray-0.14-remove-blas-src.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Efraim Flashner 2022-03-29gnu: pigx-sars-cov2-ww: Update to 0.0.5....* gnu/packages/bioinformatics.scm (pigx-sars-cov2-ww): Update to 0.0.5. [source]: Remove patch. [arguments]: Disable tests. * gnu/packages/patches/pigx-sars-cov2-ww-no-citeproc.patch: Remove file. * gnu/local.mk (dist_patch_DATA): Remove it. Ricardo Wurmus 2022-03-29gnu: pigx-rnaseq: Update to 0.0.20....* gnu/packages/bioinformatics.scm (pigx-rnaseq): Update to 0.0.20. [source]: Remove patch. [inputs]: Add megadepth. * gnu/packages/patches/pigx-rnaseq-no-citeproc.patch: Remove patch. * gnu/local.mk (dist_patch_DATA): Remove it. Ricardo Wurmus 2022-03-28gnu: zig: Remove unneeded patch....* gnu/packages/zig.scm (zig)[source]: Remove one patch. * gnu/packages/patches/zig-disable-libc-note-test.patch: Remove file. * gnu/local.mk (dist_patch_DATA): Remove it. Efraim Flashner 2022-03-24gnu: tremc: Update to 0.9.3....* gnu/packages/bittorrent.scm (tremc): Update to 0.9.3. [source]: Remove obsolete patch. * gnu/packages/patches/tremc-fix-decodestring.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. Leo Famulari 2022-03-24gnu: python-robotframework: Update to 5.0 and run acceptance tests....* gnu/packages/python-xyz.scm (python-robotframework): Update to 5.0. [patches]: Remove python-robotframework-ug2html.patch. Add python-robotframework-atest.patch and update python-robotframework-source-date-epoch.patch. [phases]: Use gexps. {delete-problematic-tests}: New phase. {check}: Also run `atest', the acceptance test suite. [native-inputs]: Use new style. Add python-lxml, python-pyyaml, python-xmlschema, scrot and xvfb-run. * gnu/packages/patches/python-robotframework-atest.patch: New file. * gnu/packages/patches/python-robotframework-source-date-epoch.patch: Update patch. * gnu/packages/patches/python-robotframework-ug2html.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. Maxim Cournoyer 2022-03-21gnu: openboardview: Unbundle imgui....* gnu/packages/patches/openboardview-use-system-imgui.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/electronics.scm (openboardview)[source]: Delete "imgui" subdirectory from snippet and apply patch. [inputs]{imgui}: New input. Maxim Cournoyer 2022-03-19gnu: python-mypy: Fix test errors on i686-linux....* gnu/packages/patches/python-mypy-12332.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/python-check.scm (python-mypy)[source]<origin>: Use patch "python-mypy-12332.patch" to avoid overflow issues resulting in test failures. Signed-off-by: Ludovic Courtès <ludo@gnu.org> itd 2022-03-16gnu: dunst: Update to 1.8.1....* gnu/packages/dunst.scm (dunst): Update to 1.8.1. * gnu/packages/patches/dunst-1.7.3-fix-crash.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Remove it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Jai Vetrivelan 2022-03-15gnu: mariadb: Fix building for powerpc-linux....* gnu/packages/databases.scm (mariadb)[arguments]: Add custom phase for powerpc-linux to apply patch. [native-inputs]: When building for powerpc-linux add patch and a patch file. * gnu/packages/patches/mariadb-link-libatomic.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. Efraim Flashner 2022-03-11gnu: transfig: Fix "multiple definition" errors with GCC 10+....* gnu/packages/patches/transfig-gcc10-fno-common.patch: New patch. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/xfig.scm (transfig)[source]<origin>: Use patch "transfig-gcc10-fno-common.patch" to avoid "multiple definition" errors with GCC 10+ and "-f-no-common". Signed-off-by: Ludovic Courtès <ludo@gnu.org> Ivan Vilata i Balaguer 2022-03-11gnu: sdcc: Update to 4.2.0....* gnu/packages/embedded.scm (sdcc): Update to 4.2.0. [description]: Update to mention the newly supported MOS 6502. * gnu/packages/patches/sdcc-disable-non-free-code.patch: Update to match new version. Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr> Simon South 2022-03-10gnu: python-robotframework: Do not embed a timestamp in the user guide....* gnu/packages/patches/python-robotframework-source-date-epoch.patch: Update patch to cover for the user guide. Maxim Cournoyer 2022-03-09gnu: python-robotframework: Fully build the documentation....* gnu/packages/patches/python-robotframework-ug2html.patch: New patch. * gnu/local.mk: Register it. * gnu/packages/python-xyz.scm (python-robotframework): Apply patch. [modules]: New argument. [phases]{build-and-install-doc}: Modify to build the full HTML documentation, including the user guide. [native-inputs]: Add python-pygments. Maxim Cournoyer 2022-03-09gnu: python-robotframework-sshlibrary: Patch for RobotFramework 5 compatibility....* gnu/packages/patches/python-robotframework-sshlibrary-rf5-compat.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/python-xyz.scm (python-robotframework-sshlibrary): Apply it. Maxim Cournoyer 2022-03-04gnu: racket: Use Git origins for Racket packages....* gnu/packages/patches/racket-gui-tethered-launcher-backport.patch: Adjust path. * gnu/packages/racket.scm (racket-packages-origin) (simple-racket-origin): New procedures. (extend-layer): Rename to ... (configure-layer.rkt): ... this variable. Tweak command-line arguments. Adapt to 'config-tethered-apps-dir'. (racket): Stop inheriting from 'racket-minimal'. [version]: Use '%racket-version'. [source]: Stop using bundled tarball. [inputs]: Remove labels. Add 'racket-minimal' and package sources. [native-inputs]: Reduce to racket-minimal. Untested, as cross-compilation doesn't work yet. [arguments]: Rewrite to use G-expressions, package sources from 'inputs', an explicit 'install' phase, and the revised 'configure-layer.rkt'. Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Philip McGrath 2022-03-04gnu: racket: Update to 8.4....* gnu/packages/patches/racket-enable-scheme-backport.patch, gnu/packages/patches/racket-gui-tethered-launcher-backport.patch: New patches. * gnu/local.mk (dist_patch_DATA): Add them. * gnu/packages/racket.scm (%racket-version, %racket-commit) (%racket-origin): New variables. [patches]: Add "racket-enable-scheme-backport.patch". (racket-minimal): Update to 8.4. [version]: Use '%racket-version'. [source]: Use '%racket-origin'. [inputs]: Add 'ncurses'. Remove 'zlib:static' and 'lz4:static'. (racket-minimal-bc-3m)[inputs]: Adjust accordingly. (racket-bootstrap-chez-bootfiles)[version]: Use Chez Scheme's '(scheme-fork-version-number)'. (racket)[version]: Use '%racket-version'. [native-inputs]: Use '%racket-origin'. [source]: Update to 8.4. <patches>: Use "racket-gui-tethered-launcher-backport.patch". <snippet>: Remove "srfi-doc-nonfree". Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com> Philip McGrath 2022-03-02gnu: rust-pinot-0.1: Update to 0.1.4....* gnu/packages/crates-io.scm (rust-pinot-0.1): Update to 0.1.4. * gnu/packages/patches/rust-pinot-0.1-implement-math-table.patch: Remove file. * gnu/local.mk: Remove reference to the file above. Nicolas Goaziou 2022-03-01gnu: tectonic: Update to 0.8.1....* gnu/packages/rust-apps.scm (tectonic): Update to 0.8.1. [inputs]: Add FREETYPE, GRAPHITE2, ICU4C, LIBPNG. * gnu/packages/crates-io.scm (rust-pinot-0.1)[origin]<patches>: Add patch necessary for Tectonic. (rust-tectonic-docmodel-0.1): Update to 0.1.2. (rust-tectonic-engine-spx2html-0.1): New variable. (rust-tectonic-engine-xetex-0.2): New variable. (rust-tectonic-engine-xetex-0.1): Remove variable. (rust-tectonic-io-base-0.4): New variable. (rust-tectonic-io-base-0.3): Inherit from above. (rust-tectonic-xdv-0.2): New variable. (rust-tectonic-xdv-0.1): Remove variable. * gnu/packages/patches/rust-pinot-0.1-implement-math-table.patch: New file. * gnu/local.mk (dist_patch_DATA): Register new file. Nicolas Goaziou 2022-03-01gnu: guile-ssh: Update to 0.15.1....* gnu/packages/patches/guile-ssh-fix-test-suite.patch, gnu/packages/patches/guile-ssh-read-error.patch: Remove. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/ssh.scm (guile-ssh): Update to 0.15.1, and remove those patches. (guile2.2-ssh)[source]: Remove. (guile2.0-ssh): Remove. Co-authored-by: poptsov.artyom@gmail.com (Artyom V. Poptsov) Ludovic Courtès 2022-03-01gnu: guile@3.0.8: Get correct type sizes when cross-compiling....This works around <https://issues.guix.gnu.org/54198>, whereby cross-compilation from (say) x86_64-linux to i586-pc-gnu would produce a broken Guile that crashes at startup. * gnu/packages/patches/guile-cross-compilation.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/guile.scm (guile-3.0-latest)[source]: Use it. Ludovic Courtès 2022-02-27gnu: screen: Update to 4.9.0....* gnu/packages/screen.scm (screen): Update to 4.9.0. [source]: Remove one patch. [native-inputs]: Remove input labels. Add autoconf, automake. * gnu/packages/patches/screen-CVE-2021-26937.patch: Remove file. * gnu/local.mk (dist_patch_DATA): Remove it. Efraim Flashner 2022-02-24gnu: evilwm: Update to 1.3.1....* gnu/packages/wm.scm (evilwm): Update to 1.3.1. [source]: Remove patch. * gnu/packages/patches/evilwm-lost-focus-bug.patch: Remove. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. Eric Bavier 2022-02-24gnu: webkitgtk: Adjust BubbleWrap wrapper....This revisits <https://issues.guix.gnu.org/40837> with a fix that doesn't require to have PULSE_CLIENTCONFIG point to an absolute store location, which will allow us to revert to have PULSE_CLIENTCONFIG point to a fixed location under /etc. This would alleviate the need to reboot to have changes to the PulseAudio configuration effected. * gnu/packages/patches/webkitgtk-share-store.patch: Delete file. * gnu/packages/patches/webkitgtk-bubblewrap-paths.patch: Add file. * gnu/packages/patches/webkitgtk-canonicalize-paths.patch: Likewise. * gnu/local.mk (dist_patch_DATA): Update patches list. * gnu/packages/webkit.scm (webkitgtk)[patches]: Adjust accordingly. Maxim Cournoyer