mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-01-19 09:36:47 +02:00
Use std::filesystem::path
in profile.cc
...
...and `run.cc`
This commit is contained in:
parent
0abc664a78
commit
8e70f6f850
2 changed files with 13 additions and 12 deletions
|
@ -122,9 +122,9 @@ struct ProfileManifest
|
||||||
|
|
||||||
ProfileManifest() { }
|
ProfileManifest() { }
|
||||||
|
|
||||||
ProfileManifest(EvalState & state, const Path & profile)
|
ProfileManifest(EvalState & state, const std::filesystem::path & profile)
|
||||||
{
|
{
|
||||||
auto manifestPath = profile + "/manifest.json";
|
auto manifestPath = profile / "manifest.json";
|
||||||
|
|
||||||
if (pathExists(manifestPath)) {
|
if (pathExists(manifestPath)) {
|
||||||
auto json = nlohmann::json::parse(readFile(manifestPath));
|
auto json = nlohmann::json::parse(readFile(manifestPath));
|
||||||
|
@ -176,12 +176,12 @@ struct ProfileManifest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (pathExists(profile + "/manifest.nix")) {
|
else if (pathExists(profile / "manifest.nix")) {
|
||||||
// FIXME: needed because of pure mode; ugly.
|
// FIXME: needed because of pure mode; ugly.
|
||||||
state.allowPath(state.store->followLinksToStore(profile));
|
state.allowPath(state.store->followLinksToStore(profile.string()));
|
||||||
state.allowPath(state.store->followLinksToStore(profile + "/manifest.nix"));
|
state.allowPath(state.store->followLinksToStore((profile / "manifest.nix").string()));
|
||||||
|
|
||||||
auto packageInfos = queryInstalled(state, state.store->followLinksToStore(profile));
|
auto packageInfos = queryInstalled(state, state.store->followLinksToStore(profile.string()));
|
||||||
|
|
||||||
for (auto & packageInfo : packageInfos) {
|
for (auto & packageInfo : packageInfos) {
|
||||||
ProfileElement element;
|
ProfileElement element;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "source-accessor.hh"
|
#include "source-accessor.hh"
|
||||||
#include "progress-bar.hh"
|
#include "progress-bar.hh"
|
||||||
#include "eval.hh"
|
#include "eval.hh"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#if __linux__
|
#if __linux__
|
||||||
# include <sys/mount.h>
|
# include <sys/mount.h>
|
||||||
|
@ -169,7 +170,7 @@ void chrootHelper(int argc, char * * argv)
|
||||||
if (!pathExists(storeDir)) {
|
if (!pathExists(storeDir)) {
|
||||||
// FIXME: Use overlayfs?
|
// FIXME: Use overlayfs?
|
||||||
|
|
||||||
Path tmpDir = createTempDir();
|
std::filesystem::path tmpDir = createTempDir();
|
||||||
|
|
||||||
createDirs(tmpDir + storeDir);
|
createDirs(tmpDir + storeDir);
|
||||||
|
|
||||||
|
@ -178,16 +179,16 @@ void chrootHelper(int argc, char * * argv)
|
||||||
|
|
||||||
for (auto entry : std::filesystem::directory_iterator{"/"}) {
|
for (auto entry : std::filesystem::directory_iterator{"/"}) {
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
auto src = entry.path().string();
|
auto src = entry.path();
|
||||||
Path dst = tmpDir + "/" + entry.path().filename().string();
|
Path dst = tmpDir / entry.path().filename();
|
||||||
if (pathExists(dst)) continue;
|
if (pathExists(dst)) continue;
|
||||||
auto st = lstat(src);
|
auto st = entry.symlink_status();
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (std::filesystem::is_directory(st)) {
|
||||||
if (mkdir(dst.c_str(), 0700) == -1)
|
if (mkdir(dst.c_str(), 0700) == -1)
|
||||||
throw SysError("creating directory '%s'", dst);
|
throw SysError("creating directory '%s'", dst);
|
||||||
if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1)
|
if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, 0) == -1)
|
||||||
throw SysError("mounting '%s' on '%s'", src, dst);
|
throw SysError("mounting '%s' on '%s'", src, dst);
|
||||||
} else if (S_ISLNK(st.st_mode))
|
} else if (std::filesystem::is_symlink(st))
|
||||||
createSymlink(readLink(src), dst);
|
createSymlink(readLink(src), dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue