From 64519cfd657d024ae6e2bb74cb21ad21b886fd2a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Dec 2008 15:06:30 +0000 Subject: * Unify the treatment of sources copied to the store, and recursive SHA-256 outputs of fixed-output derivations. I.e. they now produce the same store path: $ nix-store --add x /nix/store/j2fq9qxvvxgqymvpszhs773ncci45xsj-x $ nix-store --add-fixed --recursive sha256 x /nix/store/j2fq9qxvvxgqymvpszhs773ncci45xsj-x the latter being the same as the path that a derivation derivation { name = "x"; outputHashAlgo = "sha256"; outputHashMode = "recursive"; outputHash = "..."; ... }; produces. This does change the output path for such fixed-output derivations. Fortunately they are quite rare. The most common use is fetchsvn calls with SHA-256 hashes. (There are a handful of those is Nixpkgs, mostly unstable development packages.) * Documented the computation of store paths (in store-api.cc). --- src/libstore/local-store.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/libstore/local-store.cc') diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 9dcd13471124..e015894b9fdc 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -670,14 +670,14 @@ void LocalStore::invalidatePath(const Path & path) } -Path LocalStore::addToStore(const Path & _srcPath, bool fixed, +Path LocalStore::addToStore(const Path & _srcPath, bool recursive, string hashAlgo, PathFilter & filter) { Path srcPath(absPath(_srcPath)); debug(format("adding `%1%' to the store") % srcPath); std::pair pr = - computeStorePathForPath(srcPath, fixed, recursive, hashAlgo, filter); + computeStorePathForPath(srcPath, recursive, hashAlgo, filter); Path & dstPath(pr.first); Hash & h(pr.second); @@ -696,10 +696,13 @@ Path LocalStore::addToStore(const Path & _srcPath, bool fixed, copyPath(srcPath, dstPath, filter); + /* !!! */ +#if 0 Hash h2 = hashPath(htSHA256, dstPath, filter); if (h != h2) throw Error(format("contents of `%1%' changed while copying it to `%2%' (%3% -> %4%)") % srcPath % dstPath % printHash(h) % printHash(h2)); +#endif canonicalisePathMetaData(dstPath); @@ -713,10 +716,10 @@ Path LocalStore::addToStore(const Path & _srcPath, bool fixed, } -Path LocalStore::addTextToStore(const string & suffix, const string & s, +Path LocalStore::addTextToStore(const string & name, const string & s, const PathSet & references) { - Path dstPath = computeStorePathForText(suffix, s, references); + Path dstPath = computeStorePathForText(name, s, references); addTempRoot(dstPath); -- cgit 1.4.1