jgrulich / rpms / firefox

Forked from rpms/firefox 4 years ago
Clone
46ed09d
#!/bin/bash
cvsdist cac9c1c
#
cvsdist cac9c1c
# The contents of this file are subject to the Netscape Public
cvsdist cac9c1c
# License Version 1.1 (the "License"); you may not use this file
cvsdist cac9c1c
# except in compliance with the License. You may obtain a copy of
cvsdist cac9c1c
# the License at http://www.mozilla.org/NPL/
cvsdist cac9c1c
#
cvsdist cac9c1c
# Software distributed under the License is distributed on an "AS
cvsdist cac9c1c
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
cvsdist cac9c1c
# implied. See the License for the specific language governing
cvsdist cac9c1c
# rights and limitations under the License.
cvsdist cac9c1c
#
cvsdist cac9c1c
# The Original Code is mozilla.org code.
cvsdist cac9c1c
#
cvsdist cac9c1c
# The Initial Developer of the Original Code is Netscape
cvsdist cac9c1c
# Communications Corporation.  Portions created by Netscape are
cvsdist cac9c1c
# Copyright (C) 1998 Netscape Communications Corporation. All
cvsdist cac9c1c
# Rights Reserved.
cvsdist cac9c1c
#
0813120
# Contributor(s):
cvsdist cac9c1c
#
cvsdist cac9c1c
0813120
##
cvsdist cac9c1c
## Usage:
cvsdist cac9c1c
##
e86a9f2
## $ firefox
cvsdist cac9c1c
##
cvsdist cac9c1c
## This script is meant to run a mozilla program from the mozilla
cvsdist cac9c1c
## rpm installation.
cvsdist cac9c1c
##
cvsdist cac9c1c
## The script will setup all the environment voodoo needed to make
cvsdist cac9c1c
## mozilla work.
cvsdist cac9c1c
cvsdist cac9c1c
cmdname=`basename $0`
cvsdist cac9c1c
cvsdist cac9c1c
##
cvsdist cac9c1c
## Variables
cvsdist cac9c1c
##
fa5aab6
MOZ_ARCH=$(uname -m)
fa5aab6
case $MOZ_ARCH in
6b3c95c
	x86_64 | s390x | sparc64)
0813120
		MOZ_LIB_DIR="/__PREFIX__/lib64"
0813120
		SECONDARY_LIB_DIR="/__PREFIX__/lib"
fa5aab6
		;;
fa5aab6
	* )
0813120
		MOZ_LIB_DIR="/__PREFIX__/lib"
0813120
		SECONDARY_LIB_DIR="/__PREFIX__/lib64"
fa5aab6
		;;
fa5aab6
esac
fa5aab6
73632af
MOZ_FIREFOX_FILE="firefox"
Martin Stransky 5cc9eff
d2cc793
if [ ! -r $MOZ_LIB_DIR/firefox/$MOZ_FIREFOX_FILE ]; then
d2cc793
    if [ ! -r $SECONDARY_LIB_DIR/firefox/$MOZ_FIREFOX_FILE ]; then
d2cc793
	echo "Error: $MOZ_LIB_DIR/firefox/$MOZ_FIREFOX_FILE not found"
fa5aab6
	if [ -d $SECONDARY_LIB_DIR ]; then
d2cc793
	    echo "       $SECONDARY_LIB_DIR/firefox/$MOZ_FIREFOX_FILE not found"
fa5aab6
	fi
fa5aab6
	exit 1
fa5aab6
    fi
fa5aab6
    MOZ_LIB_DIR="$SECONDARY_LIB_DIR"
74adc9d
fi
d2cc793
MOZ_DIST_BIN="$MOZ_LIB_DIR/firefox"
e86a9f2
MOZ_LANGPACKS_DIR="$MOZ_DIST_BIN/langpacks"
e86a9f2
MOZ_EXTENSIONS_PROFILE_DIR="$HOME/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
73632af
MOZ_PROGRAM="$MOZ_DIST_BIN/$MOZ_FIREFOX_FILE"
Christopher Aillon 679f997
MOZ_LAUNCHER="$MOZ_DIST_BIN/run-mozilla.sh"
c45606f
cvsdist cac9c1c
##
a1d5dfd
## Enable Wayland backend?
a1d5dfd
##
a1d5dfd
if __DEFAULT_WAYLAND__ && ! [ $MOZ_DISABLE_WAYLAND ]; then
a1d5dfd
  if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
a1d5dfd
    export MOZ_ENABLE_WAYLAND=1
a1d5dfd
  fi
a1d5dfd
fi
a1d5dfd
a1d5dfd
##
557e35a
## Set MOZ_GRE_CONF
557e35a
##
557e35a
MOZ_GRE_CONF=/etc/gre.d/gre.conf
0813120
if [ "$MOZ_LIB_DIR" == "/__PREFIX__/lib64" ]; then
557e35a
  MOZ_GRE_CONF=/etc/gre.d/gre64.conf
557e35a
fi
557e35a
export MOZ_GRE_CONF
557e35a
557e35a
##
cvsdist cac9c1c
## Set MOZILLA_FIVE_HOME
cvsdist cac9c1c
##
cvsdist cac9c1c
MOZILLA_FIVE_HOME="$MOZ_DIST_BIN"
cvsdist cac9c1c
cvsdist cac9c1c
export MOZILLA_FIVE_HOME
cvsdist cac9c1c
15debc1
##
536c4ad
## Make sure that we set the plugin path
cvsdist cac9c1c
##
Martin Stransky e86e7ae
MOZ_PLUGIN_DIR="plugins"
Martin Stransky e86e7ae
cvsdist cac9c1c
if [ "$MOZ_PLUGIN_PATH" ]
cvsdist cac9c1c
then
15debc1
  MOZ_PLUGIN_PATH=$MOZ_PLUGIN_PATH:$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR
cvsdist cac9c1c
else
15debc1
  MOZ_PLUGIN_PATH=$MOZ_LIB_DIR/mozilla/$MOZ_PLUGIN_DIR:$MOZ_DIST_BIN/$MOZ_PLUGIN_DIR
cvsdist cac9c1c
fi
cvsdist cac9c1c
export MOZ_PLUGIN_PATH
cvsdist cac9c1c
383a808
##
e5f8814
## Set MOZ_APP_LAUNCHER for gnome-session
e5f8814
##
0813120
export MOZ_APP_LAUNCHER="/__PREFIX__/bin/firefox"
e5f8814
e5f8814
##
cvsdist cac9c1c
## Set FONTCONFIG_PATH for Xft/fontconfig
cvsdist cac9c1c
##
cvsdist cac9c1c
FONTCONFIG_PATH="/etc/fonts:${MOZILLA_FIVE_HOME}/res/Xft"
cvsdist cac9c1c
export FONTCONFIG_PATH
cvsdist cac9c1c
2ca6e87
##
0813120
## In order to better support certain scripts (such as Indic and some CJK
0813120
## scripts), Fedora builds its Firefox, with permission from the Mozilla
0813120
## Corporation, with the Pango system as its text renderer.  This change
besfahbo 580eb13
## may negatively impact performance on some pages.  To disable the use of
besfahbo 580eb13
## Pango, set MOZ_DISABLE_PANGO=1 in your environment before launching
besfahbo 580eb13
## Firefox.
2ca6e87
##
da97c6e
#
da97c6e
# MOZ_DISABLE_PANGO=1
da97c6e
# export MOZ_DISABLE_PANGO
da97c6e
#
f381d84
018bdff
##
018bdff
## Disable the GNOME crash dialog, Moz has it's own
018bdff
##
018bdff
GNOME_DISABLE_CRASH_DIALOG=1
018bdff
export GNOME_DISABLE_CRASH_DIALOG
018bdff
3cfb2b8
##
3cfb2b8
## Disable the SLICE allocator (rhbz#1014858)
3cfb2b8
##
3cfb2b8
export G_SLICE=always-malloc
3cfb2b8
90dc736
##
90dc736
## Enable Xinput2 (mozbz#1207973)
90dc736
##
90dc736
export MOZ_USE_XINPUT2=1
90dc736
cvsdist cac9c1c
# OK, here's where all the real work gets done
cvsdist cac9c1c
e86a9f2
e86a9f2
##
e86a9f2
## To disable the use of Firefox localization, set MOZ_DISABLE_LANGPACKS=1
e86a9f2
## in your environment before launching Firefox.
e86a9f2
##
e86a9f2
#
e86a9f2
# MOZ_DISABLE_LANGPACKS=1
e86a9f2
# export MOZ_DISABLE_LANGPACKS
e86a9f2
#
e86a9f2
e86a9f2
##
ea2cabb
## Automatically installed langpacks are tracked by .fedora-langpack-install
ea2cabb
## config file.
e86a9f2
##
ea2cabb
FEDORA_LANGPACK_CONFIG="$MOZ_EXTENSIONS_PROFILE_DIR/.fedora-langpack-install"
e86a9f2
Christopher Aillon 25ccac4
# MOZ_DISABLE_LANGPACKS disables language packs completely
e86a9f2
MOZILLA_DOWN=0
e86a9f2
if ! [ $MOZ_DISABLE_LANGPACKS ] || [ $MOZ_DISABLE_LANGPACKS -eq 0 ]; then
a3e5347
    if [ -x $MOZ_DIST_BIN/$MOZ_FIREFOX_FILE ]; then
e86a9f2
        # Is firefox running?
0813120
        /__PREFIX__/bin/pidof firefox > /dev/null 2>&1
e86a9f2
        MOZILLA_DOWN=$?
e86a9f2
    fi
e86a9f2
fi
e86a9f2
0813120
# Modify language pack configuration only when firefox is not running
e86a9f2
# and language packs are not disabled
e86a9f2
if [ $MOZILLA_DOWN -ne 0 ]; then
e86a9f2
ea2cabb
    # Clear already installed langpacks
ea2cabb
    mkdir -p $MOZ_EXTENSIONS_PROFILE_DIR
ea2cabb
    if [ -f $FEDORA_LANGPACK_CONFIG ]; then
505794d
        rm `cat $FEDORA_LANGPACK_CONFIG` > /dev/null 2>&1
505794d
        rm $FEDORA_LANGPACK_CONFIG > /dev/null 2>&1
36c0fad
        # remove all empty langpacks dirs while they block installation of langpacks
36c0fad
        rmdir $MOZ_EXTENSIONS_PROFILE_DIR/langpack* > /dev/null 2>&1
ea2cabb
    fi
e1fa01e
e1fa01e
    # Get locale from system
e1fa01e
    CURRENT_LOCALE=$LC_ALL
e1fa01e
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LC_MESSAGES}
e1fa01e
    CURRENT_LOCALE=${CURRENT_LOCALE:-$LANG}
c6c7068
Martin Stransky a62de3b
    # Try with a local variant first, then without a local variant
ea5307d
    SHORTMOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*||g" | sed "s|\..*||g"`
ea5307d
    MOZLOCALE=`echo $CURRENT_LOCALE | sed "s|_\([^.]*\).*|-\1|g" | sed "s|\..*||g"`
Christopher Aillon 36d2d05
Christopher Aillon 36d2d05
    function create_langpack_link() {
Christopher Aillon 36d2d05
        local language=$*
Christopher Aillon 49840ed
        local langpack=langpack-${language}@firefox.mozilla.org.xpi
Christopher Aillon 49840ed
        if [ -f $MOZ_LANGPACKS_DIR/$langpack ]; then
Christopher Aillon 36d2d05
            rm -rf $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
0813120
            # If the target file is a symlink (the fallback langpack),
d38e8d3
            # install the original file instead of the fallback one
d38e8d3
            if [ -h $MOZ_LANGPACKS_DIR/$langpack ]; then
d38e8d3
                langpack=`readlink $MOZ_LANGPACKS_DIR/$langpack`
d38e8d3
            fi
Christopher Aillon 36d2d05
            ln -s $MOZ_LANGPACKS_DIR/$langpack \
Christopher Aillon 36d2d05
                  $MOZ_EXTENSIONS_PROFILE_DIR/$langpack
Christopher Aillon 36d2d05
            echo $MOZ_EXTENSIONS_PROFILE_DIR/$langpack > $FEDORA_LANGPACK_CONFIG
Christopher Aillon 36d2d05
            return 0
e86a9f2
        fi
Christopher Aillon 36d2d05
        return 1
Christopher Aillon 36d2d05
    }
Christopher Aillon 36d2d05
Martin Stransky a62de3b
    create_langpack_link $MOZLOCALE || create_langpack_link $SHORTMOZLOCALE || true
e86a9f2
fi
cvsdist cac9c1c
c6c7068
# BEAST fix (rhbz#1005611)
c6c7068
NSS_SSL_CBC_RANDOM_IV=${NSS_SSL_CBC_RANDOM_IV-1}
c6c7068
export NSS_SSL_CBC_RANDOM_IV
c6c7068
ee9e9cf
# Prepare command line arguments
ee9e9cf
script_args=""
ee9e9cf
pass_arg_count=0
ee9e9cf
while [ $# -gt $pass_arg_count ]
ee9e9cf
do
ee9e9cf
  case "$1" in
ee9e9cf
    -g | --debug)
ee9e9cf
      script_args="$script_args -g"
ee9e9cf
      debugging=1
ee9e9cf
      shift
ee9e9cf
      ;;
ee9e9cf
    -d | --debugger)
e530b2e
      if [ $# -gt 1 ]; then
e530b2e
        script_args="$script_args -d $2"
e530b2e
        shift 2
e530b2e
      else
e530b2e
        shift
e530b2e
      fi
ee9e9cf
      ;;
ee9e9cf
    *)
ee9e9cf
      # Move the unrecognized argument to the end of the list.
ee9e9cf
      arg="$1"
ee9e9cf
      shift
ee9e9cf
      set -- "$@" "$arg"
ee9e9cf
      pass_arg_count=`expr $pass_arg_count + 1`
ee9e9cf
      ;;
ee9e9cf
  esac
ee9e9cf
done
ee9e9cf
7edd26f
# Flatpak specific environment variables
7edd26f
%FLATPAK_ENV_VARS%
7edd26f
b2802de
# Don't throw "old profile" dialog box.
b2802de
export MOZ_ALLOW_DOWNGRADE=1
b2802de
cac1096
# Run the browser
ee9e9cf
debugging=0
ee9e9cf
if [ $debugging = 1 ]
ee9e9cf
then
Christopher Aillon 779c27a
  echo $MOZ_LAUNCHER $script_args $MOZ_PROGRAM "$@"
ee9e9cf
fi
ee9e9cf
Christopher Aillon 779c27a
exec $MOZ_LAUNCHER $script_args $MOZ_PROGRAM "$@"