Advertisement
Guest User

Untitled

a guest
Jun 17th, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 12.60 KB | None | 0 0
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # $Header: /var/cvsroot/gentoo-x86/www-client/firefox/firefox-13.0.ebuild,v 1.4 2012/06/12 05:11:58 polynomial-c Exp $
  4.  
  5. EAPI="3"
  6. VIRTUALX_REQUIRED="pgo"
  7. WANT_AUTOCONF="2.1"
  8. MOZ_ESR=""
  9.  
  10. # This list can be updated with scripts/get_langs.sh from the mozilla overlay
  11. MOZ_LANGS=(af ak ar as ast be bg bn-BD bn-IN br bs ca cs csb cy da de el en
  12. en-GB en-US en-ZA eo es-AR es-CL es-ES es-MX et eu fa fi fr fy-NL ga-IE gd gl
  13. gu-IN he hi-IN hr hu hy-AM id is it ja kk kn ko ku lg lt lv mai mk ml mr nb-NO
  14. nl nn-NO nso or pa-IN pl pt-BR pt-PT rm ro ru si sk sl son sq sr sv-SE ta ta-LK
  15. te th tr uk vi zh-CN zh-TW zu)
  16.  
  17. # Convert the ebuild version to the upstream mozilla version, used by mozlinguas
  18. MOZ_PV="${PV/_alpha/a}" # Handle alpha for SRC_URI
  19. MOZ_PV="${MOZ_PV/_beta/b}" # Handle beta for SRC_URI
  20. MOZ_PV="${MOZ_PV/_rc/rc}" # Handle rc for SRC_URI
  21.  
  22. if [[ ${MOZ_ESR} == 1 ]]; then
  23.     # ESR releases have slightly version numbers
  24.     MOZ_PV="${MOZ_PV}esr"
  25. fi
  26.  
  27. # Changeset for alpha snapshot
  28. CHANGESET="e56ecd8b3a68"
  29. # Patch version
  30. PATCH="${PN}-13.0-patches-0.2"
  31. # Upstream ftp release URI that's used by mozlinguas.eclass
  32. # We don't use the http mirror because it deletes old tarballs.
  33. MOZ_FTP_URI="ftp://ftp.mozilla.org/pub/${PN}/releases/"
  34.  
  35. inherit check-reqs flag-o-matic toolchain-funcs eutils gnome2-utils mozconfig-3 multilib pax-utils fdo-mime autotools python virtualx nsplugins mozlinguas
  36.  
  37. DESCRIPTION="Firefox Web Browser"
  38. HOMEPAGE="http://www.mozilla.com/firefox"
  39.  
  40. KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux"
  41. SLOT="0"
  42. LICENSE="|| ( MPL-1.1 GPL-2 LGPL-2.1 )"
  43. IUSE="bindist +crashreporter +ipc +jit +minimal pgo selinux system-sqlite +webm kde"
  44.  
  45. # More URIs appended below...
  46. SRC_URI="${SRC_URI}
  47.     http://dev.gentoo.org/~anarchy/mozilla/patchsets/${PATCH}.tar.xz
  48.     kde? ( http://aur.archlinux.org/packages/fi/firefox-kde-opensuse/firefox-kde-opensuse.tar.gz )"
  49. ASM_DEPEND=">=dev-lang/yasm-1.1"
  50.  
  51. # Mesa 7.10 needed for WebGL + bugfixes
  52. RDEPEND="
  53.     >=sys-devel/binutils-2.16.1
  54.     >=dev-libs/nss-3.13.5
  55.     >=dev-libs/nspr-4.9.1
  56.     >=dev-libs/glib-2.26:2
  57.     >=media-libs/mesa-7.10
  58.     >=media-libs/libpng-1.5.9[apng]
  59.     virtual/libffi
  60.     system-sqlite? ( >=dev-db/sqlite-3.7.10[fts3,secure-delete,threadsafe,unlock-notify,debug=] )
  61.     webm? ( >=media-libs/libvpx-1.0.0
  62.         media-libs/alsa-lib )
  63.     crashreporter? ( net-misc/curl )
  64.     selinux? ( sec-policy/selinux-mozilla )"
  65. # We don't use PYTHON_DEPEND/PYTHON_USE_WITH for some silly reason
  66. DEPEND="${RDEPEND}
  67.     virtual/pkgconfig
  68.     pgo? (
  69.         =dev-lang/python-2*[sqlite]
  70.         >=sys-devel/gcc-4.5 )
  71.     webm? ( x86? ( ${ASM_DEPEND} )
  72.         amd64? ( ${ASM_DEPEND} )
  73.         virtual/opengl )"
  74.  
  75. # No source releases for alpha|beta
  76. if [[ ${PV} =~ alpha ]]; then
  77.     SRC_URI="${SRC_URI}
  78.         http://dev.gentoo.org/~anarchy/mozilla/firefox/firefox-${MOZ_PV}_${CHANGESET}.source.tar.bz2"
  79.     S="${WORKDIR}/mozilla-central"
  80. elif [[ ${PV} =~ beta ]]; then
  81.     S="${WORKDIR}/mozilla-beta"
  82.     SRC_URI="${SRC_URI}
  83.         ${MOZ_FTP_URI}/${MOZ_PV}/source/firefox-${MOZ_PV}.source.tar.bz2"
  84. else
  85.     SRC_URI="${SRC_URI}
  86.         ${MOZ_FTP_URI}/${MOZ_PV}/source/firefox-${MOZ_PV}.source.tar.bz2"
  87.     if [[ ${MOZ_ESR} == 1 ]]; then
  88.         S="${WORKDIR}/mozilla-esr${PV%%.*}"
  89.     else
  90.         S="${WORKDIR}/mozilla-release"
  91.     fi
  92. fi
  93.  
  94. QA_PRESTRIPPED="usr/$(get_libdir)/${PN}/firefox"
  95.  
  96. pkg_setup() {
  97.     moz_pkgsetup
  98.  
  99.     # Avoid PGO profiling problems due to enviroment leakage
  100.     # These should *always* be cleaned up anyway
  101.     unset DBUS_SESSION_BUS_ADDRESS \
  102.         DISPLAY \
  103.         ORBIT_SOCKETDIR \
  104.         SESSION_MANAGER \
  105.         XDG_SESSION_COOKIE \
  106.         XAUTHORITY
  107.  
  108.     if ! use bindist; then
  109.         einfo
  110.         elog "You are enabling official branding. You may not redistribute this build"
  111.         elog "to any users on your network or the internet. Doing so puts yourself into"
  112.         elog "a legal problem with Mozilla Foundation"
  113.         elog "You can disable it by emerging ${PN} _with_ the bindist USE-flag"
  114.     fi
  115.  
  116.     if use pgo; then
  117.         einfo
  118.         ewarn "You will do a double build for profile guided optimization."
  119.         ewarn "This will result in your build taking at least twice as long as before."
  120.     fi
  121.  
  122.     # Ensure we have enough disk space to compile
  123.     if use pgo || use debug || use test ; then
  124.         CHECKREQS_DISK_BUILD="8G"
  125.     else
  126.         CHECKREQS_DISK_BUILD="4G"
  127.     fi
  128.     check-reqs_pkg_setup
  129. }
  130.  
  131. src_unpack() {
  132.     unpack ${A}
  133.  
  134.     # Unpack language packs
  135.     mozlinguas_src_unpack
  136. }
  137.  
  138. src_prepare() {
  139.     # Apply our patches
  140.     EPATCH_SUFFIX="patch" \
  141.     EPATCH_FORCE="yes" \
  142.     epatch "${WORKDIR}/firefox"
  143.  
  144.  if use kde; then
  145.                rm -f browser/components/shell/src/nsKDEShellService.cpp \
  146.                          browser/components/shell/src/nsKDEShellService.h \
  147.                          browser/components/shell/src/nsUnixShellService.cpp \
  148.                          browser/components/shell/src/nsUnixShellService.h \
  149.                          browser/base/content/browser-kde.xul
  150.                rm -f toolkit/xre/nsKDEUtils.cpp \
  151.                          toolkit/xre/nsKDEUtils.h \
  152.                          uriloader/exthandler/unix/nsCommonRegistry.cpp \
  153.                          uriloader/exthandler/unix/nsCommonRegistry.h \
  154.                          uriloader/exthandler/unix/nsKDERegistry.cpp \
  155.                          uriloader/exthandler/unix/nsKDERegistry.h \
  156.                          toolkit/content/widgets/dialog-kde.xml \
  157.                          toolkit/content/widgets/preferences-kde.xml
  158.  
  159.                install -m 644 "${WORKDIR}/firefox-kde-opensuse/kde.js" browser/app/profile/kde.js
  160.  
  161.                EPATCH_SUFFIX="patch" \
  162.                EPATCH_FORCE="yes" \
  163.                EPATCH_EXCLUDE="firefox-install-dir.patch mozilla-firefox-1.0-lang.patch" \
  164.                epatch "${WORKDIR}/firefox-kde-opensuse"
  165.  fi
  166.  
  167.     # Allow user to apply any additional patches without modifing ebuild
  168.     epatch_user
  169.  
  170.     # Enable gnomebreakpad
  171.     if use debug ; then
  172.         sed -i -e "s:GNOME_DISABLE_CRASH_DIALOG=1:GNOME_DISABLE_CRASH_DIALOG=0:g" \
  173.             "${S}"/build/unix/run-mozilla.sh || die "sed failed!"
  174.     fi
  175.  
  176.     # Disable gnomevfs extension
  177.     sed -i -e "s:gnomevfs::" "${S}/"browser/confvars.sh \
  178.         -e "s:gnomevfs::" "${S}/"xulrunner/confvars.sh \
  179.         || die "Failed to remove gnomevfs extension"
  180.  
  181.     # Ensure that are plugins dir is enabled as default
  182.     sed -i -e "s:/usr/lib/mozilla/plugins:/usr/$(get_libdir)/nsbrowser/plugins:" \
  183.         "${S}"/xpcom/io/nsAppFileLocationProvider.cpp || die "sed failed to replace plugin path!"
  184.  
  185.     # Fix sandbox violations during make clean, bug 372817
  186.     sed -e "s:\(/no-such-file\):${T}\1:g" \
  187.         -i "${S}"/config/rules.mk \
  188.         -i "${S}"/js/src/config/rules.mk \
  189.         -i "${S}"/nsprpub/configure{.in,} \
  190.         || die
  191.  
  192.     #Fix compilation with curl-7.21.7 bug 376027
  193.     sed -e '/#include <curl\/types.h>/d'  \
  194.         -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/http_upload.cc \
  195.         -i "${S}"/toolkit/crashreporter/google-breakpad/src/common/linux/libcurl_wrapper.cc \
  196.         -i "${S}"/config/system-headers \
  197.         -i "${S}"/js/src/config/system-headers || die "Sed failed"
  198.  
  199.     eautoreconf
  200. }
  201.  
  202. src_configure() {
  203.     MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
  204.     MEXTENSIONS="default"
  205.  
  206.     ####################################
  207.     #
  208.     # mozconfig, CFLAGS and CXXFLAGS setup
  209.     #
  210.     ####################################
  211.  
  212.     mozconfig_init
  213.     mozconfig_config
  214.  
  215.     # It doesn't compile on alpha without this LDFLAGS
  216.     use alpha && append-ldflags "-Wl,--no-relax"
  217.  
  218.     mozconfig_annotate '' --prefix="${EPREFIX}"/usr
  219.     mozconfig_annotate '' --libdir="${EPREFIX}"/usr/$(get_libdir)
  220.     mozconfig_annotate '' --enable-extensions="${MEXTENSIONS}"
  221.     mozconfig_annotate '' --disable-gconf
  222.     mozconfig_annotate '' --disable-mailnews
  223.     mozconfig_annotate '' --enable-canvas
  224.     mozconfig_annotate '' --enable-safe-browsing
  225.     mozconfig_annotate '' --with-system-png
  226.     mozconfig_annotate '' --enable-system-ffi
  227.  
  228.     # Other ff-specific settings
  229.     mozconfig_annotate '' --with-default-mozilla-five-home=${MOZILLA_FIVE_HOME}
  230.     mozconfig_annotate '' --target="${CTARGET:-${CHOST}}"
  231.  
  232.     mozconfig_use_enable system-sqlite
  233.     # Both methodjit and tracejit conflict with PaX
  234.     mozconfig_use_enable jit methodjit
  235.     mozconfig_use_enable jit tracejit
  236.  
  237.     # Allow for a proper pgo build
  238.     if use pgo; then
  239.         echo "mk_add_options PROFILE_GEN_SCRIPT='\$(PYTHON) \$(OBJDIR)/_profile/pgo/profileserver.py'" >> "${S}"/.mozconfig
  240.     fi
  241.  
  242.     # Finalize and report settings
  243.     mozconfig_final
  244.  
  245.     if [[ $(gcc-major-version) -lt 4 ]]; then
  246.         append-cxxflags -fno-stack-protector
  247.     elif [[ $(gcc-major-version) -gt 4 || $(gcc-minor-version) -gt 3 ]]; then
  248.         if use amd64 || use x86; then
  249.             append-flags -mno-avx
  250.         fi
  251.     fi
  252. }
  253.  
  254. src_compile() {
  255.     if use pgo; then
  256.         addpredict /root
  257.         addpredict /etc/gconf
  258.         # Reset and cleanup environment variables used by GNOME/XDG
  259.         gnome2_environment_reset
  260.  
  261.         # Firefox tries to use dri stuff when it's run, see bug 380283
  262.         shopt -s nullglob
  263.         cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
  264.         if test -n "${cards}"; then
  265.             # FOSS drivers are fine
  266.             addpredict "${cards}"
  267.         else
  268.             cards=$(echo -n /dev/ati/card* /dev/nvidiactl* | sed 's/ /:/g')
  269.             if test -n "${cards}"; then
  270.                 # Binary drivers seem to cause access violations anyway, so
  271.                 # let's use indirect rendering so that the device files aren't
  272.                 # touched at all. See bug 394715.
  273.                 export LIBGL_ALWAYS_INDIRECT=1
  274.             fi
  275.         fi
  276.         shopt -u nullglob
  277.  
  278.         CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
  279.         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
  280.         Xemake -f client.mk profiledbuild || die "Xemake failed"
  281.     else
  282.         CC="$(tc-getCC)" CXX="$(tc-getCXX)" LD="$(tc-getLD)" \
  283.         MOZ_MAKE_FLAGS="${MAKEOPTS}" \
  284.         emake -f client.mk || die "emake failed"
  285.     fi
  286.  
  287. }
  288.  
  289. src_install() {
  290.     MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
  291.  
  292.     # MOZ_BUILD_ROOT, and hence OBJ_DIR change depending on arch, compiler, pgo, etc.
  293.     local obj_dir="$(echo */config.log)"
  294.     obj_dir="${obj_dir%/*}"
  295.     cd "${S}/${obj_dir}"
  296.  
  297.     # Without methodjit and tracejit there's no conflict with PaX
  298.     if use jit; then
  299.         # Pax mark xpcshell for hardened support, only used for startupcache creation.
  300.         pax-mark m "${S}/${obj_dir}"/dist/bin/xpcshell
  301.     fi
  302.  
  303.     # Add our default prefs for firefox + xulrunner
  304.     cp "${FILESDIR}"/gentoo-default-prefs.js-1 \
  305.         "${S}/${obj_dir}/dist/bin/defaults/pref/all-gentoo.js" || die
  306.  
  307.     MOZ_MAKE_FLAGS="${MAKEOPTS}" \
  308.     emake DESTDIR="${D}" install || die "emake install failed"
  309.  
  310.     # Install language packs
  311.     mozlinguas_src_install
  312.  
  313.     local size sizes icon_path icon name
  314.     if use bindist; then
  315.         sizes="16 32 48"
  316.         icon_path="${S}/browser/branding/aurora"
  317.         # Firefox's new rapid release cycle means no more codenames
  318.         # Let's just stick with this one...
  319.         icon="aurora"
  320.         name="Aurora"
  321.     else
  322.         sizes="16 22 24 32 256"
  323.         icon_path="${S}/browser/branding/official"
  324.         icon="${PN}"
  325.         name="Mozilla Firefox"
  326.     fi
  327.  
  328.     # Install icons and .desktop for menu entry
  329.     for size in ${sizes}; do
  330.         insinto "/usr/share/icons/hicolor/${size}x${size}/apps"
  331.         newins "${icon_path}/default${size}.png" "${icon}.png" || die
  332.     done
  333.     # The 128x128 icon has a different name
  334.     insinto "/usr/share/icons/hicolor/128x128/apps"
  335.     newins "${icon_path}/mozicon128.png" "${icon}.png" || die
  336.     # Install a 48x48 icon into /usr/share/pixmaps for legacy DEs
  337.     newicon "${icon_path}/content/icon48.png" "${icon}.png" || die
  338.     newmenu "${FILESDIR}/icon/${PN}.desktop" "${PN}.desktop" || die
  339.     sed -i -e "s:@NAME@:${name}:" -e "s:@ICON@:${icon}:" \
  340.         "${ED}/usr/share/applications/${PN}.desktop" || die
  341.  
  342.     # Add StartupNotify=true bug 237317
  343.     if use startup-notification ; then
  344.         echo "StartupNotify=true" >> "${ED}/usr/share/applications/${PN}.desktop"
  345.     fi
  346.  
  347.     # Without methodjit and tracejit there's no conflict with PaX
  348.     if use jit; then
  349.         # Required in order to use plugins and even run firefox on hardened.
  350.         pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/{firefox,firefox-bin}
  351.     fi
  352.  
  353.     # Plugin-container needs to be pax-marked for hardened to ensure plugins such as flash
  354.     # continue to work as expected.
  355.     pax-mark m "${ED}"${MOZILLA_FIVE_HOME}/plugin-container
  356.  
  357.     # Plugins dir
  358.     share_plugins_dir
  359.  
  360.     if use minimal; then
  361.         rm -rf "${ED}"/usr/include "${ED}${MOZILLA_FIVE_HOME}"/{idl,include,lib,sdk} || \
  362.             die "Failed to remove sdk and headers"
  363.     fi
  364.  
  365.     # very ugly hack to make firefox not sigbus on sparc
  366.     # FIXME: is this still needed??
  367.     use sparc && { sed -e 's/Firefox/FirefoxGentoo/g' \
  368.                      -i "${ED}/${MOZILLA_FIVE_HOME}/application.ini" || \
  369.                      die "sparc sed failed"; }
  370. }
  371.  
  372. pkg_preinst() {
  373.     gnome2_icon_savelist
  374. }
  375.  
  376. pkg_postinst() {
  377.     # Update mimedb for the new .desktop file
  378.     fdo-mime_desktop_database_update
  379.     gnome2_icon_cache_update
  380. }
  381.  
  382. pkg_postrm() {
  383.     gnome2_icon_cache_update
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement