thunderbird: port changes from firefox

Fix random crashes.
Add optional GTK3 support.
This commit is contained in:
Nikolay Amiantov 2017-04-09 20:15:06 +03:00
parent 56ca347872
commit b023370f37

View File

@ -1,28 +1,27 @@
{ stdenv, lib, fetchurl, pkgconfig, autoconf213, which, m4, gtk2, pango { lib, stdenv, fetchurl, pkgconfig, gtk2, pango, perl, python, zip, libIDL
, perl, python2, zip , libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
, libIDL , libjpeg, libpng, zlib, dbus, dbus_glib, bzip2, xorg , freetype, fontconfig, file, nspr, nss, libnotify
, freetype, fontconfig, file, alsaLib, nspr, nss, libnotify , yasm, mesa, sqlite, unzip
, yasm, mesa, sqlite, unzip, makeWrapper , hunspell, libevent, libstartup_notification
, hunspell, libevent, libstartup_notification, libvpx , cairo, gstreamer, gst-plugins-base, icu, libpng, jemalloc
, cairo, gstreamer, gst-plugins-base, icu , autoconf213, which, m4
, writeScript, xidel, common-updater-scripts, coreutils, gnused, gnugrep, curl , writeScript, xidel, common-updater-scripts, coreutils, gnused, gnugrep, curl
, enableGTK3 ? false, gtk3, wrapGAppsHook
, debugBuild ? false , debugBuild ? false
, # If you want the resulting program to call itself "Thunderbird" , # If you want the resulting program to call itself "Thunderbird" instead
# instead of "Earlybird", enable this option. However, those # of "Earlybird" or whatever, enable this option. However, those
# binaries may not be distributed without permission from the # binaries may not be distributed without permission from the
# Mozilla Foundation, see # Mozilla Foundation, see
# http://www.mozilla.org/foundation/trademarks/. # http://www.mozilla.org/foundation/trademarks/.
enableOfficialBranding ? false enableOfficialBranding ? false
}: }:
let version = "52.0"; in
let verName = "${version}"; in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "thunderbird-${verName}"; name = "thunderbird-${version}";
version = "52.0";
src = fetchurl { src = fetchurl {
url = "mirror://mozilla/thunderbird/releases/${verName}/source/thunderbird-${verName}.source.tar.xz"; url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
sha512 = "215de8ae386f6f12d7a4338bb03bac956410be0dd4de5cca218e12241e3948c8c2540756e149bfde597cd10e399b4cb4db86619a2aa50a368ba323b413c1f93c"; sha512 = "215de8ae386f6f12d7a4338bb03bac956410be0dd4de5cca218e12241e3948c8c2540756e149bfde597cd10e399b4cb4db86619a2aa50a368ba323b413c1f93c";
}; };
@ -33,96 +32,94 @@ stdenv.mkDerivation rec {
done done
''; '';
buildInputs = # from firefox30Pkgs.xulrunner, without gstreamer and libvpx # from firefox, but without sound libraries
[ pkgconfig autoconf213 which libpng gtk2 perl zip libIDL libjpeg zlib bzip2 buildInputs =
python2 dbus dbus_glib pango freetype fontconfig xorg.libXi [ gtk2 zip libIDL libjpeg zlib bzip2
dbus dbus_glib pango freetype fontconfig xorg.libXi
xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
alsaLib nspr nss libnotify xorg.pixman yasm mesa nspr nss libnotify xorg.pixman yasm mesa
xorg.libXScrnSaver xorg.scrnsaverproto xorg.libXScrnSaver xorg.scrnsaverproto
xorg.libXext xorg.xextproto sqlite unzip makeWrapper xorg.libXext xorg.xextproto sqlite unzip
hunspell libevent libstartup_notification cairo icu hunspell libevent libstartup_notification /* cairo */
] ++ [ m4 ]; icu libpng jemalloc
]
++ lib.optional enableGTK3 gtk3;
# from firefox + m4
nativeBuildInputs = [ m4 autoconf213 which gnused pkgconfig perl python ] ++ lib.optional enableGTK3 wrapGAppsHook;
configureFlags =
[ # from firefox, but without sound libraries (alsa, libvpx, pulseaudio)
"--enable-application=mail"
"--disable-alsa"
"--disable-pulseaudio"
configurePhase = let configureFlags = [ "--enable-application=mail" ]
# from firefox30Pkgs.commonConfigureFlags, but without gstreamer and libvpx
++ [
"--with-system-jpeg" "--with-system-jpeg"
"--with-system-zlib" "--with-system-zlib"
"--with-system-bz2" "--with-system-bz2"
"--with-system-nspr" "--with-system-nspr"
"--with-system-nss" "--with-system-nss"
"--with-system-libevent" "--with-system-libevent"
#"--with-system-libvpx" "--with-system-png" # needs APNG support
"--with-system-png"
"--with-system-icu" "--with-system-icu"
"--enable-system-ffi" "--enable-system-ffi"
"--enable-system-hunspell" "--enable-system-hunspell"
"--enable-system-pixman" "--enable-system-pixman"
"--enable-system-sqlite" "--enable-system-sqlite"
"--enable-system-cairo" #"--enable-system-cairo"
"--disable-gconf"
"--enable-startup-notification" "--enable-startup-notification"
# "--enable-content-sandbox" # available since 26.0, but not much info available "--enable-content-sandbox" # available since 26.0, but not much info available
# "--enable-content-sandbox-reporter" # keeping disabled for now
"--disable-crashreporter" "--disable-crashreporter"
"--disable-tests" "--disable-tests"
"--disable-necko-wifi" # maybe we want to enable this at some point "--disable-necko-wifi" # maybe we want to enable this at some point
"--disable-updater" "--disable-updater"
"--disable-pulseaudio" "--enable-jemalloc"
"--enable-default-toolkit=cairo-gtk2" "--disable-gconf"
] ++ (if debugBuild then [ "--enable-debug" "--enable-profiling"] "--enable-default-toolkit=cairo-gtk${if enableGTK3 then "3" else "2"}"
]
++ (if debugBuild then [ "--enable-debug" "--enable-profiling"]
else [ "--disable-debug" "--enable-release" else [ "--disable-debug" "--enable-release"
"--disable-debug-symbols" "--disable-debug-symbols"
"--enable-optimize" "--enable-strip" ]) "--enable-optimize" "--enable-strip" ])
++ [ ++ lib.optional enableOfficialBranding "--enable-official-branding";
#"--enable-stdcxx-compat" # Avoid dependency on libstdc++ 4.7
]
++ stdenv.lib.optional enableOfficialBranding "--enable-official-branding";
in ''
mkdir -p objdir/mozilla
cd objdir
echo '${stdenv.lib.concatMapStrings (s : "ac_add_options ${s}\n") configureFlags}' > .mozconfig
echo 'ac_add_options --prefix="'"$out"'"' >> .mozconfig
# From version 38, we need to specify the source directory to build
# Thunderbird. Refer to mozilla/configure and search a line with
# "checking for application to build" and "# Support comm-central".
echo 'ac_add_options --with-external-source-dir="'`realpath ..`'"' >> .mozconfig
echo 'mk_add_options MOZ_MAKE_FLAGS="-j'"$NIX_BUILD_CORES"'"' >> .mozconfig
echo 'mk_add_options MOZ_OBJDIR="'`pwd`'"' >> .mozconfig
export MOZCONFIG=`realpath ./.mozconfig`
patchShebangs ../mozilla/mach
../mozilla/mach configure
'';
enableParallelBuilding = true; enableParallelBuilding = true;
requiredSystemFeatures = [ "big-parallel" ];
buildPhase = "../mozilla/mach build"; preConfigure =
installPhase =
'' ''
../mozilla/mach install configureScript="$(realpath ./configure)"
mkdir ../objdir
cd ../objdir
'';
rm -rf $out/include $out/lib/thunderbird-devel-* $out/share/idl preInstall =
''
# The following is needed for startup cache creation on grsecurity kernels.
paxmark m ../objdir/dist/bin/xpcshell
'';
# Create a desktop item. postInstall =
mkdir -p $out/share/applications ''
cat > $out/share/applications/thunderbird.desktop <<EOF # For grsecurity kernels
[Desktop Entry] paxmark m $out/lib/thunderbird-[0-9]*/thunderbird
Type=Application
Exec=$out/bin/thunderbird # Needed to find Mozilla runtime
Icon=$out/lib/thunderbird-${version}/chrome/icons/default/default256.png gappsWrapperArgs+=(--argv0 "$out/bin/.thunderbird-wrapped")
Name=Thunderbird
GenericName=Mail Reader
Categories=Application;Network;
EOF
''; '';
postFixup = postFixup =
# Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
'' ''
paxmark m $out/lib/thunderbird-${version}/thunderbird patchelf --set-rpath "${lib.getLib libnotify
}/lib:$(patchelf --print-rpath "$out"/lib/thunderbird-*/libxul.so)" \
"$out"/lib/thunderbird-*/libxul.so
'';
doInstallCheck = true;
installCheckPhase =
''
# Some basic testing
"$out/bin/thunderbird" --version
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {