forked from lix-project/lix
build: make needsHashRewrite a method
This commit is contained in:
parent
d75bdb5793
commit
ce02fc74b2
|
@ -803,9 +803,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. */
|
||||||
|
@ -885,6 +882,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
|
||||||
|
@ -1037,6 +1037,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) {
|
||||||
|
@ -1845,13 +1856,6 @@ void DerivationGoal::startBuilder()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __linux__
|
|
||||||
needsHashRewrite = !useChroot;
|
|
||||||
#else
|
|
||||||
/* Darwin requires hash rewriting even when sandboxing is enabled. */
|
|
||||||
needsHashRewrite = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If `build-users-group' is not empty, then we have to build as
|
/* If `build-users-group' is not empty, then we have to build as
|
||||||
one of the members of that group. */
|
one of the members of that group. */
|
||||||
if (settings.buildUsersGroup != "" && getuid() == 0) {
|
if (settings.buildUsersGroup != "" && getuid() == 0) {
|
||||||
|
@ -2083,7 +2087,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);
|
||||||
|
@ -3067,7 +3071,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()
|
||||||
|
|
Loading…
Reference in a new issue