/[gentoo-src]/mozilla-launcher/mozilla-launcher
Gentoo

Contents of /mozilla-launcher/mozilla-launcher

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.59 - (hide annotations) (download)
Wed Mar 12 18:42:08 2008 UTC (6 years, 4 months ago) by armin76
Branch: MAIN
CVS Tags: HEAD
Changes since 1.58: +0 -4 lines
Remove useless warning

1 agriffis 1.1 #!/bin/bash
2 armin76 1.58 # $Header: /var/cvsroot/gentoo-src/mozilla-launcher/mozilla-launcher,v 1.57 2008/01/01 14:07:46 armin76 Exp $
3 agriffis 1.1 #
4 agriffis 1.27 # Portions of this file are extracted from the mozilla.org distributed scripts.
5     # Those portions are Copyright (C) 1998 Netscape Communmications Corporation and
6 armin76 1.57 # released under the NPL as detailed in
7     # /usr/lib/mozilla-firefox/firefox and /usr/lib/mozilla-thunderbird/thunderbird.
8 agriffis 1.27 #
9 armin76 1.57 # The remainder of this file is Copyright 1999-2008 Gentoo Foundation
10 agriffis 1.1 # Distributed under the terms of the GNU General Public License v2
11    
12 agriffis 1.37 : ${MOZILLA_LAUNCHER_DEBUG:=false}
13    
14 agriffis 1.1 # Make sure necessary progs are in the PATH
15 armin76 1.57 PATH=/usr/bin:/bin:$PATH
16 kloeri 1.56 unset GREP_OPTIONS
17 agriffis 1.1
18     main() {
19 agriffis 1.33 declare args mozargs urls u i mozpid debugger debugging=false
20 agriffis 1.45 declare candidates retval=0 progname
21 agriffis 1.33 declare zero=${0##*/}
22 agriffis 1.1
23 agriffis 1.27 # We'd like to believe that we were called via one of the symlinks in
24     # /usr/bin. However OOo sports some questionable behavior: it follows the
25     # symlinks instead of relying on UNIX filesystem semantics, so $zero is
26     # "/usr/libexec/mozilla-launcher" in that case. We workaround this
27     # misbehavior by using a stub in /usr/bin instead of a symlink. The stub sets
28     # MOZILLA_LAUNCHER and execs /usr/libexec/mozilla-launcher
29     [[ -n $MOZILLA_LAUNCHER ]] && zero=$MOZILLA_LAUNCHER
30 agriffis 1.35 unset MOZILLA_LAUNCHER
31 agriffis 1.27
32 agriffis 1.1 # Determine if we're called as firefox or mozilla and set up
33     # variables appropriately
34 agriffis 1.15 which_browser || exit 1 # note: modifies $zero
35 agriffis 1.1
36     # Parse the command-line and set args, mozargs and urls
37     parse_cmdline "$@" || exit 1
38    
39 agriffis 1.7 # Make sure we'll get at least an empty window/tab
40     # when nothing else is specified on the cmdline.
41 agriffis 1.25 if [[ $# -eq 0 && ${#mozargs[@]} == 0 ]]; then
42 agriffis 1.47 if [[ $zero == sunbird* ]]; then
43 agriffis 1.50 args=-calendar
44 agriffis 1.15 else
45     urls=('')
46     fi
47 agriffis 1.7 fi
48    
49 agriffis 1.1 # Set the candidates array with find_running
50     find_running
51    
52 agriffis 1.7 # Handle some special args. We want to handle these ourselves so
53     # that we can find the right window on the screen to target.
54 agriffis 1.1 set -- "${mozargs[@]}"
55     while [[ $# -gt 0 ]]; do
56     case $1 in
57     -mail) try_running 'xfeDoCommand(openInbox)' ;;
58 agriffis 1.34 -compose)
59 agriffis 1.25 if [[ -n $2 ]]; then
60     try_running "xfeDoCommand(composeMessage,$2)" && shift
61     else
62     try_running "xfeDoCommand(composeMessage)"
63     fi ;;
64 agriffis 1.7 -remote) try_running "$2" && shift ;;
65 agriffis 1.44 *) false ;;
66 agriffis 1.1 esac
67     [[ $? -eq 0 ]] && { shift; continue; }
68     # Error path: try_running failed, so prepend remaining mozargs to
69 agriffis 1.7 # args and drop through to call the browser binary
70 agriffis 1.25 args=("$@" "${args[@]}")
71 agriffis 1.1 break
72     done
73    
74 agriffis 1.7 # If there's no running browser, or we've got args, start an
75 agriffis 1.8 # instance.
76 agriffis 1.7 if [[ ${#args[@]} -gt 0 ]] || ! try_running 'ping()'; then
77 agriffis 1.8 # Assume the first url should just be tacked on the end.
78 agriffis 1.23 try_start "${args[@]}" ${urls:+"${urls[0]}"} || exit
79 agriffis 1.26 mozpid=$!
80 agriffis 1.8 set -- "${urls[@]}"; shift; urls=("$@") # shift off the first url
81 agriffis 1.7 candidates=$DISPLAY
82     args=()
83    
84     # Handle case of multiple URLs by waiting for browser to map to
85     # the screen so that it can be found by $remote below
86     if [[ ${#urls[@]} -gt 0 ]]; then
87     if [[ -x /usr/bin/xtoolwait ]]; then
88     xtoolwait sleep 10 # hope it hasn't mapped yet
89     else
90 agriffis 1.8 sleep 1
91     for ((i = 0; i < 40; i = i + 1)); do
92     try_running 'ping()' && break || sleep 0.25
93 agriffis 1.7 done
94     fi
95     fi
96 agriffis 1.1 fi
97    
98     # Handle multiple URLs by looping over the xremote call
99     for u in "${urls[@]}"; do
100 kloeri 1.56 u="$(sanitize_url $u)"
101 agriffis 1.7 if [[ $u == mailto:* ]]; then
102     try_running "mailto(${u#mailto:})" || retval=$?
103 agriffis 1.1 else
104 agriffis 1.27 if [[ -n $MOZILLA_NEWTYPE ]]; then
105     try_running "openURL($u,new-$MOZILLA_NEWTYPE)" || retval=$?
106 anarchy 1.52 elif [[ ( $zero == firefox* || $zero == seamonkey* ) && -n $u ]]; then
107 agriffis 1.29 # Don't override preferences set in the browser #82653
108     try_running "openURL($u)" || retval=$?
109 agriffis 1.32 elif [[ -n $u ]]; then
110     try_running "openURL($u,new-window)" || retval=$?
111 agriffis 1.27 else
112 agriffis 1.32 try_running "xfeDoCommand(openBrowser)" || retval=$?
113 agriffis 1.27 fi
114 agriffis 1.1 fi
115     done
116    
117     # Will only wait here if browser was started by this script
118 agriffis 1.26 if [[ -n ${mozpid} ]]; then
119     wait ${mozpid}
120 agriffis 1.1 retval=$?
121 agriffis 1.26 [[ ${retval} == 0 ]] \
122     || echo "${mozbin##*/} exited with non-zero status (${retval})" >&2
123     moz_pis_startstop_scripts stop
124 agriffis 1.1 fi
125    
126     exit $retval
127     }
128    
129     which_browser() {
130 agriffis 1.33 # Newer launcher stubs will set MOZILLA_LIBDIR so that the installation
131     # location is controlled by the ebuild rather than mozilla-launcher, finally!
132 agriffis 1.37 if [[ ! -d $MOZILLA_LIBDIR ]]; then
133     unset MOZILLA_LIBDIR
134 agriffis 1.33 fi
135    
136 armin76 1.57 # Support mozilla-firefox, mozilla-firefox-bin, mozilla-thunderbird,
137     # mozilla-thunderbird-bin, mozilla-sunbird, mozilla-sunbird-bin,
138     # xulrunner!
139 agriffis 1.9 # This case statement does the setup for source-based browsers and
140     # just drops through for binary-based browsers.
141     case $zero in
142 agriffis 1.1 *fox)
143 armin76 1.57 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/usr/lib/mozilla-firefox"}
144 agriffis 1.1 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
145     mozbin=$MOZILLA_FIVE_HOME/firefox-bin
146     ;;
147    
148 agriffis 1.18 *sunbird)
149 armin76 1.57 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/usr/lib/mozilla-sunbird"}
150 agriffis 1.18 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
151     mozbin=$MOZILLA_FIVE_HOME/sunbird-bin
152 agriffis 1.1 ;;
153    
154 agriffis 1.6 *thunderbird)
155 armin76 1.57 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/usr/lib/mozilla-thunderbird"}
156 agriffis 1.6 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
157     mozbin=$MOZILLA_FIVE_HOME/thunderbird-bin
158 agriffis 1.9 ;;
159    
160 agriffis 1.46 *seamonkey)
161 agriffis 1.47 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/usr/lib/seamonkey"}
162 agriffis 1.46 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
163     mozbin=$MOZILLA_FIVE_HOME/seamonkey-bin
164     ;;
165    
166 kloeri 1.55 *xulrunner)
167     export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/usr/lib/xulrunner"}
168     remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
169     mozbin=$MOZILLA_FIVE_HOME/xulrunner-bin
170 armin76 1.58 xulparams=$XUL_PARAMS
171 kloeri 1.55 ;;
172    
173 agriffis 1.9 *-bin)
174     unset mozbin # just in case...
175     ;; # but don't do anything yet
176 agriffis 1.6
177 agriffis 1.1 *)
178     echo "$0: unknown browser" >&2
179     return 1
180     ;;
181     esac
182    
183 agriffis 1.9 # Attempt to use -bin version if source version isn't available
184     if [[ -n $mozbin && ! -f $mozbin ]]; then
185     unset mozbin # it's bogus anyway
186     zero=${zero}-bin
187     fi
188    
189     case $zero in
190     *fox-bin)
191 agriffis 1.37 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/opt/firefox"}
192 agriffis 1.9 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
193     mozbin=$MOZILLA_FIVE_HOME/firefox-bin
194     ;;
195    
196 agriffis 1.17 *sunbird-bin)
197 agriffis 1.37 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/opt/sunbird"}
198 agriffis 1.17 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
199     mozbin=$MOZILLA_FIVE_HOME/sunbird-bin
200     ;;
201    
202 agriffis 1.10 *thunderbird-bin)
203 agriffis 1.37 export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/opt/thunderbird"}
204 agriffis 1.9 remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
205     mozbin=$MOZILLA_FIVE_HOME/thunderbird-bin
206     ;;
207 agriffis 1.46
208     *seamonkey-bin)
209     export MOZILLA_FIVE_HOME=${MOZILLA_LIBDIR:-"/opt/seamonkey"}
210     remote=$MOZILLA_FIVE_HOME/mozilla-xremote-client
211 agriffis 1.49 mozbin=$MOZILLA_FIVE_HOME/seamonkey-bin
212 agriffis 1.46 ;;
213 agriffis 1.9 esac
214    
215     # Make sure we got something
216     if [[ -z $mozbin || ! -f $mozbin ]]; then
217     echo "$0: can't find the browser :-(" >&2
218     return 1
219     fi
220    
221 agriffis 1.20 # Newer xremote has the ability to specify a target program. Base
222     # this on ${zero} but workaround bug 247754 for thunderbird
223     progname=${zero%-bin}
224     if [[ $progname == thunderbird ]]; then
225 agriffis 1.19 grep -q '"0\.[78]"' ${MOZILLA_FIVE_HOME}/defaults/pref/*.js \
226 agriffis 1.20 && progname=Thunderbird
227 agriffis 1.15 fi
228    
229 agriffis 1.9 # Set LD_LIBRARY_PATH (also set in /etc/env.d/10*)
230     export LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME:$MOZILLA_FIVE_HOME/plugins${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
231    
232 agriffis 1.41 # Make sure netscape-compatible plugins are picked up
233     [[ -z $MOZ_PLUGIN_PATH ]] && export MOZ_PLUGIN_PATH=/usr/lib/nsbrowser/plugins
234    
235 agriffis 1.1 return 0
236     }
237    
238     # parse_cmdline: set args, mozargs and urls, which are dynamically
239     # scoped in main()
240     parse_cmdline() {
241     # Validate the args and extract the urls
242     args=() # general arguments
243 agriffis 1.7 mozargs=() # arguments that we handle specifically
244 agriffis 1.1 urls=() # urls to open
245     while [[ $# -ne 0 ]] ; do
246     if [[ $1 == -* ]] ; then
247     case "${1#-}" in
248 agriffis 1.28 # options we handle specially
249     g|-debug)
250     debugging=true
251     shift 1 ;;
252     d|-debugger)
253     debugging=true
254     debugger=$2
255 agriffis 1.1 shift 2 ;;
256 agriffis 1.31 a)
257     # ignore -a which xfhelp4 passes for no reason
258     shift 2 ;;
259 agriffis 1.34 register)
260     # just do this immediately
261     update_chrome
262     exit $? ;;
263 agriffis 1.41 unregister)
264     # just do this immediately
265     remove_chrome
266     exit $? ;;
267 agriffis 1.28 # mozargs with 0 arguments
268 agriffis 1.25 mail)
269 agriffis 1.7 mozargs=("${mozargs[@]}" "$1")
270 agriffis 1.1 shift 1 ;;
271 agriffis 1.28 # mozargs with 0 or 1 arguments
272 agriffis 1.25 compose|remote)
273     if [[ -n $2 ]]; then
274     mozargs=("${mozargs[@]}" "$1" "$2")
275     shift 2
276     else
277     mozargs=("${mozargs[@]}" "$1")
278 agriffis 1.28 shift 1
279 agriffis 1.25 fi ;;
280 agriffis 1.28 # options we pass through 1 argument
281     height|width|CreateProfile|P|UILocale|contentLocale|edit|chrome)
282     args=("${args[@]}" "$1" "$2")
283     shift 2 ;;
284     # unrecognized options are simply passed through
285 agriffis 1.1 *)
286     args=("${args[@]}" "$1")
287     shift 1 ;;
288     esac
289     else
290 agriffis 1.3 if [[ $1 == *://*/* ]]; then
291     urls=("${urls[@]}" "$1")
292     elif [[ $1 == *://* ]]; then
293     # as of mozilla_1.7_rc1 the url checking changed for xremote
294     # calls... now three slashes are required for urls, otherwise we
295     # get the following error from xremote:
296     # Error: Failed to send command: 509 internal error
297     urls=("${urls[@]}" "$1/")
298 agriffis 1.24 elif [[ $1 != /* && -e $1 ]]; then
299     # relative path to a file, transform to URL syntax
300 agriffis 1.1 urls=("${urls[@]}" "file://$PWD/$1")
301 agriffis 1.24 elif [[ $1 == /* && -e $1 ]]; then
302     # absolute path to a file, transform to URL syntax
303     urls=("${urls[@]}" "file://$1")
304 agriffis 1.6 elif [[ $1 != *:* && $1 == *@* ]]; then
305     # looks like an email address, prefix with mailto: so we can
306     # recognize it later.
307     urls=("${urls[@]}" "mailto:$1")
308 agriffis 1.1 else
309 agriffis 1.3 # no idea what this is! just add it to urls and hope it works
310     urls=("${urls[@]}" "$1")
311 agriffis 1.1 fi
312     shift
313     fi
314     done
315    
316     return 0
317     }
318    
319     # find_running: sets the candidates array
320     find_running() {
321 agriffis 1.33 declare screens s
322 agriffis 1.1
323     # Try to start in an existing session; check all screens
324 agriffis 1.53 # with priority on the current screen.
325     #
326     # If xdpyinfo isn't installed, then this will just check $DISPLAY
327 agriffis 1.2 screens=("$DISPLAY"
328 agriffis 1.53 $(xdpyinfo 2>/dev/null | awk '
329 agriffis 1.34 /^name of display:/ {
330 agriffis 1.1 disp = substr($NF, 0, match($NF, /\.[^.]*$/)-1)
331     }
332     /^number of screens:/ {
333 agriffis 1.2 for (i = 0; i < $NF; i++) {
334     this = sprintf("%s.%d", disp, i)
335     if (this != ENVIRON["DISPLAY"])
336     print this
337     }
338 agriffis 1.1 }')
339     )
340    
341 agriffis 1.14 # We used to check displays with xwininfo here but that isn't
342 agriffis 1.45 # necessary with the advent of -a programname.
343 agriffis 1.14 # Instead just test for a running program if we're on a local
344     # display.
345     if [[ $DISPLAY != :* ]] || killall -0 ${mozbin##*/} &>/dev/null; then
346     candidates=("${screens[@]}")
347     else
348 agriffis 1.2 candidates=()
349     fi
350 agriffis 1.1 }
351    
352     # try_running: try to use an existing browser to run a command
353     try_running() {
354 agriffis 1.33 declare s retval=2 # default == can't find an instance
355 agriffis 1.1
356     # Try mozilla-xremote-client on each candidate screen.
357 agriffis 1.45 for s in "${candidates[@]}"; do
358     DISPLAY=$s $remote -a ${progname} "$@"
359     retval=$?
360     if [[ $retval -eq 0 ]]; then
361     candidates=("$s") # for future calls
362     return 0
363 agriffis 1.12 fi
364 agriffis 1.45 done
365 agriffis 1.1
366 agriffis 1.7 # Might as well do this error interpretation here
367     case $retval in
368     1) echo "Unable to connect to X server" >&2 ;;
369     2) echo "No running windows found" >&2 ;;
370     3) echo "Browser doesn't understand command" >&2 ;;
371     *) echo "Unknown error $retval from mozilla-xremote-client" >&2 ;;
372     esac
373    
374 agriffis 1.1 return $retval
375     }
376    
377 agriffis 1.28 # set_debugger: set $debugger
378     set_debugger() {
379 agriffis 1.33 declare d
380 agriffis 1.28 : ${debugger:=ddd gdb}
381    
382     # Try to find a workable debugger
383     for d in ${debugger}; do
384     type -fp $d &>/dev/null || continue
385     debugger=$d
386     return 0
387     done
388    
389     echo "Can't find debugger (${debugger})" >&2
390     exit 1
391     }
392    
393 agriffis 1.1 # try_start: attempt to start a browser
394     try_start() {
395 agriffis 1.33 declare f
396 agriffis 1.23
397     # shouldn't have files in profile that are owned by a user other
398     # than the current one. http://bugs.gentoo.org/show_bug.cgi?id=59849
399     f=$(find ~/{.,.mozilla/}${zero%-bin} ! -uid ${EUID} 2>/dev/null | head -n10)
400     if [[ -n ${f} ]]; then
401 armin76 1.57 [[ ${zero} == "thunderbird" ]] && hint="thunderbird" || hint="mozilla"
402 agriffis 1.23 cat <<EOF
403     Error launching ${zero}:
404    
405     There are files in your profile that are owned by a user other than
406     $(id -un). ${zero} can't execute in this condition. Here are some of
407     the files that I found:
408     EOF
409     echo "${f}" | sed 's/^/ /'
410     (( $(echo "${f}" | wc -l) == 10 )) && echo " ..."
411     echo
412     echo "You can fix this problem by running the following:"
413 armin76 1.57 echo " su -c 'chown -R $(id -un):$(id -gn) $HOME/.${hint}'"
414 agriffis 1.23 echo
415     return 101
416     fi >&2
417    
418 agriffis 1.21 # compreg.dat and/or chrome.rdf will screw things up if it's from an
419     # older version. http://bugs.gentoo.org/show_bug.cgi?id=63999
420 agriffis 1.22 for f in ~/{.,.mozilla/}${zero%-bin}/*/{compreg.dat,chrome.rdf,XUL.mfasl}; do
421 agriffis 1.20 if [[ -f ${f} && ${f} -ot ${mozbin} ]]; then
422     echo "Removing ${f} leftover from older ${zero%-bin}"
423     rm -f "${f}"
424     fi
425     done
426 agriffis 1.23
427 agriffis 1.26 moz_pis_startstop_scripts start
428 agriffis 1.28
429     if $debugging && set_debugger; then
430     for v in MOZILLA_FIVE_HOME LD_LIBRARY_PATH LD_LIBRARYN32_PATH \
431     LD_LIBRARYN64_PATH LD_LIBRARY_PATH_64 DISPLAY XPSERVERLIST \
432     MOZILLA_POSTSCRIPT_PRINTER_LIST DYLD_LIBRARY_PATH LIBRARY_PATH \
433     SHLIB_PATH LIBPATH ADDON_PATH MOZ_PROGRAM MOZ_TOOLKIT debugger; do
434     [[ -n ${!v} ]] && printf "%31s=%s\n" "$v" "${!v}"
435     done
436     echo
437    
438     # Note that --args works for gdb and ddd. Other debuggers will need another
439     # method if added to this script.
440 armin76 1.58 $(type -P aoss) "$debugger" --args "$mozbin" $xulparams "$@"
441 agriffis 1.28
442     # Don't try to load additional URLs if debugging
443     unset urls
444     else
445 agriffis 1.51 case " $* " in
446     *' -ProfileManager '*|*' -P '*)
447     # bug 114683: -ProfileManager doesn't work with DeerPark
448 armin76 1.58 MOZ_NO_REMOTE=1 $(type -P aoss) "$mozbin" $xulparams "$@" &
449 agriffis 1.51 ;;
450     *)
451 armin76 1.58 $(type -P aoss) "$mozbin" $xulparams "$@" &
452 agriffis 1.51 ;;
453     esac
454 agriffis 1.28 fi
455 agriffis 1.1 }
456    
457 agriffis 1.34 moz_pis_startstop_scripts() {
458 agriffis 1.33 eval $(grep -m1 MOZ_USER_DIR= $MOZILLA_FIVE_HOME/${zero%-bin})
459 agriffis 1.26 # MOZ_PIS_ is the name space for "Mozilla Plugable Init Scripts"
460     # These variables and there meaning are specified in
461     # mozilla/xpfe/bootstrap/init.d/README
462     MOZ_PIS_API=2
463     MOZ_PIS_MOZBINDIR="${dist_bin}"
464     MOZ_PIS_SESSION_PID="$$"
465     MOZ_PIS_USER_DIR="${MOZ_USER_DIR}"
466     export MOZ_PIS_API MOZ_PIS_MOZBINDIR MOZ_PIS_SESSION_PID MOZ_PIS_USER_DIR
467 agriffis 1.34
468 agriffis 1.26 case "${1}" in
469     "start")
470     for curr_pis in "${dist_bin}/init.d"/S* "${HOME}/${MOZ_USER_DIR}/init.d"/S* ; do
471     if [ -x "${curr_pis}" ] ; then
472     case "${curr_pis}" in
473     *.sh) . "${curr_pis}" ;;
474     *) "${curr_pis}" "start" ;;
475     esac
476     fi
477     done
478     ;;
479     "stop")
480     for curr_pis in "${HOME}/${MOZ_USER_DIR}/init.d"/K* "${dist_bin}/init.d"/K* ; do
481     if [ -x "${curr_pis}" ] ; then
482     case "${curr_pis}" in
483     *.sh) . "${curr_pis}" ;;
484     *) "${curr_pis}" "stop" ;;
485     esac
486     fi
487     done
488     ;;
489     *)
490     echo 1>&2 "$0: Internal error in moz_pis_startstop_scripts."
491     exit 1
492     ;;
493     esac
494     }
495    
496 agriffis 1.41 remove_chrome() {
497     if [[ $UID != 0 ]]; then
498     echo "$0: You need to be root to update the registry" >&2
499     return 1
500     fi
501    
502     rm -rf ${MOZILLA_FIVE_HOME}/chrome/overlayinfo
503     rm -f ${MOZILLA_FIVE_HOME}/chrome/chrome.rdf
504     rm -f ${MOZILLA_FIVE_HOME}/extensions/installed-extensions-processed.txt
505     rm -f ${MOZILLA_FIVE_HOME}/extensions/Extensions.rdf
506     rm -f ${MOZILLA_FIVE_HOME}/extensions/installed-extensions.txt
507     rm -f ${MOZILLA_FIVE_HOME}/chrome/installed-chrome.txt
508 agriffis 1.42
509     return 0
510 agriffis 1.41 }
511    
512 agriffis 1.34 update_chrome() {
513     if [[ $UID != 0 ]]; then
514     echo "$0: You need to be root to update the registry" >&2
515     return 1
516     fi
517    
518 agriffis 1.42 # The -bin packages don't support updating the registry, at least not yet.
519     # regxpcom and regchrome are missing from firefox-bin and thunderbird-bin, and
520     # there should be no need to run mozilla-rebuild-databases.pl with mozilla-bin
521     if [[ ${zero} == *-bin ]]; then
522     echo "$0: update_chrome doesn't support ${zero}"
523     return 1
524     fi
525    
526 armin76 1.57 # seamonkey doesn't support -register yet. Until it does, use the
527     # seamonkey-rebuild-databases.pl script instead
528     if [[ ${zero} == seamonkey ]]; then
529 agriffis 1.47 echo "Running seamonkey-rebuild-databases.pl"
530     umask 022
531     ${MOZILLA_FIVE_HOME}/seamonkey-rebuild-databases.pl
532     return $?
533 agriffis 1.42 fi
534    
535 agriffis 1.40 echo "Updating ${zero} chrome registry..."
536 agriffis 1.39 umask 022
537 agriffis 1.34 export PATH=${MOZILLA_FIVE_HOME}:${PATH}
538 agriffis 1.37 export HOME=$(mktemp -d /tmp/${zero}-register.XXXXXX)
539 agriffis 1.34 declare libdir=${MOZILLA_FIVE_HOME}
540 agriffis 1.39 declare extdir=${libdir}/extensions.d
541     declare chrdir=${libdir}/chrome.d
542 agriffis 1.37
543     # set up libdir
544 agriffis 1.41 remove_chrome || return 1
545 agriffis 1.39 mkdir -p ${libdir}/chrome/overlayinfo
546 agriffis 1.38 mkdir -p ${libdir}/extensions
547 agriffis 1.34
548     # generate installed-extensions.txt
549 agriffis 1.39 :> ${libdir}/extensions/installed-extensions.txt
550     chmod 0644 ${libdir}/extensions/installed-extensions.txt
551 agriffis 1.37 for f in $(ls -d ${extdir}/* 2>/dev/null); do
552 agriffis 1.34 while read line; do
553     extuid=$(echo ${line} | cut -f 2 -d ,)
554     extuiddir=${libdir}/extensions/${extuid}
555 agriffis 1.37 if [[ ! -e ${extuiddir} ]]; then
556     echo "W: ${f}: ${extuiddir} doesn't exist." >&2
557     elif [[ ! -e ${extuiddir}/install.rdf ]]; then
558     echo "W: ${f}: ${extuiddir}/install.rdf doesn't exist." >&2
559     elif grep -Fq ${extuid} ${extuiddir}/install.rdf; then
560 agriffis 1.39 echo $line >> ${libdir}/extensions/installed-extensions.txt
561 agriffis 1.34 else
562 agriffis 1.37 echo "W: ${f}: ${extuiddir}/install.rdf doesn't contain the UID." >&2
563 agriffis 1.34 fi
564     done < $f
565     done
566    
567 agriffis 1.39 # do some double-checking
568     if $MOZILLA_LAUNCHER_DEBUG; then
569     for f in $(find ${libdir}/extensions/ -maxdepth 1 -name '{*}'); do
570     if ! grep -Fq ${f##*/} ${libdir}/extensions/installed-extensions.txt; then
571     echo "W: ${f##*/} not in ${libdir}/extensions/installed-extensions.txt" >&2
572     fi
573     done
574     fi
575    
576 agriffis 1.38 # generate installed-chrome.txt
577 agriffis 1.39 cat /dev/null $(ls -d ${chrdir}/* 2>/dev/null) > ${libdir}/chrome/installed-chrome.txt
578     chmod 0644 ${libdir}/chrome/installed-chrome.txt
579 agriffis 1.34
580     # let the mozilla binary do its thing...
581 agriffis 1.38 $mozbin -register || echo "E: Registration process exited with status: $?" >&2
582     regchrome || echo "E: regchrome exited with status: $?" >&2
583     regxpcom || echo "E: regxpcom exited with status: $?" >&2
584 agriffis 1.34
585     if [[ -e ${libdir}/extensions/installed-extensions.txt ]]; then
586     echo "E: ${libdir}/extensions/installed-extensions.txt still present" >&2
587     echo "E: Registration might have gone wrong" >&2
588     fi
589    
590     rm -fr ${HOME}
591    
592     return 0
593     }
594    
595 kloeri 1.56 sanitize_url()
596     {
597 armin76 1.57 # We only really need to filter '(' and ')' as these break openURL
598     echo $1 | sed -e's/(/%28/g' -e's/)/%29/g'
599 kloeri 1.56 }
600    
601 agriffis 1.1 # Call the main sub, which is defined at the top of this script
602     main "$@"
603    
604     # vim:expandtab sw=2:

  ViewVC Help
Powered by ViewVC 1.1.20