libstore: remove DerivationOutput::Deferred
we can't create these any more except by reading an old json-formatted derivation that used them. since we cannot do anything with a deferred derivation even when read we will remove json support for them as well Change-Id: I4f9ea0b7c6469f57977784037f7710f939e40a2c
This commit is contained in:
@@ -1023,7 +1023,7 @@ drvName, Bindings * attrs, Value & v)
|
||||
for (auto & i : outputs) {
|
||||
drv.env[i] = "";
|
||||
drv.outputs.insert_or_assign(i,
|
||||
DerivationOutput::Deferred { });
|
||||
DerivationOutput::InputAddressed { .path = StorePath::dummy });
|
||||
}
|
||||
|
||||
auto hashModulo =
|
||||
|
||||
@@ -526,21 +526,6 @@ try {
|
||||
if (useDerivation) {
|
||||
auto & fullDrv = *dynamic_cast<Derivation *>(drv.get());
|
||||
|
||||
auto drvType = fullDrv.type();
|
||||
bool resolveDrv = std::visit(overloaded {
|
||||
[&](const DerivationType::InputAddressed & ia) {
|
||||
/* must resolve if deferred. */
|
||||
return ia.deferred;
|
||||
},
|
||||
[&](const DerivationType::ContentAddressed & ca) {
|
||||
return false;
|
||||
},
|
||||
}, drvType.raw);
|
||||
|
||||
if (resolveDrv && !fullDrv.inputDrvs.empty()) {
|
||||
throw UnimplementedError("ca derivations are not supported");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines)
|
||||
auto accumInputPaths = [&](const StorePath & depDrvPath, const StringSet & inputNode) -> kj::Promise<Result<void>> {
|
||||
try {
|
||||
|
||||
@@ -1878,12 +1878,6 @@ try {
|
||||
|
||||
return newInfo0;
|
||||
},
|
||||
|
||||
[&](const DerivationOutput::Deferred &) -> ValidPathInfo {
|
||||
// No derivation should reach that point without having been
|
||||
// rewritten first
|
||||
assert(false);
|
||||
},
|
||||
}, output->raw);
|
||||
|
||||
/* FIXME: set proper permissions in restorePath() so
|
||||
|
||||
@@ -25,9 +25,6 @@ std::optional<StorePath> DerivationOutput::path(const Store & store, std::string
|
||||
dof.path(store, drvName, outputName)
|
||||
};
|
||||
},
|
||||
[](const DerivationOutput::Deferred &) -> std::optional<StorePath> {
|
||||
return std::nullopt;
|
||||
},
|
||||
}, raw);
|
||||
}
|
||||
|
||||
@@ -72,7 +69,7 @@ bool DerivationType::hasKnownOutputPaths() const
|
||||
{
|
||||
return std::visit(overloaded {
|
||||
[](const InputAddressed & ia) {
|
||||
return !ia.deferred;
|
||||
return true;
|
||||
},
|
||||
[](const ContentAddressed & ca) {
|
||||
return true;
|
||||
@@ -257,7 +254,7 @@ static DerivationOutput parseDerivationOutput(
|
||||
}
|
||||
} else {
|
||||
if (pathS == "") {
|
||||
return DerivationOutput::Deferred { };
|
||||
throw UnimplementedError("deferred input-addressed derivations are not supported");
|
||||
}
|
||||
validatePath(pathS);
|
||||
return DerivationOutput::InputAddressed {
|
||||
@@ -441,11 +438,6 @@ std::string Derivation::unparse(const Store & store, bool maskOutputs,
|
||||
s += ','; printUnquotedString(s, dof.ca.printMethodAlgo());
|
||||
s += ','; printUnquotedString(s, dof.ca.hash.to_string(Base::Base16, false));
|
||||
},
|
||||
[&](const DerivationOutput::Deferred &) {
|
||||
s += ','; printUnquotedString(s, "");
|
||||
s += ','; printUnquotedString(s, "");
|
||||
s += ','; printUnquotedString(s, "");
|
||||
},
|
||||
}, i.second.raw);
|
||||
s += ')';
|
||||
}
|
||||
@@ -512,8 +504,7 @@ DerivationType BasicDerivation::type() const
|
||||
{
|
||||
std::set<std::string_view>
|
||||
inputAddressedOutputs,
|
||||
fixedCAOutputs,
|
||||
deferredIAOutputs;
|
||||
fixedCAOutputs;
|
||||
|
||||
for (auto & i : outputs) {
|
||||
std::visit(overloaded {
|
||||
@@ -523,27 +514,19 @@ DerivationType BasicDerivation::type() const
|
||||
[&](const DerivationOutput::CAFixed &) {
|
||||
fixedCAOutputs.insert(i.first);
|
||||
},
|
||||
[&](const DerivationOutput::Deferred &) {
|
||||
deferredIAOutputs.insert(i.first);
|
||||
},
|
||||
}, i.second.raw);
|
||||
}
|
||||
|
||||
if (inputAddressedOutputs.empty()
|
||||
&& fixedCAOutputs.empty()
|
||||
&& deferredIAOutputs.empty())
|
||||
&& fixedCAOutputs.empty())
|
||||
throw Error("must have at least one output");
|
||||
|
||||
if (!inputAddressedOutputs.empty()
|
||||
&& fixedCAOutputs.empty()
|
||||
&& deferredIAOutputs.empty())
|
||||
return DerivationType::InputAddressed {
|
||||
.deferred = false,
|
||||
};
|
||||
&& fixedCAOutputs.empty())
|
||||
return DerivationType::InputAddressed {};
|
||||
|
||||
if (inputAddressedOutputs.empty()
|
||||
&& !fixedCAOutputs.empty()
|
||||
&& deferredIAOutputs.empty())
|
||||
&& !fixedCAOutputs.empty())
|
||||
{
|
||||
if (fixedCAOutputs.size() > 1)
|
||||
// FIXME: Experimental feature?
|
||||
@@ -553,13 +536,6 @@ DerivationType BasicDerivation::type() const
|
||||
return DerivationType::ContentAddressed {};
|
||||
}
|
||||
|
||||
if (inputAddressedOutputs.empty()
|
||||
&& fixedCAOutputs.empty()
|
||||
&& !deferredIAOutputs.empty())
|
||||
return DerivationType::InputAddressed {
|
||||
.deferred = true,
|
||||
};
|
||||
|
||||
throw Error("can't mix derivation output types");
|
||||
}
|
||||
|
||||
@@ -748,11 +724,6 @@ void writeDerivation(Sink & out, const Store & store, const BasicDerivation & dr
|
||||
<< dof.ca.printMethodAlgo()
|
||||
<< dof.ca.hash.to_string(Base::Base16, false);
|
||||
},
|
||||
[&](const DerivationOutput::Deferred &) {
|
||||
out << ""
|
||||
<< ""
|
||||
<< "";
|
||||
},
|
||||
}, i.second.raw);
|
||||
}
|
||||
out << CommonProto::write(store,
|
||||
@@ -796,21 +767,7 @@ try {
|
||||
}
|
||||
drv.env = newEnv;
|
||||
|
||||
auto hashModulo = TRY_AWAIT(hashDerivationModulo(store, Derivation(drv), true));
|
||||
for (auto & [outputName, output] : drv.outputs) {
|
||||
if (std::holds_alternative<DerivationOutput::Deferred>(output.raw)) {
|
||||
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),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
TRY_AWAIT(hashDerivationModulo(store, Derivation(drv), true));
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
@@ -950,10 +907,6 @@ try {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
},
|
||||
[](const DerivationOutput::Deferred &) -> kj::Promise<Result<void>> {
|
||||
/* Nothing to check */
|
||||
return {result::success()};
|
||||
},
|
||||
}, i.second.raw));
|
||||
}
|
||||
co_return result::success();
|
||||
@@ -976,7 +929,6 @@ JSON DerivationOutput::toJSON(
|
||||
res["hash"] = dof.ca.hash.to_string(Base::Base16, false);
|
||||
// FIXME print refs?
|
||||
},
|
||||
[&](const DerivationOutput::Deferred &) {},
|
||||
}, raw);
|
||||
return res;
|
||||
}
|
||||
@@ -1029,7 +981,7 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||
}
|
||||
|
||||
else if (keys == (std::set<std::string_view> { })) {
|
||||
return DerivationOutput::Deferred {};
|
||||
throw UnimplementedError("deferred input-addressed derivations are not supported");
|
||||
}
|
||||
|
||||
else if (keys == (std::set<std::string_view> { "hashAlgo", "impure" })) {
|
||||
|
||||
@@ -63,18 +63,9 @@ struct DerivationOutput
|
||||
GENERATE_CMP(CAFixed, me->ca);
|
||||
};
|
||||
|
||||
/**
|
||||
* Input-addressed output which depends on a (CA) derivation whose hash
|
||||
* isn't known yet.
|
||||
*/
|
||||
struct Deferred {
|
||||
GENERATE_CMP(Deferred);
|
||||
};
|
||||
|
||||
typedef std::variant<
|
||||
InputAddressed,
|
||||
CAFixed,
|
||||
Deferred
|
||||
CAFixed
|
||||
> Raw;
|
||||
|
||||
Raw raw;
|
||||
@@ -133,14 +124,7 @@ struct DerivationType {
|
||||
* Input-addressed derivation types
|
||||
*/
|
||||
struct InputAddressed {
|
||||
/**
|
||||
* True iff the derivation type can't be determined statically,
|
||||
* for instance because it (transitively) depends on a content-addressed
|
||||
* derivation.
|
||||
*/
|
||||
bool deferred;
|
||||
|
||||
GENERATE_CMP(InputAddressed, me->deferred);
|
||||
GENERATE_CMP(InputAddressed);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -236,7 +236,7 @@ try {
|
||||
drv.env.emplace("name", drv.name);
|
||||
drv.inputSrcs.insert(std::move(getEnvShPath));
|
||||
for (auto & output : drv.outputs) {
|
||||
output.second = DerivationOutput::Deferred { };
|
||||
output.second = DerivationOutput::InputAddressed { .path = StorePath::dummy };
|
||||
drv.env[output.first] = "";
|
||||
}
|
||||
auto hashesModulo = TRY_AWAIT(hashDerivationModulo(*evalStore, drv, true));
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -102,10 +102,6 @@ TEST_JSON(DerivationTest, caFixedNAR,
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
|
||||
TEST_JSON(DerivationTest, deferred,
|
||||
DerivationOutput::Deferred { },
|
||||
"drv-name", "output-name")
|
||||
|
||||
#undef TEST_JSON
|
||||
|
||||
#define TEST_JSON(FIXTURE, NAME, VAL) \
|
||||
|
||||
Reference in New Issue
Block a user