mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge 1b2c828d57
into aa1629ca35
This commit is contained in:
commit
cbfa28f339
5 changed files with 271 additions and 50 deletions
|
@ -105,14 +105,8 @@ protected:
|
|||
/**
|
||||
* Stuff we need to pass to initChild().
|
||||
*/
|
||||
struct ChrootPath {
|
||||
Path source;
|
||||
bool optional;
|
||||
ChrootPath(Path source = "", bool optional = false)
|
||||
: source(source), optional(optional)
|
||||
{ }
|
||||
};
|
||||
typedef std::map<Path, ChrootPath> PathsInChroot; // maps target path to source path
|
||||
|
||||
typedef SandboxPaths PathsInChroot;
|
||||
|
||||
typedef StringMap Environment;
|
||||
Environment env;
|
||||
|
@ -849,24 +843,14 @@ DerivationBuilderImpl::PathsInChroot DerivationBuilderImpl::getPathsInSandbox()
|
|||
|
||||
/* Allow a user-configurable set of directories from the
|
||||
host file system. */
|
||||
for (auto i : settings.sandboxPaths.get()) {
|
||||
if (i.empty()) continue;
|
||||
bool optional = false;
|
||||
if (i[i.size() - 1] == '?') {
|
||||
optional = true;
|
||||
i.pop_back();
|
||||
}
|
||||
size_t p = i.find('=');
|
||||
if (p == std::string::npos)
|
||||
pathsInChroot[i] = {i, optional};
|
||||
else
|
||||
pathsInChroot[i.substr(0, p)] = {i.substr(p + 1), optional};
|
||||
}
|
||||
for (const auto & [k, v] : settings.sandboxPaths.get())
|
||||
pathsInChroot.insert_or_assign(k, v);
|
||||
|
||||
if (hasPrefix(store.storeDir, tmpDirInSandbox()))
|
||||
{
|
||||
throw Error("`sandbox-build-dir` must not contain the storeDir");
|
||||
}
|
||||
pathsInChroot[tmpDirInSandbox()] = tmpDir;
|
||||
pathsInChroot.insert_or_assign(tmpDirInSandbox(), tmpDir);
|
||||
|
||||
/* Add the closure of store paths to the chroot. */
|
||||
StorePathSet closure;
|
||||
|
@ -936,11 +920,8 @@ DerivationBuilderImpl::PathsInChroot DerivationBuilderImpl::getPathsInSandbox()
|
|||
if (line == "") {
|
||||
state = stBegin;
|
||||
} else {
|
||||
auto p = line.find('=');
|
||||
if (p == std::string::npos)
|
||||
pathsInChroot[line] = line;
|
||||
else
|
||||
pathsInChroot[line.substr(0, p)] = line.substr(p + 1);
|
||||
for (const auto & [k, v] : SandboxPath::parse(line, "extra-sandbox-paths (via pre-build-hook)"))
|
||||
pathsInChroot.try_emplace(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue