Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3913afdd69a5
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f7ce80f90ab3
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 27, 2019

  1. Copy the full SHA
    f1c0b2c View commit details
  2. Factor out linkOrCopy()

    edolstra committed Oct 27, 2019
    Copy the full SHA
    f7ce80f View commit details
Showing with 28 additions and 16 deletions.
  1. +17 −16 src/libstore/build.cc
  2. +9 −0 src/libutil/archive.cc
  3. +2 −0 src/libutil/archive.hh
33 changes: 17 additions & 16 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
@@ -1874,6 +1874,21 @@ static void preloadNSS() {
});
}


void linkOrCopy(const Path & from, const Path & to)
{
if (link(from.c_str(), to.c_str()) == -1) {
/* Hard-linking fails if we exceed the maximum link count on a
file (e.g. 32000 of ext3), which is quite possible after a
'nix-store --optimise'. FIXME: actually, why don't we just
bind-mount in this case? */
if (errno != EMLINK)
throw SysError("linking '%s' to '%s'", to, from);
copyPath(from, to);
}
}


void DerivationGoal::startBuilder()
{
/* Right platform? */
@@ -2117,22 +2132,8 @@ void DerivationGoal::startBuilder()
throw SysError(format("getting attributes of path '%1%'") % i);
if (S_ISDIR(st.st_mode))
dirsInChroot[i] = r;
else {
Path p = chrootRootDir + i;
debug("linking '%1%' to '%2%'", p, r);
if (link(r.c_str(), p.c_str()) == -1) {
/* Hard-linking fails if we exceed the maximum
link count on a file (e.g. 32000 of ext3),
which is quite possible after a `nix-store
--optimise'. */
if (errno != EMLINK)
throw SysError(format("linking '%1%' to '%2%'") % p % i);
StringSink sink;
dumpPath(r, sink);
StringSource source(*sink.s);
restorePath(p, source);
}
}
else
linkOrCopy(r, chrootRootDir + i);
}

/* If we're repairing, checking or rebuilding part of a
9 changes: 9 additions & 0 deletions src/libutil/archive.cc
Original file line number Diff line number Diff line change
@@ -375,4 +375,13 @@ void copyNAR(Source & source, Sink & sink)
}


void copyPath(const Path & from, const Path & to)
{
auto source = sinkToSource([&](Sink & sink) {
dumpPath(from, sink);
});
restorePath(to, *source);
}


}
2 changes: 2 additions & 0 deletions src/libutil/archive.hh
Original file line number Diff line number Diff line change
@@ -77,6 +77,8 @@ void restorePath(const Path & path, Source & source);
/* Read a NAR from 'source' and write it to 'sink'. */
void copyNAR(Source & source, Sink & sink);

void copyPath(const Path & from, const Path & to);


extern const std::string narVersionMagic1;