mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Merge pull request #13241 from fzakaria/lix-2100
cherry-pick https://gerrit.lix.systems/c/lix/+/2100
This commit is contained in:
commit
b4bea57667
8 changed files with 43 additions and 58 deletions
|
@ -10,7 +10,7 @@
|
|||
#include "nix/util/util.hh"
|
||||
#include "nix/util/compression.hh"
|
||||
#include "nix/store/common-protocol.hh"
|
||||
#include "nix/store/common-protocol-impl.hh"
|
||||
#include "nix/store/common-protocol-impl.hh" // Don't remove is actually needed
|
||||
#include "nix/store/local-store.hh" // TODO remove, along with remaining downcasts
|
||||
|
||||
#include <fstream>
|
||||
|
|
|
@ -34,7 +34,7 @@ SSHMaster::SSHMaster(
|
|||
throw Error("invalid SSH host name '%s'", host);
|
||||
|
||||
auto state(state_.lock());
|
||||
state->tmpDir = std::make_unique<AutoDelete>(createTempDir("", "nix", true, true, 0700));
|
||||
state->tmpDir = std::make_unique<AutoDelete>(createTempDir("", "nix", 0700));
|
||||
}
|
||||
|
||||
void SSHMaster::addCommonSSHOpts(Strings & args)
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
#include "nix/store/build/derivation-builder.hh"
|
||||
#include "nix/util/file-system.hh"
|
||||
#include "nix/store/local-store.hh"
|
||||
#include "nix/util/processes.hh"
|
||||
#include "nix/store/indirect-root-store.hh"
|
||||
#include "nix/store/build/hook-instance.hh"
|
||||
#include "nix/store/build/worker.hh"
|
||||
#include "nix/store/builtins.hh"
|
||||
#include "nix/store/builtins/buildenv.hh"
|
||||
#include "nix/store/path-references.hh"
|
||||
#include "nix/util/finally.hh"
|
||||
#include "nix/util/util.hh"
|
||||
#include "nix/util/archive.hh"
|
||||
#include "nix/util/git.hh"
|
||||
#include "nix/util/compression.hh"
|
||||
#include "nix/store/daemon.hh"
|
||||
#include "nix/util/topo-sort.hh"
|
||||
#include "nix/util/callback.hh"
|
||||
#include "nix/util/json-utils.hh"
|
||||
#include "nix/util/current-process.hh"
|
||||
#include "nix/store/build/child.hh"
|
||||
#include "nix/util/unix-domain-socket.hh"
|
||||
#include "nix/store/posix-fs-canonicalise.hh"
|
||||
|
@ -671,23 +664,33 @@ static void replaceValidPath(const Path & storePath, const Path & tmpPath)
|
|||
tmpPath (the replacement), so we have to move it out of the
|
||||
way first. We'd better not be interrupted here, because if
|
||||
we're repairing (say) Glibc, we end up with a broken system. */
|
||||
Path oldPath = fmt("%1%.old-%2%-%3%", storePath, getpid(), rand());
|
||||
if (pathExists(storePath))
|
||||
Path oldPath;
|
||||
|
||||
if (pathExists(storePath)) {
|
||||
// why do we loop here?
|
||||
// although makeTempPath should be unique, we can't
|
||||
// guarantee that.
|
||||
do {
|
||||
oldPath = makeTempPath(storePath, ".old");
|
||||
// store paths are often directories so we can't just unlink() it
|
||||
// let's make sure the path doesn't exist before we try to use it
|
||||
} while (pathExists(oldPath));
|
||||
movePath(storePath, oldPath);
|
||||
|
||||
}
|
||||
try {
|
||||
movePath(tmpPath, storePath);
|
||||
} catch (...) {
|
||||
try {
|
||||
// attempt to recover
|
||||
movePath(oldPath, storePath);
|
||||
if (!oldPath.empty())
|
||||
movePath(oldPath, storePath);
|
||||
} catch (...) {
|
||||
ignoreExceptionExceptInterrupt();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
deletePath(oldPath);
|
||||
if (!oldPath.empty())
|
||||
deletePath(oldPath);
|
||||
}
|
||||
|
||||
|
||||
|
@ -877,7 +880,7 @@ void DerivationBuilderImpl::startBuilder()
|
|||
|
||||
/* Create a temporary directory where the build will take
|
||||
place. */
|
||||
topTmpDir = createTempDir(settings.buildDir.get().value_or(""), "nix-build-" + std::string(drvPath.name()), false, false, 0700);
|
||||
topTmpDir = createTempDir(settings.buildDir.get().value_or(""), "nix-build-" + std::string(drvPath.name()), 0700);
|
||||
#ifdef __APPLE__
|
||||
if (false) {
|
||||
#else
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "nix/store/globals.hh"
|
||||
#include "nix/store/pathlocks.hh"
|
||||
#include "nix/util/users.hh"
|
||||
#include "nix/util/logging.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue