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. */
|
||||
PathSet lockFiles;
|
||||
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)) {
|
||||
worker.waitForAWhile(shared_from_this());
|
||||
|
@ -1429,7 +1429,7 @@ void DerivationGoal::tryToBuild()
|
|||
for (auto & i : drv->outputs) {
|
||||
if (worker.store.isValidPath(i.second.path)) continue;
|
||||
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
|
||||
|
@ -1686,7 +1686,7 @@ void DerivationGoal::buildDone()
|
|||
|
||||
/* Delete unused redirected outputs (when doing hash rewriting). */
|
||||
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). */
|
||||
autoDelChroot.reset(); /* this runs the destructor */
|
||||
|
@ -2072,7 +2072,7 @@ void DerivationGoal::startBuilder()
|
|||
environment using bind-mounts. We put it in the Nix store
|
||||
to ensure that we can create hard-links to non-directory
|
||||
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);
|
||||
|
||||
/* Clean up the chroot directory automatically. */
|
||||
|
@ -2917,7 +2917,7 @@ void DerivationGoal::addDependency(const StorePath & path)
|
|||
|
||||
#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);
|
||||
debug("bind-mounting %s -> %s", target, source);
|
||||
|
||||
|
@ -3579,7 +3579,7 @@ void DerivationGoal::registerOutputs()
|
|||
if (needsHashRewrite()) {
|
||||
auto r = redirectedOutputs.find(i.second.path);
|
||||
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
|
||||
&& redirectedBadOutputs.count(i.second.path)
|
||||
&& pathExists(redirected))
|
||||
|
@ -3672,7 +3672,7 @@ void DerivationGoal::registerOutputs()
|
|||
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)));
|
||||
|
||||
Path actualDest = worker.store.toRealPath(worker.store.printStorePath(dest));
|
||||
Path actualDest = worker.store.Store::toRealPath(dest);
|
||||
|
||||
if (worker.store.isValidPath(dest))
|
||||
std::rethrow_exception(delayedException);
|
||||
|
|
|
@ -354,7 +354,7 @@ Hash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutput
|
|||
if (h == drvHashes.end()) {
|
||||
assert(store.isValidPath(i.first));
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -910,7 +910,7 @@ CachedDownloadResult Downloader::downloadCached(
|
|||
printInfo("unpacking '%s'...", url);
|
||||
Path tmpDir = createTempDir();
|
||||
AutoDelete autoDelete(tmpDir, true);
|
||||
unpackTarfile(store->toRealPath(store->printStorePath(*storePath)), tmpDir);
|
||||
unpackTarfile(store->toRealPath(*storePath), tmpDir);
|
||||
auto members = readDirectory(tmpDir);
|
||||
if (members.size() != 1)
|
||||
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) {
|
||||
unsigned int statusCode = 102;
|
||||
Hash gotHash = request.unpack
|
||||
? hashPath(request.expectedHash.type, store->toRealPath(store->printStorePath(*storePath))).first
|
||||
: hashFile(request.expectedHash.type, store->toRealPath(store->printStorePath(*storePath)));
|
||||
? hashPath(request.expectedHash.type, store->toRealPath(*storePath)).first
|
||||
: hashFile(request.expectedHash.type, store->toRealPath(*storePath));
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ std::pair<Tree, std::shared_ptr<const Input>> Input::fetchTree(ref<Store> store)
|
|||
auto [tree, input] = fetchTreeInternal(store);
|
||||
|
||||
if (tree.actualPath == "")
|
||||
tree.actualPath = store->toRealPath(store->printStorePath(tree.storePath));
|
||||
tree.actualPath = store->toRealPath(tree.storePath);
|
||||
|
||||
if (!tree.info.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)) {
|
||||
return {{rev, Tree{
|
||||
.actualPath = store->toRealPath(store->printStorePath(storePath)),
|
||||
.actualPath = store->toRealPath(storePath),
|
||||
.storePath = std::move(storePath),
|
||||
.info = TreeInfo {
|
||||
.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 tree = Tree {
|
||||
.actualPath = store->toRealPath(store->printStorePath(storePath)),
|
||||
.actualPath = store->toRealPath(storePath),
|
||||
.storePath = std::move(storePath),
|
||||
.info = TreeInfo {
|
||||
.revCount = revCount,
|
||||
|
|
|
@ -1263,7 +1263,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
|
|||
else
|
||||
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();
|
||||
|
||||
if (info->narHash != nullHash && info->narHash != current.first) {
|
||||
|
|
|
@ -656,6 +656,11 @@ public:
|
|||
return storePath;
|
||||
}
|
||||
|
||||
Path toRealPath(const StorePath & storePath)
|
||||
{
|
||||
return toRealPath(printStorePath(storePath));
|
||||
}
|
||||
|
||||
virtual void createUser(const std::string & userName, uid_t userId)
|
||||
{ }
|
||||
|
||||
|
|
Loading…
Reference in a new issue