--- mozilla/browser/app/mozilla.in~ 2005-10-07 14:40:55 +0400 +++ mozilla/browser/app/mozilla.in 2005-10-07 15:14:55 +0400 @@ -75,118 +75,15 @@ moz_pis_startstop_scripts() moz_libdir=%MOZAPPDIR% MRE_HOME=%MREDIR% -# Use run-mozilla.sh in the current dir if it exists -# If not, then start resolving symlinks until we find run-mozilla.sh -found=0 -progname="$0" -curdir=`dirname "$progname"` -progbase=`basename "$progname"` -run_moz="$curdir/run-mozilla.sh" -if test -x "$run_moz"; then - dist_bin="$curdir" - found=1 -else - here=`/bin/pwd` - while [ -h "$progname" ]; do - bn=`basename "$progname"` - cd `dirname "$progname"` - progname=`/bin/ls -l "$bn" | sed -e 's/^.* -> //' ` - if [ ! -x "$progname" ]; then - break - fi - curdir=`dirname "$progname"` - run_moz="$curdir/run-mozilla.sh" - if [ -x "$run_moz" ]; then - cd "$curdir" - dist_bin=`pwd` - run_moz="$dist_bin/run-mozilla.sh" - found=1 - break - fi - done - cd "$here" -fi -if [ $found = 0 ]; then - # Check default compile-time libdir - if [ -x "$moz_libdir/run-mozilla.sh" ]; then - dist_bin="$moz_libdir" - else - echo "Cannot find mozilla runtime directory. Exiting." - exit 1 - fi -fi +export MOZ_PLUGIN_PATH="%PLUGIN_PATH%:$moz_libdir/plugins${MOZ_PLUGIN_PATH:+":$MOZ_PLUGIN_PATH"}${HOME:+":$HOME/%MOZ_USER_DIR%/plugins"}" + +dist_bin="$moz_libdir" +run_moz="$moz_libdir/run-mozilla.sh" +MOZILLA_BIN="${0##*/}-bin" script_args="" debugging=0 -MOZILLA_BIN="${progbase}-bin" - -# The following is to check for a currently running instance. -# This is taken almost verbatim from the Mozilla RPM package's launch script. -MOZ_CLIENT_PROGRAM="$dist_bin/mozilla-xremote-client" -check_running() { - "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" 'ping()' 2>/dev/null >/dev/null - RETURN_VAL=$? - if [ $RETURN_VAL -eq 0 ]; then - echo 1 - return 1 - else - echo 0 - return 0 - fi -} - -if [ "$OSTYPE" = "beos" ]; then - mimeset -F "$MOZILLA_BIN" -fi - -ALREADY_RUNNING=`check_running` - -################################################################ Parse Arguments -# If there's a command line argument but it doesn't begin with a - -# it's probably a url. Try to send it to a running instance. -_USE_EXIST=0 -_optOne="$1" -case "${_optOne}" in - -*) - ;; - *) - _USE_EXIST=1 - ;; -esac - -_optLast= -for i in "$@"; do - _optLast="${i}" -done #last arg - -if [ `expr "${_optLast}" : '.*:/.*'` -eq 0 -a \( -f "${_optLast}" -o -d "${_optLast}" \) ]; then - # Last argument seems to be a local file/directory - # Check, if it is absolutely specified (ie. /home/foo/file vs. ./file) - # If it is just "relatively" (./file) specified, make it absolutely - [ `expr "${_optLast}" : '/.*'` -eq 0 ] && _optLast="file://`pwd`/${_optLast}" -fi -################################################################ Parse Arguments -########################################################################### Main -if [ $ALREADY_RUNNING -eq 1 ]; then - # There's an instance already running. Use it. - # Any command line args passed in? - if [ $# -gt 0 ]; then - # There were "some" command line args. - if [ ${_USE_EXIST} -eq 1 ]; then - # We should use an existing instance, as _USE_EXIST=$_USE_EXIST=-1 - _remote_cmd="openURL(${_optLast})" - "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "${_remote_cmd}" - unset _remote_cmd - exit $? - fi - else - # No command line args. Open new window/tab - #exec "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBrowser)" - "${run_moz}" "$MOZ_CLIENT_PROGRAM" -a "${progbase}" "xfeDoCommand(openBrowser)" - exit $? - fi -fi # Default action - no running instance or _USE_EXIST (${_USE_EXIST}) ! -eq 1 ########################################################################### Main @@ -222,10 +119,7 @@ export MRE_HOME ## Start addon scripts moz_pis_startstop_scripts "start" -if [ $debugging = 1 ] -then - echo $dist_bin/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN "$@" -fi +[ $debugging = 0 ] || echo "DEBUG: $dist_bin/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN $@" "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@" exitcode=$? --- mozilla/build/unix/run-mozilla.sh.run-scripts 2003-12-15 20:27:28 +0300 +++ mozilla/build/unix/run-mozilla.sh 2005-06-27 21:37:13 +0400 @@ -58,22 +58,25 @@ ## Potential improvements: ## ## + Run from anywhere in the tree. ## + Run ldd on the program and report missing dlls ## + Deal with NSPR in the tree ## + All the other unices ## # -cmdname=`basename "$0"` -MOZ_DIST_BIN=`dirname "$0"` -MOZ_DEFAULT_NAME="./${cmdname}-bin" -MOZ_APPRUNNER_NAME="./mozilla-bin" -MOZ_VIEWER_NAME="./viewer" +cmdname="${0##*/}" +MOZ_DIST_BIN="${0%/*}" MOZ_PROGRAM="" +MOZ_CLIENT_PROGRAM="${MOZ_DIST_BIN}/mozilla-xremote-client" +MOZ_CLIENT_OPTS=" -a firefox -u $USER" + +USE_XPRINT= +ALREADY_RUNNING= +RUNS= exitcode=0 # ## ## Functions ## ########################################################################## moz_usage() @@ -150,53 +153,61 @@ moz_get_debugger() debugger=$dpath break fi done echo $debugger return 0 } ########################################################################## +check_running() { + "$MOZ_CLIENT_PROGRAM" -a firefox -u "$USER" 'ping()' 2>/dev/null >/dev/null || return 1 +} +########################################################################## +open_browser() { + local opt="$1" && shift ||: + [ "${opt#-}" = "$opt" ] || return 0 + [ "${opt#altbug:}" = "$opt" ] || opt="https://bugzilla.altlinux.org/show_bug.cgi?id=${opt#altbug:}" + + if [ "${ALREADY_RUNNING}" -eq "0" ]; then + [ -z "$opt" ] || RUNS="$prog $opt $*" + return 0 + fi + + [ -n "$opt" ] || { RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS xfeDoCommand(openBrowser)"; return 0; } + + # check to make sure that the command contains at least a :/ in it. + if [ "${opt#*:/}" = "$opt" ]; then + # if it doesn't begin with a '/' and it exists when the pwd is + # prepended to it then append the full path + [ "${opt#/}" = "$opt" ] && [ -e "$PWD/$opt" ] && opt="$PWD/$opt" + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS openurl($opt)" + return 0 + fi + # just pass it off if it looks like a url + RUNS="$MOZ_CLIENT_PROGRAM $MOZ_CLIENT_OPTS openurl($opt,new-tab)" +} +########################################################################## moz_run_program() { prog=$MOZ_PROGRAM ## ## Make sure the program is executable ## if [ ! -x "$prog" ] then moz_bail "Cannot execute $prog." fi - ## - ## Use md5sum to crc a core file. If md5sum is not found on the system, - ## then dont debug core files. - ## - moz_test_binary /bin/type - if [ $? -eq 1 ] - then - crc_prog=`type md5sum 2>/dev/null | awk '{print $3;}' 2>/dev/null | sed -e 's/\.$//'` - else - crc_prog=`which md5sum 2>/dev/null` - fi - if [ -x "$crc_prog" ] - then - DEBUG_CORE_FILES=1 - fi - if [ "$DEBUG_CORE_FILES" ] - then - crc_old= - if [ -f core ] - then - crc_old=`$crc_prog core | awk '{print $1;}' ` - fi - fi - ## - ## Run the program - ## - "$prog" ${1+"$@"} + + RUNS= + check_running && ALREADY_RUNNING=1 || ALREADY_RUNNING=0 + open_browser $* + + [ -n "$RUNS" ] || RUNS="$prog ${1+"$@"}" + $RUNS exitcode=$? if [ "$DEBUG_CORE_FILES" ] then if [ -f core ] then crc_new=`$crc_prog core | awk '{print $1;}' ` fi fi @@ -301,55 +312,22 @@ do break; ;; esac done # ## ## Program name given in $1 ## -if [ $# -gt 0 ] -then - MOZ_PROGRAM=$1 - shift +if [ $# -gt 0 -a -x "$1" ]; then + MOZ_PROGRAM="$1" + shift fi -## -## Program not given, try to guess a default -## -if [ -z "$MOZ_PROGRAM" ] -then - ## - ## Try this script's name with '-bin' appended - ## - if [ -x "$MOZ_DEFAULT_NAME" ] - then - MOZ_PROGRAM=$MOZ_DEFAULT_NAME - ## Try viewer (this should be deprecated) - ## - elif [ -x "$MOZ_VIEWER_NAME" ] - then - MOZ_PROGRAM=$MOZ_VIEWER_NAME - ## - ## Try mozilla-bin - ## - elif [ -x "$MOZ_APPRUNNER_NAME" ] - then - MOZ_PROGRAM=$MOZ_APPRUNNER_NAME - fi -fi -# -# -## -## Make sure the program is executable -## -if [ ! -x "$MOZ_PROGRAM" ] -then - moz_bail "Cannot execute $MOZ_PROGRAM." -fi -# +[ -x "$MOZ_PROGRAM" ] || moz_bail "Cannot execute $MOZ_PROGRAM." + ## ## Set MOZILLA_FIVE_HOME ## MOZILLA_FIVE_HOME=$MOZ_DIST_BIN if [ -z "$MRE_HOME" ]; then MRE_HOME=$MOZILLA_FIVE_HOME fi @@ -364,47 +342,20 @@ if [ -n "$LD_LIBRARYN64_PATH" ] then LD_LIBRARYN64_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARYN64_PATH+":$LD_LIBRARYN64_PATH"} fi if [ -n "$LD_LIBRARY_PATH_64" ]; then LD_LIBRARY_PATH_64=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/plugins:${MRE_HOME}${LD_LIBRARY_PATH_64+":$LD_LIBRARY_PATH_64"} fi # # -## Set SHLIB_PATH for HPUX -SHLIB_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${SHLIB_PATH+":$SHLIB_PATH"} -# -## Set LIBPATH for AIX -LIBPATH=${MOZ_DIST_BIN}:${MRE_HOME}${LIBPATH+":$LIBPATH"} -# -## Set DYLD_LIBRARY_PATH for Mac OS X (Darwin) -DYLD_LIBRARY_PATH=${MOZ_DIST_BIN}:${MRE_HOME}${DYLD_LIBRARY_PATH+":$DYLD_LIBRARY_PATH"} -# -## Set LIBRARY_PATH for BeOS -LIBRARY_PATH=${MOZ_DIST_BIN}:${MOZ_DIST_BIN}/components:${MRE_HOME}${LIBRARY_PATH+":$LIBRARY_PATH"} -# -## Set ADDON_PATH for BeOS -ADDON_PATH=${MOZ_DIST_BIN}${ADDON_PATH+":$ADDON_PATH"} -# -## Solaris Xserver(Xsun) tuning - use shared memory transport if available -if [ "$XSUNTRANSPORT" = "" ] -then - XSUNTRANSPORT="shmem" - XSUNSMESIZE="512" - export XSUNTRANSPORT XSUNSMESIZE -fi ## Populate XPSERVERLIST if it was not set yet -if [ "$XPSERVERLIST" = "" ] -then - if [ -f /etc/init.d/xprint ] ; then - XPSERVERLIST="`/bin/sh /etc/init.d/xprint get_xpserverlist`" - if [ "$XPSERVERLIST" != "" ] ; then - export XPSERVERLIST - fi - fi +if [ -z "$XPSERVERLIST" -a -n "$USE_XPRINT" ]; then + XPSERVERLIST="$(/sbin/service xprint get_xpserverlist)" + [ -z "$XPSERVERLIST" ] || export XPSERVERLIST fi if [ "$moz_debug" -eq 1 ] then echo "MOZILLA_FIVE_HOME=$MOZILLA_FIVE_HOME" echo " LD_LIBRARY_PATH=$LD_LIBRARY_PATH" if [ -n "$LD_LIBRARYN32_PATH" ] then