diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-06 10:56:22 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-06 10:56:22 -0500 |
commit | 989b8065b45e52a8df2a803b1a72e0d0a7c35536 (patch) | |
tree | ffd7d779cf35dc13396aef3b1871a7bc954af350 /src/libstore/derivations.cc | |
parent | 08b8657978de0d56064aad9c3e925b64d91b28a2 (diff) | |
parent | e9fc1e4fdb0ab5adb6b163c3db361b86a4f5c69b (diff) |
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r-- | src/libstore/derivations.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 2d0679871..c2c0520f5 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -446,7 +446,7 @@ std::string Derivation::unparse(const Store & store, bool maskOutputs, // FIXME: remove -bool isDerivation(const std::string & fileName) +bool isDerivation(std::string_view fileName) { return hasSuffix(fileName, drvExtension); } @@ -659,8 +659,10 @@ DrvHash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOut if (res.kind == DrvHash::Kind::Deferred) kind = DrvHash::Kind::Deferred; for (auto & outputName : inputOutputs) { - const auto h = res.hashes.at(outputName); - inputs2[h.to_string(Base16, false)].insert(outputName); + const auto h = get(res.hashes, outputName); + if (!h) + throw Error("no hash for output '%s' of derivation '%s'", outputName, drv.name); + inputs2[h->to_string(Base16, false)].insert(outputName); } } @@ -834,8 +836,11 @@ static void rewriteDerivation(Store & store, BasicDerivation & drv, const String auto hashModulo = hashDerivationModulo(store, Derivation(drv), true); for (auto & [outputName, output] : drv.outputs) { if (std::holds_alternative<DerivationOutput::Deferred>(output.raw())) { - auto & h = hashModulo.hashes.at(outputName); - auto outPath = store.makeOutputPath(outputName, h, drv.name); + auto h = get(hashModulo.hashes, outputName); + if (!h) + throw Error("derivation '%s' output '%s' has no hash (derivations.cc/rewriteDerivation)", + drv.name, outputName); + auto outPath = store.makeOutputPath(outputName, *h, drv.name); drv.env[outputName] = store.printStorePath(outPath); output = DerivationOutput::InputAddressed { .path = std::move(outPath), |