Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Chromium from source #14

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
75edcc3
chromium: Minimal build (no install) from source.
aszlig Jun 12, 2012
38ddc6c
chromium: Add an install phase.
aszlig Jun 15, 2012
35f7534
chromium: Add an update script.
aszlig Jun 15, 2012
41fecca
chromium: Generate the latest source.nix.
aszlig Jun 15, 2012
7bba9f2
chromium: Clean up build flags.
aszlig Jun 15, 2012
d422878
chromium: Enable seccomp by default.
aszlig Jun 15, 2012
38a52c8
chromium: Add "which" to build dependencies.
aszlig Jun 19, 2012
8df530c
chromium: Use system libraries whenever possible.
aszlig Jun 19, 2012
82cb39f
chromium: Rename "chrome" binary to "chromium".
aszlig Jun 19, 2012
67ea999
chromium: Use patches from system OpenSSL.
aszlig Jun 19, 2012
498f598
chromium: Allow to switch off openssl support.
aszlig Jun 19, 2012
93abd07
chromium: Add flag to disable Gnome support.
aszlig Jun 19, 2012
6379245
chromium: Add mesa to build dependencies.
aszlig Jun 20, 2012
e6b64fb
chromium: Update source to version 21.0.1179.1.
aszlig Jun 20, 2012
d44d4c6
chromium: Implement handling of enableCUPS.
aszlig Jun 20, 2012
c53c0ef
chromium: Enable proprietary codecs by default.
aszlig Jun 20, 2012
e60ba92
chromium: Add dependency for libselinux.
aszlig Jun 20, 2012
301fe5d
chromium: Cleanup dependencies.
aszlig Jun 20, 2012
8e3be37
chromium: Use bundled versions of some libraries.
aszlig Jun 20, 2012
3ca9701
chromium: Simplify names of getConfig options.
aszlig Jun 20, 2012
652b887
chromium: Add support for pulseaudio.
aszlig Jun 20, 2012
a8befd7
chromium: Enable parallel building.
aszlig Jun 21, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/printing/printing.gyp b/printing/printing.gyp
index 19fa1b2..f11d76e 100644
--- a/printing/printing.gyp
+++ b/printing/printing.gyp
@@ -26,6 +26,9 @@
'include_dirs': [
'..',
],
+ 'cflags': [
+ '-Wno-deprecated-declarations',
+ ],
'sources': [
'backend/print_backend.cc',
'backend/print_backend.h',
233 changes: 179 additions & 54 deletions pkgs/applications/networking/browsers/chromium/default.nix
Original file line number Diff line number Diff line change
@@ -1,62 +1,187 @@
{ GConf, alsaLib, bzip2, cairo, cups, dbus, dbus_glib, expat
, fetchurl, ffmpeg, fontconfig, freetype, libX11, libXfixes
, glib, gtk, gdk_pixbuf, pango
, libXScrnSaver, libXdamage, libXext, libXrender, libXt, libXtst, libXcomposite
, libgcrypt, libjpeg, libpng, makeWrapper, nspr, nss, patchelf
, stdenv, unzip, zlib, pam, pcre, udev }:

assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux" ;

stdenv.mkDerivation rec {
name = "chromium-19.0.1061.0-pre${version}";

# To determine the latest revision, get
# ‘http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/LAST_CHANGE’.
# For the version number, see ‘about:version’.
version = "124950";

src =
if stdenv.system == "x86_64-linux" then
fetchurl {
url = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux_x64/${version}/chrome-linux.zip";
sha256 = "4472bf584a96e477e2c17f96d4452dd41f4f34ac3d6a9bb4c845cf15d8db0c73";
}
else if stdenv.system == "i686-linux" then
fetchurl {
url = "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux/${version}/chrome-linux.zip";
sha256 = "6e8a49d9917ee26b67d14cd10b85711c3b9382864197ba02b3cfe8e636d3d69c";
}
else throw "Chromium is not supported on this platform.";

phases = "unpackPhase installPhase";

buildInputs = [ makeWrapper unzip ];

libPath =
stdenv.lib.makeLibraryPath
[ GConf alsaLib bzip2 cairo cups dbus dbus_glib expat
ffmpeg fontconfig freetype libX11 libXScrnSaver libXfixes libXcomposite
libXdamage libXext libXrender libXt libXtst libgcrypt libjpeg
libpng nspr stdenv.gcc.gcc zlib stdenv.gcc.libc
glib gtk gdk_pixbuf pango
pam udev
];
{ stdenv, getConfig, fetchurl, makeWrapper, which

# default dependencies
, bzip2, flac, speex
, libevent, expat, libjpeg
, libpng, libxml2, libxslt
, xdg_utils, yasm, zlib

, python, perl, pkgconfig
, nspr, udev, krb5
, utillinux, alsaLib
, gcc, bison, gperf
, glib, gtk, dbus_glib
, libXScrnSaver, libXcursor, mesa

# optional dependencies
, libgnome_keyring # config.gnomeKeyring
, gconf # config.gnome
, libgcrypt # config.gnome || config.cups
, nss, openssl # config.openssl
, pulseaudio # config.pulseaudio
, libselinux # config.selinux
}:

let
mkConfigurable = stdenv.lib.mapAttrs (flag: default: getConfig ["chromium" flag] default);

config = mkConfigurable {
selinux = false;
nacl = false;
openssl = true;
gnome = false;
gnomeKeyring = false;
proprietaryCodecs = true;
cups = false;
pulseaudio = getConfig ["pulseaudio"] true;
};

sourceInfo = import ./source.nix;

mkGypFlags = with stdenv.lib; let
sanitize = value:
if value == true then "1"
else if value == false then "0"
else "${value}";
toFlag = key: value: "-D${key}=${sanitize value}";
in attrs: concatStringsSep " " (attrValues (mapAttrs toFlag attrs));

gypFlagsUseSystemLibs = {
use_system_bzip2 = true;
use_system_flac = true;
use_system_libevent = true;
use_system_libexpat = true;
use_system_libjpeg = true;
use_system_libpng = true;
use_system_libxml = true;
use_system_speex = true;
use_system_ssl = true;
use_system_stlport = true;
use_system_xdg_utils = true;
use_system_yasm = true;
use_system_zlib = true;

use_system_harfbuzz = false;
use_system_icu = false;
use_system_libwebp = false; # See chromium issue #133161
use_system_skia = false;
use_system_sqlite = false; # See chromium issue #22208
use_system_v8 = false;
};

defaultDependencies = [
bzip2 flac speex
libevent expat libjpeg
libpng libxml2 libxslt
xdg_utils yasm zlib
];

in stdenv.mkDerivation rec {
name = "${packageName}-${version}";
packageName = "chromium";

version = sourceInfo.version;

src = fetchurl {
url = sourceInfo.url;
sha256 = sourceInfo.sha256;
};

buildInputs = defaultDependencies ++ [
which makeWrapper
python perl pkgconfig
nspr udev
(if config.openssl then openssl else nss)
utillinux alsaLib
gcc bison gperf
krb5
glib gtk dbus_glib
libXScrnSaver libXcursor mesa
] ++ stdenv.lib.optional config.gnomeKeyring libgnome_keyring
++ stdenv.lib.optionals config.gnome [ gconf libgcrypt ]
++ stdenv.lib.optional config.selinux libselinux
++ stdenv.lib.optional config.cups libgcrypt
++ stdenv.lib.optional config.pulseaudio pulseaudio;

opensslPatches = stdenv.lib.optional config.openssl openssl.patches;

prePatch = "patchShebangs .";

patches = stdenv.lib.optional (!config.selinux) ./enable_seccomp.patch
++ stdenv.lib.optional config.cups ./cups_allow_deprecated.patch
++ stdenv.lib.optional config.pulseaudio ./pulseaudio_array_bounds.patch;

postPatch = stdenv.lib.optionalString config.openssl ''
cat $opensslPatches | patch -p1 -d third_party/openssl/openssl
'';

gypFlags = mkGypFlags (gypFlagsUseSystemLibs // {
linux_use_gold_binary = false;
linux_use_gold_flags = false;
proprietary_codecs = false;
use_gnome_keyring = config.gnomeKeyring;
use_gconf = config.gnome;
use_gio = config.gnome;
use_pulseaudio = config.pulseaudio;
disable_nacl = !config.nacl;
use_openssl = config.openssl;
selinux = config.selinux;
use_cups = config.cups;
} // stdenv.lib.optionalAttrs config.proprietaryCodecs {
# enable support for the H.264 codec
proprietary_codecs = true;
ffmpeg_branding = "Chrome";
} // stdenv.lib.optionalAttrs (stdenv.system == "x86_64-linux") {
target_arch = "x64";
} // stdenv.lib.optionalAttrs (stdenv.system == "i686-linux") {
target_arch = "ia32";
});

buildType = "Release";

enableParallelBuilding = true;

configurePhase = ''
python build/gyp_chromium --depth "$(pwd)" ${gypFlags}
'';

makeFlags = let
CC = "${gcc}/bin/gcc";
CXX = "${gcc}/bin/g++";
in [
"CC=${CC}"
"CXX=${CXX}"
"CC.host=${CC}"
"CXX.host=${CXX}"
"LINK.host=${CXX}"
];

buildFlags = [
"BUILDTYPE=${buildType}"
"library=shared_library"
"chrome"
];

installPhase = ''
mkdir -p $out/bin
mkdir -p $out/libexec/chrome
mkdir -vp "$out/libexec/${packageName}"
cp -v "out/${buildType}/"*.pak "$out/libexec/${packageName}/"
cp -vR "out/${buildType}/locales" "out/${buildType}/resources" "$out/libexec/${packageName}/"

cp -v "out/${buildType}/chrome" "$out/libexec/${packageName}/${packageName}"

cp -R * $out/libexec/chrome
mkdir -vp "$out/bin"
makeWrapper "$out/libexec/${packageName}/${packageName}" "$out/bin/${packageName}"

strip $out/libexec/chrome/chrome

${patchelf}/bin/patchelf \
--interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
--set-rpath ${libPath}:$out/lib:${stdenv.gcc.gcc}/lib64:${stdenv.gcc.gcc}/lib \
$out/libexec/chrome/chrome
mkdir -vp "$out/share/man/man1"
cp -v "out/${buildType}/chrome.1" "$out/share/man/man1/${packageName}.1"

makeWrapper $out/libexec/chrome/chrome $out/bin/chrome \
--prefix LD_LIBRARY_PATH : "${pcre}/lib:${nss}/lib"
for icon_file in chrome/app/theme/chromium/product_logo_*[0-9].png; do
num_and_suffix="''${icon_file##*logo_}"
icon_size="''${num_and_suffix%.*}"
logo_output_path="$out/share/icons/hicolor/''${icon_size}x''${icon_size}/apps"
mkdir -vp "$logo_output_path"
cp -v "$icon_file" "$logo_output_path/${packageName}.png"
done
'';

meta = with stdenv.lib; {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/content/common/seccomp_sandbox.h b/content/common/seccomp_sandbox.h
index a07d6f3..a622a35 100644
--- a/content/common/seccomp_sandbox.h
+++ b/content/common/seccomp_sandbox.h
@@ -29,15 +29,9 @@ static bool SeccompSandboxEnabled() {
// TODO(evan): turn on for release too once we've flushed out all the bugs,
// allowing us to delete this file entirely and just rely on the "disabled"
// switch.
-#ifdef NDEBUG
- // Off by default; allow turning on with a switch.
- return CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableSeccompSandbox);
-#else
// On by default; allow turning off with a switch.
return !CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableSeccompSandbox);
-#endif // NDEBUG
}
#endif // SECCOMP_SANDBOX

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/media/media.gyp b/media/media.gyp
index 2a8c6c6..66ca767 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -399,6 +399,7 @@
['use_pulseaudio == 1', {
'cflags': [
'<!@(pkg-config --cflags libpulse)',
+ '-Wno-array-bounds',
],
'link_settings': {
'libraries': [
5 changes: 5 additions & 0 deletions pkgs/applications/networking/browsers/chromium/source.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
version = "21.0.1179.1";
url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-21.0.1179.1.tar.bz2";
sha256 = "1ynm1dv8nwjg6a0absid1g3r62y0mpb74pmal8g9nmqb92rlkdnc";
}
34 changes: 34 additions & 0 deletions pkgs/applications/networking/browsers/chromium/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

bucket_url="http://commondatastorage.googleapis.com/chromium-browser-official/";

get_newest_version()
{
curl -s "$bucket_url" | sed -ne ' H;/<[Kk][Ee][Yy]>chromium-[^<]*</h;${
g;s/^.*<Key>chromium-\([^<.]\+\(\.[^<.]\+\)\+\)\.tar\.bz2<.*$/\1/p
}';
}

cd "$(dirname "$0")";

version="$(get_newest_version)";

if [ -e source.nix ]; then
oldver="$(sed -n 's/^ *version *= *"\([^"]\+\)".*$/\1/p' source.nix)";
if [ "x$oldver" = "x$version" ]; then
echo "Already the newest version: $version" >&2;
exit 1;
fi;
fi;

url="${bucket_url%/}/chromium-$version.tar.bz2";

sha256="$(nix-prefetch-url "$url")";

cat > source.nix <<EOF
{
version = "$version";
url = "$url";
sha256 = "$sha256";
}
EOF
9 changes: 4 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6328,14 +6328,13 @@ let
xulrunner = firefox36Pkgs.xulrunner;
};

chrome = lowPrio (callPackage ../applications/networking/browsers/chromium {
inherit (gnome) GConf;
libpng = libpng12;
chromium = lowPrio (callPackage ../applications/networking/browsers/chromium {
gconf = gnome.GConf;
});

chromeWrapper = wrapFirefox
{ browser = chrome; browserName = "chrome"; desktopName = "Chrome";
icon = "${chrome}/libexec/chrome/product_logo_48.png";
{ browser = chromium; browserName = chromium.packageName; desktopName = "Chromium";
icon = "${chromium}/share/icons/hicolor/48x48/apps/${chromium.packageName}.png";
};

cinelerra = callPackage ../applications/video/cinelerra { };
Expand Down