build: fix path repairing when hash rewriting is required

Handle store path repairing on darwin when sandboxing is enabled. Unlike
on linux sandboxing on darwin still requires hash rewriting.
This commit is contained in:
Daiderd Jordan 2020-01-04 20:23:59 +01:00
parent b33fefcb92
commit 7d448bc966
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -3567,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()) {
@ -3591,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;