[PATCH] www/mozilla: new mozilla.sh script
Jose M Rodriguez (freebsd)
josemi at freebsd.jazztel.es
Tue Dec 28 19:36:18 PST 2004
>Submitter-Id: current-users
>Originator: Jose M Rodriguez (freebsd)
>Organization: Redes JM
>Confidential: no
>Synopsis: [PATCH] www/mozilla: new mozilla.sh script
>Severity: non-critical
>Priority: low
>Category: ports
>Class: change-request
>Release: FreeBSD 5.3-STABLE i386
>Environment:
System: FreeBSD orion.redesjm.local 5.3-STABLE FreeBSD 5.3-STABLE #0: Mon Dec 27 17:00:42 CET 2004
>Description:
New mozilla.sh script
first step for a generic mozilla/firefox/thunderbird script
comments wellcome
Port maintainer (gnome at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.63
>How-To-Repeat:
>Fix:
--- mozilla-1.7.5_1,2.patch begins here ---
diff -ruN --exclude=CVS /usr/HEAD/ports/www/mozilla/files/mozilla.sh /junk/wk/www/mozilla/files/mozilla.sh
--- /usr/HEAD/ports/www/mozilla/files/mozilla.sh Sun Dec 26 17:08:52 2004
+++ /junk/wk/www/mozilla/files/mozilla.sh Wed Dec 29 03:16:07 2004
@@ -1,34 +1,350 @@
#!/bin/sh
+#
+# The contents of this file are subject to the Netscape Public License
+# Version 1.0 (the "NPL"); you may not use this file except in
+# compliance with the NPL. You may obtain a copy of the NPL at
+# http://www.mozilla.org/NPL/
+#
+# Software distributed under the NPL is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+# for the specific language governing rights and limitations under the
+# NPL.
+#
+# The Initial Developer of this code under the NPL is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All Rights
+# Reserved.
+#
-MOZILLA_DIR="%%PREFIX%%/lib/%%MOZILLA%%"
-MOZILLA_EXEC="./mozilla"
-MOZILLA_REMOTE_EXEC="${MOZILLA_EXEC} -remote"
-APPLICATION_ID="mozilla"
+# $from: mozilla.in,v 1.6 2004/02/20 18:13:46 pkw%us.ibm.com Exp $
+# Usage:
+#
+# $ mozilla [args]
+#
+# The script will setup all the environment voodoo needed to make
+# the mozilla-bin binary to work.
+
+#uncomment for debugging
+#set -x
+
+#
+# variables
+#
LOCATION='new-tab'
#MOZILLA_UILOCALE="en-US"
#MOZILLA_UIREGION="US"
#MOZILLA_DSP="auto"
-cd $MOZILLA_DIR || exit 1
+#
+# working definitions
+#
+MOZ_APPID="mozilla"
+MOZ_USER_DIR=".mozilla"
+MOZILLA_FIVE_HOME="%%PREFIX%%/lib/%%MOZILLA%%"
+
+#defaults
+curdir=`pwd`
+debugging= # no debugging
+ALREADY_RUNNING= # use a new instance
+REMOTE_COMMAND="xfeDoCommand(openBrowser)"
+has_openFile="yes"
+script_args= # non default
+more_args= # non default
+target= # non default
+moz_uilocale= # non default
+moz_uiregion= # non default
+
+#
+# Support for Mozilla Plugable Init Scripts
+#
+moz_pis_startstop_scripts()
+{
+ # MOZ_PIS_ is the name space for "Mozilla Plugable Init Scripts"
+ # These variables and there meaning are specified in
+ # mozilla/xpfe/bootstrap/init.d/README
+ MOZ_PIS_API=2
+ MOZ_PIS_MOZBINDIR="${MOZILLA_FIVE_HOME}"
+ MOZ_PIS_SESSION_PID="$$"
+ MOZ_PIS_USER_DIR="${MOZ_USER_DIR}"
+ export MOZ_PIS_API MOZ_PIS_MOZBINDIR MOZ_PIS_SESSION_PID MOZ_PIS_USER_DIR
+
+ case "${1}" in
+ "start")
+ for curr_pis in "${MOZ_PIS_MOZBINDIR}/init.d"/S* \
+ "${HOME}/${MOZ_USER_DIR}/init.d"/S*; do
+ if [ -x "${curr_pis}" ]; then
+ case "${curr_pis}" in
+ *.sh)
+ . "${curr_pis}"
+ ;;
+ *)
+ "${curr_pis}" "start"
+ ;;
+ esac
+ fi
+ done
+ ;;
+ "stop")
+ for curr_pis in "${MOZ_PIS_MOZBINDIR}/init.d"/K* \
+ "${HOME}/${MOZ_USER_DIR}/init.d"/K*; do
+ if [ -x "${curr_pis}" ]; then
+ case "${curr_pis}" in
+ *.sh)
+ . "${curr_pis}"
+ ;;
+ *)
+ "${curr_pis}" "stop"
+ ;;
+ esac
+ fi
+ done
+ ;;
+ *)
+ echo 1>&2 "$0: Internal error in moz_pis_startstop_scripts."
+ exit 1
+ ;;
+ esac
+}
+
+# cd to ${MOZILLA_FIVE_HOME}
+if [ ! -d "${MOZILLA_FIVE_HOME}" ]; then
+ echo "Cannot cd to ${MOZILLA_FIVE_HOME}"
+ exit 1
+else
+ cd "${MOZILLA_FIVE_HOME}" || exit 1
+fi
+MOZILLA_FIVE_HOME="."
+
+#use run-mozilla.sh in MOZILLA_FIVE_HOME
+run_moz="${MOZILLA_FIVE_HOME}/run-mozilla.sh"
+MOZILLA_BIN="${MOZILLA_FIVE_HOME}/${MOZ_APPID}-bin"
+MOZILLA_REMOTE_BIN="${MOZILLA_FIVE_HOME}/mozilla-xremote-client"
+run_remote="${run_moz} ${MOZILLA_REMOTE_BIN} -a ${MOZ_APPID}"
+
+if [ ! -x "${run_moz}" ]; then
+ echo "Cannot find mozilla runtime directory. Exiting."
+ exit 1
+fi
+if [ ! -x "${MOZILLA_BIN}" ]; then
+ echo "Cannot find mozilla binary. Exiting."
+ exit 1
+fi
+if [ ! -x "${MOZILLA_REMOTE_BIN}" ]; then
+ echo "Cannot find mozilla remote binary. Exiting."
+ exit 1
+fi
+
+#
+# test for a running app
+# don't test if we doesn't have DISPLAY
+# WARNING use only remote protocol if ALREADY_RUNNING=1
+#
+if [ -n "${DISPLAY}" ]; then
+ if [ -n "${debugging}" ]; then
+ echo "${run_remote} ping()"
+ ${run_remote} 'ping()' && ALREADY_RUNNING="yes"
+ else
+ ${run_remote} 'ping()' >/dev/null 2>&1 && ALREADY_RUNNING="yes"
+ fi
+elif [ -n "${debugging}" ]; then
+ echo "warn: no DISPLAY env."
+fi
+
+#
+# parse options
+#
+while [ $# -gt 0 ]
+do
+ if [ -n "${target}" ]; then
+ # well, this can't be the target if not last
+ more_args="${more_args} ${target}"
+ target= # null
+ fi
+ case "$1" in
+ -p | --pure | -pure)
+ MOZILLA_BIN="${MOZILLA_BIN}.pure"
+ shift
+ ;;
+ -g | --debug)
+ script_args="$script_args -g"
+ debugging="yes"
+ shift
+ ;;
+ -d | --debugger)
+ if [ -n "$2" ]; then
+ script_args="$script_args -d $2"
+ shift 2
+ else
+ echo "$0: -d needs an argument"
+ exit 1
+ fi
+ ;;
+ -UILocale)
+ if [ -n "$2" ]; then
+ moz_uilocale="$2"
+ shift 2
+ else
+ echo "$0: -UILocale needs an argument"
+ exit 1
+ fi
+ ;;
+ -UIRegion)
+ if [ -n "$2" ]; then
+ moz_uiregion="$2"
+ shift 2
+ else
+ echo "$0: -UIRegion needs an argument"
+ exit 1
+ fi
+ ;;
+ -browser)
+ REMOTE_COMMAND="xfeDoCommand(openBrowser)"
+ more_args="${more_args} $1"
+ shift
+ ;;
+ -mail)
+ if [ -r "${MOZILLA_FIVE_HOME}/chrome/messenger.jar" ]; then
+ REMOTE_COMMAND="xfeDoCommand(openInbox)"
+ more_args="${more_args} $1"
+ shift
+ else
+ # no mail webapp
+ echo "no mail app in ${MOZ_APP_ID}. Exiting."
+ exit 1
+ fi
+ ;;
+ -compose)
+ if [ -r "${MOZILLA_FIVE_HOME}/chrome/messenger.jar" ]; then
+ REMOTE_COMMAND="xfeDoCommand(composeMessage)"
+ more_args="${more_args} $1"
+ shift
+ else
+ # no mail webapp
+ echo "no mail app in ${MOZ_APP_ID}. Exiting."
+ exit 1
+ fi
+ ;;
+ -edit)
+ if [ -r "${MOZILLA_FIVE_HOME}/chrome/comm.jar" ]; then
+ # can't use remote with composer
+ ALREADY_RUNNING= # null
+ more_args="${more_args} $1"
+ shift
+ else
+ echo "no edit app in ${MOZ_APP_ID}. Exiting."
+ exit 1
+ fi
+ ;;
+ -chat)
+ if [ -r "${MOZILLA_FIVE_HOME}/chrome/chatzilla.jar" ]; then
+ # can't use remote with chatzilla
+ ALREADY_RUNNING= # null
+ more_args="${more_args} $1"
+ shift
+ else
+ echo "no chat app in ${MOZ_APP_ID}. Exiting."
+ exit 1
+ fi
+ ;;
+ -webcal)
+ if [ -r "${MOZILLA_FIVE_HOME}/chrome/calendar.jar" ]; then
+ # can't use remote with calendar
+ ALREADY_RUNNING= # null
+ more_args="${more_args} $1"
+ shift
+ else
+ echo "no calendar app in ${MOZ_APP_ID}. Exiting."
+ exit 1
+ fi
+ ;;
+ -*)
+ more_args="${more_args} $1"
+ shift
+ ;;
+ *)
+ target="$1"
+ shift
+ ;;
+ esac
+done
+
+#
+# use remote protocol if running
+#
+if [ -n "${ALREADY_RUNNING}" ]; then
-# LANG, MOZILLA_UILOCALE, MOZILLA_UIREGION
-if [ -n "$LANG" -a ! -n "${MOZILLA_UILOCALE}" ]; then
+ #process $target
+ if [ -n "${target}" ]; then
+ if [ `expr "${target}" : '.*:.*'` -eq 0 ]; then
+ if [ `expr "${target}" : '/.*'` -eq 0 ]; then
+ target="${curdir}/${target}"
+ fi
+ if [ -r "${target}" -a -n "${has_openFile}" ]; then
+ REMOTE_COMMAND="openFile(${target})"
+ elif [ -r "${target}" -o -d "${target}" ]; then
+ if [ -n "${LOCATION}" ]; then
+ REMOTE_COMMAND="openURL(file://${target},${LOCATION})"
+ else
+ REMOTE_COMMAND="openURL(file://${target})"
+ fi
+ else
+ # not a URI/file/dir
+ echo "Invalid target: ${target}. Exiting"
+ exit 1
+ fi
+ else
+ # an URI
+ if [ -n "${LOCATION}" ]; then
+ REMOTE_COMMAND="openURL(${target},${LOCATION})"
+ else
+ REMOTE_COMMAND="openURL(${target})"
+ fi
+ fi
+ fi
+
+ # go remote
+ # FIXME: problems with freedesktop StartupNotify
+ # we must cancel StartupNotify before exec? how?
+ [ -n "${debugging}" ] && echo "exec ${run_remote} ${REMOTE_COMMAND}"
+ exec ${run_remote} ${REMOTE_COMMAND}
+fi
+
+#
+# new instance support
+#
+
+# UILocale, UIRegion
+if [ -n "$LANG" -a -z "${MOZILLA_UILOCALE}" ]; then
_locale="${LANG%%.*}"
if [ "${_locale}" != "en_US" -a "${_locale}" != "C" ]; then
_region="${_locale##*_}"
_locale="${_locale%_*}"
- [ -r chrome/${_locale}-${_region}.jar ] && \
- MOZILLA_EXEC="${MOZILLA_EXEC} -UILocale ${_locale}-${_region}"
+ [ -r "${MOZILLA_FIVE_HOME}/chrome/${_locale}-${_region}.jar" ] && \
+ MOZILLA_UILOCALE="${_locale}-${_region}"
fi
-elif [ -n "${MOZILLA_UILOCALE}" ]; then
- MOZILLA_EXEC="${MOZILLA_EXEC} -UILocale ${MOZILLA_UILOCALE}"
- if [ -n "${MOZILLA_UIREGION}" ]; then
- MOZILLA_EXEC="${MOZILLA_EXEC} -UIRegion ${MOZILLA_UIREGION}"
+fi
+if [ -z "${moz_uilocale}" -a -n "${MOZILLA_UILOCALE}" ]; then
+ moz_uilocale="${MOZILLA_UILOCALE}"
+fi
+if [ -z "${moz_uiregion}" -a -n "${MOZILLA_UIREGION}" ]; then
+ moz_uiregion="${MOZILLA_UIREGION}"
+fi
+if [ -n "${moz_uiregion}" -a -z "${moz_uilocale}" ]; then
+ moz_uilocale="en-US"
+fi
+if [ -n "${moz_uilocale}" ]; then
+ if [ -n "${moz_uiregion}" ]; then
+ more_args="-UIRegion ${moz_uiregion} ${more_args}"
fi
+ more_args="-UILocale ${moz_uilocale} ${more_args}"
fi
+#
# find a /dev/dsp handler
+#
+
+# FIXME: problems with esddsp
case "${MOZILLA_DSP}" in
# [Ee][Ss][Dd]|esddsp) # Use the esd dsp wrapper
# MOZILLA_DSP="esddsp"
@@ -37,49 +353,31 @@
MOZILLA_DSP="artsdsp"
;;
[Nn][Oo][Nn][Ee]) # Direct dsp output
- MOZILLA_DSP=""
+ MOZILLA_DSP= # null
;;
*) # Guest one (auto)
if [ -n "${KDE_FULL_SESSION}" ]; then
- MOZILLA_DSP="artsdsp"
-# elif [ -r ${HOME}/.esd_auth ]; then
-# MOZILLA_DSP="esddsp"
+ MOZILLA_DSP="artsdsp"
+# elif [ -r ${HOME}/.esd_auth ]; then
+# MOZILLA_DSP="esddsp"
else
- MOZILLA_DSP=""
+ MOZILLA_DSP= # null
fi
;;
esac
-
if [ -n "${MOZILLA_DSP}" ] && type "${MOZILLA_DSP}" > /dev/null 2>&1; then
- MOZILLA_EXEC="${MOZILLA_DSP} ${MOZILLA_EXEC}"
+ run_moz="${MOZILLA_DSP} ${run_moz}"
fi
-case $1 in
- -browser)
- REMOTE_COMMAND="xfeDoCommand (openBrowser)"
- ;;
- -mail)
- REMOTE_COMMAND="xfeDoCommand (openInbox)"
- ;;
- -compose)
- REMOTE_COMMAND="xfeDoCommand (composeMessage)"
- ;;
- -*)
- exec ${MOZILLA_EXEC} "$@"
- ;;
- *)
- if [ -n "${LOCATION}" ]; then
- REMOTE_COMMAND="openURL($@,$LOCATION)"
- else
- REMOTE_COMMAND="openURL($@)"
- fi
- ;;
-esac
+# real invocation
+moz_pis_startstop_scripts "start"
-# process found
-${MOZILLA_REMOTE_EXEC} "ping()" >/dev/null 2>&1 &&
-${MOZILLA_REMOTE_EXEC} "${REMOTE_COMMAND}" && exit 0
+if [ -n "${debugging}" ]; then
+ echo "${run_moz} ${script_args} ${MOZILLA_BIN} ${more_args}"
+fi
+${run_moz} ${script_args} ${MOZILLA_BIN} ${more_args} ${target}
+exitcode=$?
-# no existing process
-exec ${MOZILLA_EXEC} "$@"
+moz_pis_startstop_scripts "stop"
+exit $exitcode
--- mozilla-1.7.5_1,2.patch ends here ---
More information about the freebsd-gnome
mailing list