Merge "libstore: fix "illegal reference specifier 'man'"-error in postgresql_14" into main

This commit is contained in:
Maximilian Bosch
2025-01-12 11:12:12 +00:00
committed by Gerrit Code Review
5 changed files with 32 additions and 6 deletions
+9 -5
View File
@@ -2031,6 +2031,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
OutputPathMap finalOutputs;
std::vector<std::pair<Path, std::optional<Path>>> nondeterministic;
std::map<std::string, StorePath> alreadyRegisteredOutputs;
for (auto & outputName : sortedOutputNames) {
auto output = get(drv->outputs, outputName);
@@ -2054,6 +2055,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
std::optional<StorePathSet> referencesOpt = std::visit(overloaded {
[&](const AlreadyRegistered & skippedFinalPath) -> std::optional<StorePathSet> {
finish(skippedFinalPath.path);
alreadyRegisteredOutputs.insert_or_assign(outputName, skippedFinalPath.path);
return std::nullopt;
},
[&](const PerhapsNeedToRegister & r) -> std::optional<StorePathSet> {
@@ -2383,7 +2385,7 @@ SingleDrvOutputs LocalDerivationGoal::registerOutputs()
}
/* Apply output checks. */
checkOutputs(infos);
checkOutputs(infos, alreadyRegisteredOutputs);
/* Register each output path as valid, and register the sets of
paths referenced by each of them. If there are cycles in the
@@ -2438,13 +2440,13 @@ void LocalDerivationGoal::signRealisation(Realisation & realisation)
}
void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo> & outputs)
void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo> & newlyBuiltOutputs, const std::map<std::string, StorePath> & alreadyRegisteredOutputs)
{
std::map<Path, const ValidPathInfo &> outputsByPath;
for (auto & output : outputs)
for (auto & output : newlyBuiltOutputs)
outputsByPath.emplace(worker.store.printStorePath(output.second.path), output.second);
for (auto & output : outputs) {
for (auto & output : newlyBuiltOutputs) {
auto & outputName = output.first;
auto & info = output.second;
@@ -2510,8 +2512,10 @@ void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo
for (auto & i : *value) {
if (worker.store.isStorePath(i))
spec.insert(worker.store.parseStorePath(i));
else if (auto output = get(outputs, i))
else if (auto output = get(newlyBuiltOutputs, i))
spec.insert(output->path);
else if (auto storePath = get(alreadyRegisteredOutputs, i))
spec.insert(*storePath);
else
throw BuildError("derivation contains an illegal reference specifier '%s'", i);
}
+1 -1
View File
@@ -270,7 +270,7 @@ struct LocalDerivationGoal : public DerivationGoal
* 'outputChecks' attribute (or the legacy
* '{allowed,disallowed}{References,Requisites}' attributes).
*/
void checkOutputs(const std::map<std::string, ValidPathInfo> & outputs);
void checkOutputs(const std::map<std::string, ValidPathInfo> & outputs, const std::map<std::string, StorePath> & alreadyRegisteredOutputs);
/**
* Close the read side of the logger pipe.
+1
View File
@@ -197,6 +197,7 @@ functional_tests_scripts = [
'extra-sandbox-profile.sh',
'substitute-truncated-nar.sh',
'regression-484.sh',
'regression-reference-checks.sh',
]
# Plugin tests require shared libraries support.
@@ -0,0 +1,12 @@
with import ./config.nix;
mkDerivation {
name = "test";
__structuredAttrs = true;
outputs = [ "out" "man" ];
outputChecks.out.disallowedReferences = [ "man" ];
buildCommand = ''
source $NIX_ATTRS_SH_FILE
mkdir ''${outputs[out]}
mkdir ''${outputs[man]}
'';
}
@@ -0,0 +1,9 @@
source common.sh
clearStore
outpath="$(nix-build regression-reference-checks.nix -A out --no-out-link)"
manpage="$(nix-build regression-reference-checks.nix -A man --no-out-link)"
nix-store --delete "$outpath"
nix-build regression-reference-checks.nix -A out --no-out-link