diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-02-22 16:31:04 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-02-22 16:58:00 +0100 |
commit | f023f64f40809afa8a8e3a5e7081209cbcfd2e7e (patch) | |
tree | 46e7da4c94037a598c37887f6ccf7597758ddf18 | |
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
-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 | ||||
-rw-r--r-- | src/nix-daemon/nix-daemon.cc | 1 |
6 files changed, 16 insertions, 3 deletions
diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 25ccd7d0b..a56fd6922 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 4c161cfb3..9b775e16a 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 42c09ec7e..7f398685a 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 b5934a0d1..401b001b2 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 d03e70849..c344b9d66 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) diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 3b43ddfa1..9fbc43b82 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -582,6 +582,7 @@ static void performOp(ref<LocalStore> store, bool trusted, unsigned int clientVe info.narSize = readLongLong(from); info.ultimate = readLongLong(from); info.sigs = readStrings<StringSet>(from); + info.ca = readString(from); auto nar = make_ref<std::string>(readString(from)); auto repair = readInt(from) ? true : false; auto dontCheckSigs = readInt(from) ? true : false; |