Merge pull request #2802 from LnL7/fix-needs-hashrewrite
build: move needsHashRewrite initialization to startBuilder
This commit is contained in:
commit
5f6840fbb4
|
@ -825,9 +825,6 @@ private:
|
||||||
/* Whether we're currently doing a chroot build. */
|
/* Whether we're currently doing a chroot build. */
|
||||||
bool useChroot = false;
|
bool useChroot = false;
|
||||||
|
|
||||||
/* Whether we need to perform hash rewriting if there are valid output paths. */
|
|
||||||
bool needsHashRewrite;
|
|
||||||
|
|
||||||
Path chrootRootDir;
|
Path chrootRootDir;
|
||||||
|
|
||||||
/* RAII object to delete the chroot directory. */
|
/* RAII object to delete the chroot directory. */
|
||||||
|
@ -907,6 +904,9 @@ public:
|
||||||
Worker & worker, BuildMode buildMode = bmNormal);
|
Worker & worker, BuildMode buildMode = bmNormal);
|
||||||
~DerivationGoal();
|
~DerivationGoal();
|
||||||
|
|
||||||
|
/* Whether we need to perform hash rewriting if there are valid output paths. */
|
||||||
|
bool needsHashRewrite();
|
||||||
|
|
||||||
void timedOut() override;
|
void timedOut() override;
|
||||||
|
|
||||||
string key() override
|
string key() override
|
||||||
|
@ -1019,13 +1019,6 @@ DerivationGoal::DerivationGoal(const Path & drvPath, const StringSet & wantedOut
|
||||||
, wantedOutputs(wantedOutputs)
|
, wantedOutputs(wantedOutputs)
|
||||||
, buildMode(buildMode)
|
, buildMode(buildMode)
|
||||||
{
|
{
|
||||||
#if __linux__
|
|
||||||
needsHashRewrite = !useChroot;
|
|
||||||
#else
|
|
||||||
/* Darwin requires hash rewriting even when sandboxing is enabled. */
|
|
||||||
needsHashRewrite = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
state = &DerivationGoal::getDerivation;
|
state = &DerivationGoal::getDerivation;
|
||||||
name = (format("building of '%1%'") % drvPath).str();
|
name = (format("building of '%1%'") % drvPath).str();
|
||||||
trace("created");
|
trace("created");
|
||||||
|
@ -1066,6 +1059,17 @@ DerivationGoal::~DerivationGoal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool DerivationGoal::needsHashRewrite()
|
||||||
|
{
|
||||||
|
#if __linux__
|
||||||
|
return !useChroot;
|
||||||
|
#else
|
||||||
|
/* Darwin requires hash rewriting even when sandboxing is enabled. */
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DerivationGoal::killChild()
|
void DerivationGoal::killChild()
|
||||||
{
|
{
|
||||||
if (pid != -1) {
|
if (pid != -1) {
|
||||||
|
@ -2105,7 +2109,7 @@ void DerivationGoal::startBuilder()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsHashRewrite) {
|
if (needsHashRewrite()) {
|
||||||
|
|
||||||
if (pathExists(homeDir))
|
if (pathExists(homeDir))
|
||||||
throw Error(format("directory '%1%' exists; please remove it") % homeDir);
|
throw Error(format("directory '%1%' exists; please remove it") % homeDir);
|
||||||
|
@ -3088,7 +3092,7 @@ void DerivationGoal::registerOutputs()
|
||||||
if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path);
|
if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsHashRewrite) {
|
if (needsHashRewrite()) {
|
||||||
Path redirected = redirectedOutputs[path];
|
Path redirected = redirectedOutputs[path];
|
||||||
if (buildMode == bmRepair
|
if (buildMode == bmRepair
|
||||||
&& redirectedBadOutputs.find(path) != redirectedBadOutputs.end()
|
&& redirectedBadOutputs.find(path) != redirectedBadOutputs.end()
|
||||||
|
|
|
@ -25,3 +25,6 @@ nix path-info -r $outPath | grep input-2
|
||||||
nix ls-store -R -l $outPath | grep foobar
|
nix ls-store -R -l $outPath | grep foobar
|
||||||
|
|
||||||
nix cat-store $outPath/foobar | grep FOOBAR
|
nix cat-store $outPath/foobar | grep FOOBAR
|
||||||
|
|
||||||
|
# Test --check without hash rewriting.
|
||||||
|
nix-build dependencies.nix --no-out-link --check --sandbox-paths /nix/store
|
||||||
|
|
Loading…
Reference in a new issue