mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 08:16:14 +02:00
Add convenience overload for toRealPath()
This commit is contained in:
parent
958ec5de56
commit
7bcc9f2aaf
7 changed files with 20 additions and 15 deletions
|
@ -1398,7 +1398,7 @@ void DerivationGoal::tryToBuild()
|
||||||
few seconds and then retry this goal. */
|
few seconds and then retry this goal. */
|
||||||
PathSet lockFiles;
|
PathSet lockFiles;
|
||||||
for (auto & outPath : drv->outputPaths())
|
for (auto & outPath : drv->outputPaths())
|
||||||
lockFiles.insert(worker.store.toRealPath(worker.store.printStorePath(outPath)));
|
lockFiles.insert(worker.store.Store::toRealPath(outPath));
|
||||||
|
|
||||||
if (!outputLocks.lockPaths(lockFiles, "", false)) {
|
if (!outputLocks.lockPaths(lockFiles, "", false)) {
|
||||||
worker.waitForAWhile(shared_from_this());
|
worker.waitForAWhile(shared_from_this());
|
||||||
|
@ -1429,7 +1429,7 @@ void DerivationGoal::tryToBuild()
|
||||||
for (auto & i : drv->outputs) {
|
for (auto & i : drv->outputs) {
|
||||||
if (worker.store.isValidPath(i.second.path)) continue;
|
if (worker.store.isValidPath(i.second.path)) continue;
|
||||||
debug("removing invalid path '%s'", worker.store.printStorePath(i.second.path));
|
debug("removing invalid path '%s'", worker.store.printStorePath(i.second.path));
|
||||||
deletePath(worker.store.toRealPath(worker.store.printStorePath(i.second.path)));
|
deletePath(worker.store.Store::toRealPath(i.second.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't do a remote build if the derivation has the attribute
|
/* Don't do a remote build if the derivation has the attribute
|
||||||
|
@ -1686,7 +1686,7 @@ void DerivationGoal::buildDone()
|
||||||
|
|
||||||
/* Delete unused redirected outputs (when doing hash rewriting). */
|
/* Delete unused redirected outputs (when doing hash rewriting). */
|
||||||
for (auto & i : redirectedOutputs)
|
for (auto & i : redirectedOutputs)
|
||||||
deletePath(worker.store.toRealPath(worker.store.printStorePath(i.second)));
|
deletePath(worker.store.Store::toRealPath(i.second));
|
||||||
|
|
||||||
/* Delete the chroot (if we were using one). */
|
/* Delete the chroot (if we were using one). */
|
||||||
autoDelChroot.reset(); /* this runs the destructor */
|
autoDelChroot.reset(); /* this runs the destructor */
|
||||||
|
@ -2072,7 +2072,7 @@ void DerivationGoal::startBuilder()
|
||||||
environment using bind-mounts. We put it in the Nix store
|
environment using bind-mounts. We put it in the Nix store
|
||||||
to ensure that we can create hard-links to non-directory
|
to ensure that we can create hard-links to non-directory
|
||||||
inputs in the fake Nix store in the chroot (see below). */
|
inputs in the fake Nix store in the chroot (see below). */
|
||||||
chrootRootDir = worker.store.toRealPath(worker.store.printStorePath(drvPath)) + ".chroot";
|
chrootRootDir = worker.store.Store::toRealPath(drvPath) + ".chroot";
|
||||||
deletePath(chrootRootDir);
|
deletePath(chrootRootDir);
|
||||||
|
|
||||||
/* Clean up the chroot directory automatically. */
|
/* Clean up the chroot directory automatically. */
|
||||||
|
@ -2917,7 +2917,7 @@ void DerivationGoal::addDependency(const StorePath & path)
|
||||||
|
|
||||||
#if __linux__
|
#if __linux__
|
||||||
|
|
||||||
Path source = worker.store.toRealPath(worker.store.printStorePath(path));
|
Path source = worker.store.Store::toRealPath(path);
|
||||||
Path target = chrootRootDir + worker.store.printStorePath(path);
|
Path target = chrootRootDir + worker.store.printStorePath(path);
|
||||||
debug("bind-mounting %s -> %s", target, source);
|
debug("bind-mounting %s -> %s", target, source);
|
||||||
|
|
||||||
|
@ -3579,7 +3579,7 @@ void DerivationGoal::registerOutputs()
|
||||||
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()) {
|
||||||
auto redirected = worker.store.toRealPath(worker.store.printStorePath(r->second));
|
auto redirected = worker.store.Store::toRealPath(r->second);
|
||||||
if (buildMode == bmRepair
|
if (buildMode == bmRepair
|
||||||
&& redirectedBadOutputs.count(i.second.path)
|
&& redirectedBadOutputs.count(i.second.path)
|
||||||
&& pathExists(redirected))
|
&& pathExists(redirected))
|
||||||
|
@ -3672,7 +3672,7 @@ void DerivationGoal::registerOutputs()
|
||||||
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
|
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
|
||||||
worker.store.printStorePath(dest), h.to_string(SRI), h2.to_string(SRI)));
|
worker.store.printStorePath(dest), h.to_string(SRI), h2.to_string(SRI)));
|
||||||
|
|
||||||
Path actualDest = worker.store.toRealPath(worker.store.printStorePath(dest));
|
Path actualDest = worker.store.Store::toRealPath(dest);
|
||||||
|
|
||||||
if (worker.store.isValidPath(dest))
|
if (worker.store.isValidPath(dest))
|
||||||
std::rethrow_exception(delayedException);
|
std::rethrow_exception(delayedException);
|
||||||
|
|
|
@ -354,7 +354,7 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput
|
||||||
if (h == drvHashes.end()) {
|
if (h == drvHashes.end()) {
|
||||||
assert(store.isValidPath(i.first));
|
assert(store.isValidPath(i.first));
|
||||||
h = drvHashes.insert_or_assign(i.first.clone(), hashDerivationModulo(store,
|
h = drvHashes.insert_or_assign(i.first.clone(), hashDerivationModulo(store,
|
||||||
readDerivation(store, store.toRealPath(store.printStorePath(i.first))), false)).first;
|
readDerivation(store, store.toRealPath(i.first)), false)).first;
|
||||||
}
|
}
|
||||||
inputs2.insert_or_assign(h->second.to_string(Base16, false), i.second);
|
inputs2.insert_or_assign(h->second.to_string(Base16, false), i.second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -910,7 +910,7 @@ CachedDownloadResult Downloader::downloadCached(
|
||||||
printInfo("unpacking '%s'...", url);
|
printInfo("unpacking '%s'...", url);
|
||||||
Path tmpDir = createTempDir();
|
Path tmpDir = createTempDir();
|
||||||
AutoDelete autoDelete(tmpDir, true);
|
AutoDelete autoDelete(tmpDir, true);
|
||||||
unpackTarfile(store->toRealPath(store->printStorePath(*storePath)), tmpDir);
|
unpackTarfile(store->toRealPath(*storePath), tmpDir);
|
||||||
auto members = readDirectory(tmpDir);
|
auto members = readDirectory(tmpDir);
|
||||||
if (members.size() != 1)
|
if (members.size() != 1)
|
||||||
throw nix::Error("tarball '%s' contains an unexpected number of top-level files", url);
|
throw nix::Error("tarball '%s' contains an unexpected number of top-level files", url);
|
||||||
|
@ -928,8 +928,8 @@ CachedDownloadResult Downloader::downloadCached(
|
||||||
if (expectedStorePath && *storePath != *expectedStorePath) {
|
if (expectedStorePath && *storePath != *expectedStorePath) {
|
||||||
unsigned int statusCode = 102;
|
unsigned int statusCode = 102;
|
||||||
Hash gotHash = request.unpack
|
Hash gotHash = request.unpack
|
||||||
? hashPath(request.expectedHash.type, store->toRealPath(store->printStorePath(*storePath))).first
|
? hashPath(request.expectedHash.type, store->toRealPath(*storePath)).first
|
||||||
: hashFile(request.expectedHash.type, store->toRealPath(store->printStorePath(*storePath)));
|
: hashFile(request.expectedHash.type, store->toRealPath(*storePath));
|
||||||
throw nix::Error(statusCode, "hash mismatch in file downloaded from '%s':\n wanted: %s\n got: %s",
|
throw nix::Error(statusCode, "hash mismatch in file downloaded from '%s':\n wanted: %s\n got: %s",
|
||||||
url, request.expectedHash.to_string(), gotHash.to_string());
|
url, request.expectedHash.to_string(), gotHash.to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ std::pair<Tree, std::shared_ptr<const Input>> Input::fetchTree(ref<Store> store)
|
||||||
auto [tree, input] = fetchTreeInternal(store);
|
auto [tree, input] = fetchTreeInternal(store);
|
||||||
|
|
||||||
if (tree.actualPath == "")
|
if (tree.actualPath == "")
|
||||||
tree.actualPath = store->toRealPath(store->printStorePath(tree.storePath));
|
tree.actualPath = store->toRealPath(tree.storePath);
|
||||||
|
|
||||||
if (!tree.info.narHash)
|
if (!tree.info.narHash)
|
||||||
tree.info.narHash = store->queryPathInfo(tree.storePath)->narHash;
|
tree.info.narHash = store->queryPathInfo(tree.storePath)->narHash;
|
||||||
|
|
|
@ -55,7 +55,7 @@ static std::optional<std::pair<Hash, Tree>> lookupGitInfo(
|
||||||
|
|
||||||
if (store->isValidPath(storePath)) {
|
if (store->isValidPath(storePath)) {
|
||||||
return {{rev, Tree{
|
return {{rev, Tree{
|
||||||
.actualPath = store->toRealPath(store->printStorePath(storePath)),
|
.actualPath = store->toRealPath(storePath),
|
||||||
.storePath = std::move(storePath),
|
.storePath = std::move(storePath),
|
||||||
.info = TreeInfo {
|
.info = TreeInfo {
|
||||||
.revCount = json["revCount"],
|
.revCount = json["revCount"],
|
||||||
|
@ -357,7 +357,7 @@ struct GitInput : Input
|
||||||
auto lastModified = std::stoull(runProgram("git", true, { "-C", repoDir, "log", "-1", "--format=%ct", input->rev->gitRev() }));
|
auto lastModified = std::stoull(runProgram("git", true, { "-C", repoDir, "log", "-1", "--format=%ct", input->rev->gitRev() }));
|
||||||
|
|
||||||
auto tree = Tree {
|
auto tree = Tree {
|
||||||
.actualPath = store->toRealPath(store->printStorePath(storePath)),
|
.actualPath = store->toRealPath(storePath),
|
||||||
.storePath = std::move(storePath),
|
.storePath = std::move(storePath),
|
||||||
.info = TreeInfo {
|
.info = TreeInfo {
|
||||||
.revCount = revCount,
|
.revCount = revCount,
|
||||||
|
|
|
@ -1263,7 +1263,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
||||||
else
|
else
|
||||||
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, storePathToHash(printStorePath(info->path)));
|
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, storePathToHash(printStorePath(info->path)));
|
||||||
|
|
||||||
dumpPath(toRealPath(printStorePath(i)), *hashSink);
|
dumpPath(Store::toRealPath(i), *hashSink);
|
||||||
auto current = hashSink->finish();
|
auto current = hashSink->finish();
|
||||||
|
|
||||||
if (info->narHash != nullHash && info->narHash != current.first) {
|
if (info->narHash != nullHash && info->narHash != current.first) {
|
||||||
|
|
|
@ -656,6 +656,11 @@ public:
|
||||||
return storePath;
|
return storePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path toRealPath(const StorePath & storePath)
|
||||||
|
{
|
||||||
|
return toRealPath(printStorePath(storePath));
|
||||||
|
}
|
||||||
|
|
||||||
virtual void createUser(const std::string & userName, uid_t userId)
|
virtual void createUser(const std::string & userName, uid_t userId)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue