Add the closure of store paths to the chroot

Thus, for example, to get /bin/sh in a chroot, you only need to
specify /bin/sh=${pkgs.bash}/bin/sh in build-chroot-dirs. The
dependencies of sh will be added automatically.
This commit is contained in:
Eelco Dolstra 2015-03-24 11:50:22 +01:00
parent 5ce50cd99e
commit fd89f97be9
2 changed files with 11 additions and 4 deletions

View file

@ -95,11 +95,10 @@ let
# Provide a default value for the build-chroot-dirs setting # Provide a default value for the build-chroot-dirs setting
# that includes /bin/sh pointing to bash. # that includes /bin/sh pointing to bash.
preHook = lib.optionalString stdenv.isLinux ( preHook = lib.optionalString stdenv.isLinux
let sh = stdenv.shell; in
'' ''
export DEFAULT_CHROOT_DIRS="/bin/sh=${sh} $(tr '\n' ' ' < ${writeReferencesToFile sh})" export DEFAULT_CHROOT_DIRS="/bin/sh=${stdenv.shell}"
''); '';
enableParallelBuilding = true; enableParallelBuilding = true;

View file

@ -1799,6 +1799,14 @@ void DerivationGoal::startBuilder()
} }
dirsInChroot[tmpDir] = tmpDir; dirsInChroot[tmpDir] = tmpDir;
/* Add the closure of store paths to the chroot. */
PathSet closure;
for (auto & i : dirsInChroot)
if (isInStore(i.second))
computeFSClosure(worker.store, toStorePath(i.second), closure);
for (auto & i : closure)
dirsInChroot[i] = i;
string allowed = settings.get("allowed-impure-host-deps", string(DEFAULT_ALLOWED_IMPURE_PREFIXES)); string allowed = settings.get("allowed-impure-host-deps", string(DEFAULT_ALLOWED_IMPURE_PREFIXES));
PathSet allowedPaths = tokenizeString<StringSet>(allowed); PathSet allowedPaths = tokenizeString<StringSet>(allowed);