Bug 234124 - RFE: Port the pluggable shell script API to FireFox/Thunderbird/Sunbird etc

r=bryner@brianryner.com, sr=bryner@brianryner.com

Checking in patch for Roland Mainz <roland.mainz@nrubsig.org>
This commit is contained in:
pkw%us.ibm.com 2004-02-20 18:13:47 +00:00
Родитель b439daa438
Коммит b6d6299c06
8 изменённых файлов: 302 добавлений и 82 удалений

Просмотреть файл

@ -316,11 +316,11 @@ endif
endif # MOZ_COMPONENTLIB
ifdef MOZ_PHOENIX
tier_99_dirs += browser
tier_99_dirs += browser xpfe/bootstrap/init.d
endif
ifdef MOZ_THUNDERBIRD
tier_99_dirs += mail
tier_99_dirs += mail xpfe/bootstrap/init.d
endif
ifdef MOZ_STANDALONE_COMPOSER

Просмотреть файл

@ -188,8 +188,9 @@ endif
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
firefox:: mozilla.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk
cat $< | sed -e "s|%MOZAPPDIR%|$(mozappdir)|" \
-e "s|%MOZ_USER_DIR%|.phoenix|" \
-e "s|%MREDIR%|$(mredir)|" \
-e "s|mozilla-bin|$(PROGRAM)|g" > $@
-e "s|%MOZILLA-BIN%|$(PROGRAM)|g" > $@
chmod +x $@
libs:: firefox

Просмотреть файл

@ -16,7 +16,7 @@
# Reserved.
#
## $Id: mozilla.in,v 1.2 2003-07-26 07:51:05 bryner%brianryner.com Exp $
## $Id: mozilla.in,v 1.3 2004-02-20 18:13:45 pkw%us.ibm.com Exp $
##
## Usage:
##
@ -29,6 +29,46 @@
## the mozilla-bin binary to work.
##
moz_pis_startstop_scripts()
{
MOZ_USER_DIR="%MOZ_USER_DIR%"
# 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="${dist_bin}"
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 "${dist_bin}/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 "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/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
}
#uncomment for debugging
#set -x
@ -77,7 +117,7 @@ fi
script_args=""
moreargs=""
debugging=0
MOZILLA_BIN="mozilla-bin"
MOZILLA_BIN="%MOZILLA-BIN%"
if [ "$OSTYPE" = "beos" ]; then
mimeset -F $MOZILLA_BIN
@ -87,7 +127,7 @@ while [ $# -gt 0 ]
do
case "$1" in
-p | -pure)
MOZILLA_BIN="mozilla-bin.pure"
MOZILLA_BIN="%MOZILLA-BIN%.pure"
shift
;;
-g | --debug)
@ -108,8 +148,19 @@ done
export MRE_HOME
eval "set -- $moreargs"
## 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
exec "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
exitcode=$?
## Stop addon scripts
moz_pis_startstop_scripts "stop"
exit $exitcode
# EOF.

Просмотреть файл

@ -169,8 +169,9 @@ endif
ifneq (,$(filter-out OS2 WINNT Darwin,$(OS_ARCH)))
thunderbird:: mozilla.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk
cat $< | sed -e "s|%MOZAPPDIR%|$(mozappdir)|" \
-e "s|%MOZ_USER_DIR%|.thunderbird|" \
-e "s|%MREDIR%|$(mredir)|" \
-e "s|mozilla-bin|$(PROGRAM)|g" > $@
-e "s|%MOZILLA-BIN%|$(PROGRAM)|g" > $@
chmod +x $@
libs:: thunderbird

Просмотреть файл

@ -16,7 +16,7 @@
# Reserved.
#
## $Id: mozilla.in,v 1.1 2003-04-05 20:52:38 mscott%netscape.com Exp $
## $Id: mozilla.in,v 1.2 2004-02-20 18:13:45 pkw%us.ibm.com Exp $
##
## Usage:
##
@ -29,60 +29,95 @@
## the mozilla-bin binary to work.
##
moz_pis_startstop_scripts()
{
MOZ_USER_DIR="%MOZ_USER_DIR%"
# 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="${dist_bin}"
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 "${dist_bin}/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 "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/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
}
#uncomment for debugging
#set -x
moz_libdir=%MOZAPPDIR%
MRE_HOME=%MREDIR%
# honor MOZILLA_FIVE_HOME if it's there
if [ -n "$MOZILLA_FIVE_HOME" ] ; then
dist_bin="$MOZILLA_FIVE_HOME"
# 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"`
run_moz="$curdir/run-mozilla.sh"
if test -x "$run_moz"; then
dist_bin=$curdir
found=1
else
# 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"`
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`
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
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`
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
script_args=""
moreargs=""
debugging=0
MOZILLA_BIN="mozilla-bin"
MOZILLA_BIN="%MOZILLA-BIN%"
if [ "$OSTYPE" = "beos" ]; then
mimeset -F $MOZILLA_BIN
@ -92,7 +127,7 @@ while [ $# -gt 0 ]
do
case "$1" in
-p | -pure)
MOZILLA_BIN="mozilla-bin.pure"
MOZILLA_BIN="%MOZILLA-BIN%.pure"
shift
;;
-g | --debug)
@ -113,8 +148,19 @@ done
export MRE_HOME
eval "set -- $moreargs"
## 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
exec "$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
"$dist_bin/run-mozilla.sh" $script_args "$dist_bin/$MOZILLA_BIN" "$@"
exitcode=$?
## Stop addon scripts
moz_pis_startstop_scripts "stop"
exit $exitcode
# EOF.

Просмотреть файл

@ -38,18 +38,28 @@ libs:: moz_patch_checker.dtksh
$(INSTALL) $(IFLAGS2) $< $(DIST)/bin
install:: moz_patch_checker.dtksh
chmod a+x $<
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(bindir)
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)
libs:: S02solaris_patchchecker.sh
chmod a+x $<
$(INSTALL) $(IFLAGS2) $< $(DIST)/bin/init.d
install:: S02solaris_patchchecker.sh
chmod a+x $<
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(bindir)/init.d
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/init.d
endif
ifdef MOZ_CALENDAR
libs:: S80calendar_fix_permissions_bug_230617
chmod a+x $<
$(INSTALL) $(IFLAGS2) $< $(DIST)/bin/init.d
install:: S80calendar_fix_permissions_bug_230617
chmod a+x $<
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/init.d
endif
libs:: README
$(INSTALL) $< $(DIST)/bin/init.d
install:: README
$(SYSINSTALL) $(IFLAGS1) $< $(DESTDIR)$(bindir)/init.d
$(SYSINSTALL) $(IFLAGS1) $< $(DESTDIR)$(mozappdir)/init.d

Просмотреть файл

@ -15,20 +15,123 @@ user's profile directory), on termination those scripts prefixed with 'K'
are being executed (first those in user's profile dir, finally those in
mozilla's installation directory).
When executing each script a single argument is passed to it - argument
'stop' for scripts prefixed with 'K' and the argument 'start' for scripts
prefixed with 'S'.
** Rules (for Mozilla Pluggable Init Script API Version 2):
* When executing each script a single argument is passed to it - argument
'stop' for scripts prefixed with 'K' and the argument 'start' for scripts
prefixed with 'S'.
An exception of this rule are scripts with the suffix *.sh - they are called
"inline" in the current shell process which starts/terminates Mozilla. These
scripts have FULL ACCESS to all variables of the calling script (which means
these scripts can set/modify/unset environment variables used by Mozilla).
Since these scripts run in the same shell the author of such scripts should
ensure that no namespace collisions occur (e.g. accidential modify variable
names used by the parent script).
An exception of this rule are scripts with the suffix *.sh - they are called
"inline" in the current shell process which starts/terminates Mozilla. These
scripts have FULL ACCESS to all variables of the calling script (which means
these scripts can set/modify/unset environment variables used by Mozilla).
Since these scripts run in the same shell the author of such scripts should
ensure that no namespace collisions occur (e.g. accidential modify variable
names used by the parent script).
* Any files which do not match the [SK][0-9][0-9]* pattern are FORBIDDEN
in ${HOME}/.mozilla/init.d/ and %dist_bin%/init.d/. The only
exception is this README file.
Any files which do not match the [SK][0-9][0-9]* pattern are FORBIDDEN
in ${HOME}/.mozilla/init.d/ and %user_profile%/init.d/. The only
exception is this README file.
* The following environment variables are defined if ${MOZ_PIS_API} is equal
or greater than "2" (none of these variables is guranteed to exists before
API version "2"):
- "MOZ_PIS_API":
Integer value describing the version of the "Mozilla Pluggable Init Script
API". Current version is "2".
- "MOZ_PIS_MOZBINDIR":
Relative (!!) or absolute path to the location where the mozilla binary
is located.
- "MOZ_PIS_SESSION_PID":
Process id of the initial mozilla launch script. In this case used as
session identifier. The value identifies the current mozilla
session. Note that one user may run multiple mozilla sessions (with
differnt profiles) in parallel. "stop"-scripts must ensure that they
only affect resources created by the "start"-script of the same session
(identified via "MOZ_PIS_SESSION_PID") and same machine (use 'uname -n'
on demand).
- "MOZ_PIS_USER_DIR":
Name of the user dir (e.g. ".mozilla" for Mozilla, ".phoenix" for Phoenix
etc.)
The full path to the users profile base directory can be constructed using
"${HOME}/${MOZ_PIS_USER_DIR}/"
- "HOME":
Absolute path to users home directory.
* Shell scripts must test the existence of any MOZ_PIS_*-variables before using
them. It may happen that any of these variables may not exists in a future
version of this API.
If any of the requested MOZ_PIS_*-variables is not set the script should print
an error message to stderr and exit with error code 1.
* Mozilla pluggable init shell scripts MUST NOT rely on any other variable names
than those starting with "MOZ_PIS_";
"HOME" is the only exception of this rule.
* The namespace "MOZ_PIS"/"moz_pis" is reserved for the "Mozilla Pluggable
Init Script API". Scripts MUST NOT use function names, file names or variable
name which start with "MOZ_PIS"/"moz_pis".
* Scripts ending with *.sh (=scripts called in the same shell process as the
mozilla startup script) MUST use their own name space for function and
variable names.
The usage of single-letter variable names (Example: ${i}) is STRICTLY
FORBIDDEN!
This rule does not apply to scripts which operate in their own child process.
* Scripts ending with *.sh (=scripts called in the same shell process as the
mozilla startup script) restricted to the Bourne Shell syntax.
Any extensions supported by ksh, ksh93, dtksh and bash are FORBIDDEN.
This restriction does not apply to non-inline shell scripts; they may choose
their interpreter freely (even #!/usr/bin/perl).
* Pluggable shell scripts must have the "readable" and "executable" permission
bit (e.g. chmod a+rx) set for "user", "group" and "others" when being placed
in */init.d/
* The only allowed way to test whether a mozilla supports the Mozilla Pluggable
Init Script API is to test for "$dist_bin/init.d/README".
The following fragment of a XPI install.js script illustrates the test:
-- snip --
/* Test whether this mozilla supports pluggable init shell scripts */
var fProgram = getFolder("Program");
var init_d_readme_path = getFolder(fProgram, "init.d/README");
logComment("# Checking whether '" + init_d_readme_path + "' exists.");
if (!File.exists(init_d_readme_path)) {
logComment("# init_d_readme_path missing");
alert("Your version of Mozilla does not support " +
"pluggable init shell scripts.\n" +
"You need at least Mozilla 1.7a (or later).");
cancelInstall(ACCESS_DENIED);
return;
}
-- snip --
* Scripts must be able to handle that "start" and "stop" are being called
multiple times (for example when one user works in different profiles).
The PIS framework provides "MOZ_PIS_SESSION_PID" to identify the current
running session.
* There is no gurantee that "stop"-scripts are being called. The user, admin
or a reboot may prevent the execution of the "stop" scripts; the "start"
scripts should include a check to cleanup orphaned resources (orphaned
resources can simply be identified via checking whether MOZ_PIS_SESSION_PID
is still a valid PID).
* Inline shell scripts are allowed to abort the start sequence with "exit".
This will PREVENT mozilla from being launched. USE THIS FUNCTIONALITY ONLY
in EMERGENCY cases or if the user has been asked (GUI etc.) to abort.
It is STRONGLY recommended to call 'moz_pis_startstop_scripts "stop"' to
ensure that the "stop"-scripts are being executed (please do not do that
from "stop" scripts, that will end in an endless loop).
Example:
-- snip --
if [ ! -f "/usr/local/lib/libgtk.so" ] ; then
echo "${0}: Fatal error: libgtk.so not found." 1>&2
moz_pis_startstop_scripts "stop"
exit 1
fi
-- snip --
** Rules (for Mozilla Pluggable Init Script API Version 3):
NOT DEFINED YET
# EOF.

Просмотреть файл

@ -16,7 +16,7 @@
# Reserved.
#
## $Id: mozilla.in,v 1.5 2004-02-05 20:32:05 cbiesinger%web.de Exp $
## $Id: mozilla.in,v 1.6 2004-02-20 18:13:46 pkw%us.ibm.com Exp $
##
## Usage:
##
@ -29,33 +29,41 @@
## the mozilla-bin binary to work.
##
moz_startstop_addon_scripts()
moz_pis_startstop_scripts()
{
MOZ_USER_DIR="%MOZ_USER_DIR%"
# 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="${dist_bin}"
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 i in ${dist_bin}/init.d/S* ${HOME}/${MOZ_USER_DIR}/init.d/S* ; do
if [ -r "${i}" ] ; then
case "${i}" in
*.sh) . "${i}" ;;
*) sh "${i}" "start" ;;
for curr_pis in "${dist_bin}/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 i in ${HOME}/${MOZ_USER_DIR}/init.d/K* ${dist_bin}/init.d/K* ; do
if [ -r "${i}" ] ; then
case "${i}" in
*.sh) . "${i}" ;;
*) sh "${i}" "stop" ;;
for curr_pis in "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/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_startstop_addon_scripts."
echo 1>&2 "$0: Internal error in moz_pis_startstop_scripts."
exit 1
;;
esac
@ -147,7 +155,7 @@ export MRE_HOME
eval "set -- $moreargs"
## Start addon scripts
moz_startstop_addon_scripts "start"
moz_pis_startstop_scripts "start"
if [ $debugging = 1 ]
then
@ -157,7 +165,7 @@ fi
exitcode=$?
## Stop addon scripts
moz_startstop_addon_scripts "stop"
moz_pis_startstop_scripts "stop"
exit $exitcode
# EOF.