chromium: Add support for ppapi flash and PDF.

This is hardcoded for the dev channel at the moment and we're going to
fetch it along with the main Chromium sources.

Also I'm putting this in default.nix at the moment, because we're going
to tear apart the whole Chromium package into several subparts soon.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-03-19 11:32:39 +01:00
parent 5e95ae5e88
commit c2abe4da6c
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961
1 changed files with 72 additions and 2 deletions

View File

@ -26,6 +26,8 @@
, gnomeSupport ? false, gconf ? null , gnomeSupport ? false, gconf ? null
, gnomeKeyringSupport ? false, libgnome_keyring3 ? null , gnomeKeyringSupport ? false, libgnome_keyring3 ? null
, proprietaryCodecs ? true , proprietaryCodecs ? true
, enablePepperFlash ? false
, enablePepperPDF ? false
, cupsSupport ? false , cupsSupport ? false
, pulseSupport ? false, pulseaudio ? null , pulseSupport ? false, pulseaudio ? null
}: }:
@ -151,6 +153,68 @@ let
binary = "${packageName}_sandbox"; binary = "${packageName}_sandbox";
}; };
binaryPlugins = stdenv.mkDerivation {
name = "chromium-binary-plugins";
# XXX: Only temporary and has to be version-specific
src = fetchurl {
url = "https://dl.google.com/linux/chrome/deb/pool/main/g/"
+ "google-chrome-unstable/google-chrome-unstable_"
+ "35.0.1897.2-1_amd64.deb";
sha1 = "b68683fc5321d10536e4135c266b14894b7668ed";
};
phases = [ "unpackPhase" "patchPhase" "checkPhase" "installPhase" ];
outputs = [ "pdf" "flash" ];
unpackCmd = ''
ensureDir plugins
ar p "$src" data.tar.lzma | tar xJ -C plugins --strip-components=4 \
./opt/google/chrome-unstable/PepperFlash \
./opt/google/chrome-unstable/libpdf.so
'';
doCheck = true;
checkPhase = ''
! find -iname '*.so' -exec ldd {} + | grep 'not found'
'';
patchPhase = let
rpaths = [ stdenv.gcc.gcc ];
mkrpath = p: "${makeSearchPath "lib64" p}:${makeSearchPath "lib" p}";
in ''
for sofile in PepperFlash/libpepflashplayer.so libpdf.so; do
chmod +x "$sofile"
patchelf --set-rpath "${mkrpath rpaths}" "$sofile"
done
'';
installPhase = let
pdfName = "Chrome PDF Viewer";
pdfDescription = "Portable Document Format";
pdfMimeTypes = concatStringsSep ";" [
"application/pdf"
"application/x-google-chrome-print-preview-pdf"
];
pdfInfo = "#${pdfName}#${pdfDescription};${pdfMimeTypes}";
in ''
install -vD libpdf.so "$pdf/lib/libpdf.so"
ensureDir "$pdf/nix-support"
echo "--register-pepper-plugins='$pdf/lib/libpdf.so${pdfInfo}'" \
> "$pdf/nix-support/chromium-flags"
flashVersion="$(
sed -n -r 's/.*"version": "([^"]+)",.*/\1/p' PepperFlash/manifest.json
)"
install -vD libpepflashplayer.so "$flash/lib/libpepflashplayer.so"
ensureDir "$flash/nix-support"
echo "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'" \
"--ppapi-flash-version=$flashVersion" \
> "$flash/nix-support/chromium-flags"
'';
};
# build paths and release info # build paths and release info
packageName = "chromium"; packageName = "chromium";
buildType = "Release"; buildType = "Release";
@ -248,7 +312,12 @@ in stdenv.mkDerivation rec {
chrome ${optionalString (!enableSELinux) "chrome_sandbox"} chrome ${optionalString (!enableSELinux) "chrome_sandbox"}
''; '';
installPhase = '' installPhase = let
enabledPlugins = optional enablePepperFlash binaryPlugins.flash
++ optional enablePepperPDF binaryPlugins.pdf;
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
pluginArgs = concatStringsSep " " (map getFlags enabledPlugins);
in ''
ensureDir "${libExecPath}" ensureDir "${libExecPath}"
cp -v "${buildPath}/"*.pak "${libExecPath}/" cp -v "${buildPath}/"*.pak "${libExecPath}/"
${optionalString (!versionOlder src.version "34.0.0.0") '' ${optionalString (!versionOlder src.version "34.0.0.0") ''
@ -260,7 +329,8 @@ in stdenv.mkDerivation rec {
cp -v "${buildPath}/chrome" "${libExecPath}/${packageName}" cp -v "${buildPath}/chrome" "${libExecPath}/${packageName}"
mkdir -vp "$out/bin" mkdir -vp "$out/bin"
makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" makeWrapper "${libExecPath}/${packageName}" "$out/bin/${packageName}" \
--add-flags "${pluginArgs}"
mkdir -vp "$out/share/man/man1" mkdir -vp "$out/share/man/man1"
cp -v "${buildPath}/chrome.1" "$out/share/man/man1/${packageName}.1" cp -v "${buildPath}/chrome.1" "$out/share/man/man1/${packageName}.1"