forked from lix-project/lix
Merge pull request #3302 from LnL7/darwin-repair-with-sandbox
build: fix path repairing with the darwin sandbox
This commit is contained in:
commit
0486e87791
|
@ -1513,8 +1513,10 @@ void replaceValidPath(const Path & storePath, const Path tmpPath)
|
||||||
Path oldPath = (format("%1%.old-%2%-%3%") % storePath % getpid() % random()).str();
|
Path oldPath = (format("%1%.old-%2%-%3%") % storePath % getpid() % random()).str();
|
||||||
if (pathExists(storePath))
|
if (pathExists(storePath))
|
||||||
rename(storePath.c_str(), oldPath.c_str());
|
rename(storePath.c_str(), oldPath.c_str());
|
||||||
if (rename(tmpPath.c_str(), storePath.c_str()) == -1)
|
if (rename(tmpPath.c_str(), storePath.c_str()) == -1) {
|
||||||
|
rename(oldPath.c_str(), storePath.c_str()); // attempt to recover
|
||||||
throw SysError("moving '%s' to '%s'", tmpPath, storePath);
|
throw SysError("moving '%s' to '%s'", tmpPath, storePath);
|
||||||
|
}
|
||||||
deletePath(oldPath);
|
deletePath(oldPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3565,19 +3567,6 @@ void DerivationGoal::registerOutputs()
|
||||||
if (!missingPaths.count(i.second.path)) continue;
|
if (!missingPaths.count(i.second.path)) continue;
|
||||||
|
|
||||||
Path actualPath = path;
|
Path actualPath = path;
|
||||||
if (useChroot) {
|
|
||||||
actualPath = chrootRootDir + path;
|
|
||||||
if (pathExists(actualPath)) {
|
|
||||||
/* Move output paths from the chroot to the Nix store. */
|
|
||||||
if (buildMode == bmRepair)
|
|
||||||
replaceValidPath(path, actualPath);
|
|
||||||
else
|
|
||||||
if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str()) == -1)
|
|
||||||
throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path);
|
|
||||||
}
|
|
||||||
if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needsHashRewrite()) {
|
if (needsHashRewrite()) {
|
||||||
auto r = redirectedOutputs.find(i.second.path);
|
auto r = redirectedOutputs.find(i.second.path);
|
||||||
if (r != redirectedOutputs.end()) {
|
if (r != redirectedOutputs.end()) {
|
||||||
|
@ -3589,6 +3578,17 @@ void DerivationGoal::registerOutputs()
|
||||||
if (buildMode == bmCheck)
|
if (buildMode == bmCheck)
|
||||||
actualPath = redirected;
|
actualPath = redirected;
|
||||||
}
|
}
|
||||||
|
} else if (useChroot) {
|
||||||
|
actualPath = chrootRootDir + path;
|
||||||
|
if (pathExists(actualPath)) {
|
||||||
|
/* Move output paths from the chroot to the Nix store. */
|
||||||
|
if (buildMode == bmRepair)
|
||||||
|
replaceValidPath(path, actualPath);
|
||||||
|
else
|
||||||
|
if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str()) == -1)
|
||||||
|
throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path);
|
||||||
|
}
|
||||||
|
if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
Loading…
Reference in a new issue