chromium: Split up the source tarball on the fly.

So far we've done the source code split up by using the generic
unpackPhase and copying it all over into the different outputs.

However, this had the problem of generating the I/O load of about three
times the size of the source tree: First at fetchurl of the tarball
(although it's not as much because it's compressed), second at
unpackPhase and third at installPhase.

Now we don't use installPhase anymore and directly unpack into the
output paths, which unfortunately becomes quite a bit more complex
because we need to transform the paths of the tar file on the fly.

I've also tried using GNU Tar's --to-command option to even untar *and*
patch it at the same time, but forking for every single file in the
tarball gets REALLY slow and also gets even more complex than this two
stage approach because you need to make sure that the patch file is
applied correctly, for example for files that don't yet exist but are to
be created by the patch file.

We're using --anchored and --no-wildcards-match-slash here to prevent
accidentally excluding files we don't want to exclude. One example is
something like v8/tools/gyp/v8.gyp.

So the current approach is some compromise between complexity and speed
and should hopefully get rid of the Hydra build timeouts by lowering I/O
load.

See here for examples of builds having this issue:

http://hydra.nixos.org/build/19045023
http://hydra.nixos.org/build/19044973
http://hydra.nixos.org/build/19044968
http://hydra.nixos.org/build/19045019

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2015-02-07 04:58:02 +01:00
parent 0aad4b7ee4
commit c92dbffeac
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -10,7 +10,16 @@ with (import ./update.nix {
}).getChannel channel;
let
transform = flags: concatStringsSep ";" (map (subst: subst + flags) [
"s,^[^/]+(.*)$,$main\\1,"
"s,$main/(build|tools)(/.*)?$,$out/\\1\\2,"
"s,$main/third_party(/.*)?$,$bundled\\1,"
"s,$main/sandbox(/.*)?$,$sandbox\\1,"
"s,^/,,"
]);
pre42 = versionOlder version "42.0.0.0";
in stdenv.mkDerivation {
name = "chromium-source-${version}";
@ -18,11 +27,25 @@ in stdenv.mkDerivation {
buildInputs = [ python ]; # cannot patch shebangs otherwise
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
phases = [ "unpackPhase" "patchPhase" ];
outputs = [ "out" "sandbox" "bundled" "main" ];
unpackPhase = ''
tar xf "$src" -C / \
--transform="${transform "xS"}" \
--anchored \
--no-wildcards-match-slash \
--exclude='*/tools/gyp' \
--exclude='*/.*'
'';
opensslPatches = optional useOpenSSL openssl.patches;
prePatch = "patchShebangs .";
prePatch = ''
for i in $outputs; do
eval patchShebangs "\$$i"
done
'';
patches = if pre42 then [
./sandbox_userns_36.patch ./nix_plugin_paths.patch
@ -30,48 +53,33 @@ in stdenv.mkDerivation {
./nix_plugin_paths_42.patch
];
patchPhase = let
diffmod = sym: "/^${sym} /{s/^${sym} //;${transform ""};s/^/${sym} /}";
allmods = "${diffmod "---"};${diffmod "\\+\\+\\+"}";
sedexpr = "/^(---|\\+\\+\\+) *\\/dev\\/null/b;${allmods}";
in ''
runHook prePatch
for i in $patches; do
header "applying patch $i" 3
sed -r -e "${sedexpr}" "$i" | patch -d / -p0
stopNest
done
runHook postPatch
'';
postPatch = ''
sed -i -r \
-e 's/-f(stack-protector)(-all)?/-fno-\1/' \
-e 's|/bin/echo|echo|' \
-e "/python_arch/s/: *'[^']*'/: '""'/" \
build/common.gypi chrome/chrome_tests.gypi
"$out/build/common.gypi" "$main/chrome/chrome_tests.gypi"
'' + optionalString useOpenSSL ''
cat $opensslPatches | patch -p1 -d third_party/openssl/openssl
cat $opensslPatches | patch -p1 -d "$bundled/openssl/openssl"
'' + optionalString (!pre42) ''
sed -i -e '/LOG.*no_suid_error/d' \
"$main/content/browser/browser_main_loop.cc"
'';
outputs = [ "out" "sandbox" "bundled" "main" ];
installPhase = ''
mkdir -p "$out" "$sandbox" "$bundled" "$main"
header "copying browser main sources to $main"
find . -mindepth 1 -maxdepth 1 \
\! -path ./sandbox \
\! -path ./third_party \
\! -path ./build \
\! -path ./tools \
\! -name '.*' \
-print | xargs cp -rt "$main"
stopNest
header "copying sandbox components to $sandbox"
cp -rt "$sandbox" sandbox/*
stopNest
header "copying third party sources to $bundled"
cp -rt "$bundled" third_party/*
stopNest
header "copying build requisites to $out"
cp -rt "$out" build tools
stopNest
rm -rf "$out/tools/gyp" # XXX: Don't even copy it in the first place.
'';
passthru = {
inherit version channel;
plugins = fetchurl binary;