diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-02-22T15·31+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-02-22T15·58+0100 |
commit | f023f64f40809afa8a8e3a5e7081209cbcfd2e7e (patch) | |
tree | 46e7da4c94037a598c37887f6ccf7597758ddf18 /src/libstore | |
parent | fe2db1dae59f379eda793da952425a8331139c65 (diff) |
RemoteStore::addToStore(): Pass content-addressability assertion
... and use this in Downloader::downloadCached(). This fixes $ nix-build https://nixos.org/channels/nixos-16.09-small/nixexprs.tar.xz -A hello error: cannot import path ‘/nix/store/csfbp1s60dkgmk9f8g0zk0mwb7hzgabd-nixexprs.tar.xz’ because it lacks a valid signature
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/download.cc | 1 | ||||
-rw-r--r-- | src/libstore/local-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/remote-store.cc | 2 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 6 | ||||
-rw-r--r-- | src/libstore/store-api.hh | 7 |
5 files changed, 15 insertions, 3 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 25ccd7d0b526..a56fd6922a5c 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -612,6 +612,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa Hash hash = hashString(expectedHash ? expectedHash.type : htSHA256, *res.data); info.path = store->makeFixedOutputPath(false, hash, name); info.narHash = hashString(htSHA256, *sink.s); + info.ca = makeFixedOutputCA(false, hash); store->addToStore(info, sink.s, false, true); storePath = info.path; } diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 4c161cfb341f..9b775e16a387 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -1002,7 +1002,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name, info.narHash = hash.first; info.narSize = hash.second; info.ultimate = true; - info.ca = "fixed:" + (recursive ? (std::string) "r:" : "") + h.to_string(); + info.ca = makeFixedOutputCA(recursive, h); registerValidPath(info); } diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 42c09ec7e0b6..7f398685a2c1 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -380,7 +380,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, const ref<std::string> conn->to << wopAddToStoreNar << info.path << info.deriver << printHash(info.narHash) << info.references << info.registrationTime << info.narSize - << info.ultimate << info.sigs << *nar << repair << dontCheckSigs; + << info.ultimate << info.sigs << info.ca << *nar << repair << dontCheckSigs; // FIXME: don't send nar as a string conn->processStderr(); } diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index b5934a0d1232..401b001b2d8f 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -676,6 +676,12 @@ Strings ValidPathInfo::shortRefs() const } +std::string makeFixedOutputCA(bool recursive, const Hash & hash) +{ + return "fixed:" + (recursive ? (std::string) "r:" : "") + hash.to_string(); +} + + } diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index d03e70849f93..c344b9d66ed3 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -128,7 +128,7 @@ struct ValidPathInfo of an output path of a derivation were actually produced by that derivation. In the intensional model, we have to trust that a particular output path was produced by a derivation; the - path name then implies the contents.) + path then implies the contents.) Ideally, the content-addressability assertion would just be a Boolean, and the store path would be computed from @@ -687,6 +687,11 @@ ValidPathInfo decodeValidPathInfo(std::istream & str, bool hashGiven = false); +/* Compute the content-addressability assertion (ValidPathInfo::ca) + for paths created by makeFixedOutputPath() / addToStore(). */ +std::string makeFixedOutputCA(bool recursive, const Hash & hash); + + MakeError(SubstError, Error) MakeError(BuildError, Error) /* denotes a permanent build failure */ MakeError(InvalidPath, Error) |