浏览代码

add startup script; add .autogen dir hack

Ralf S. Engelschall 23 年之前
父节点
当前提交
b8a543eb01
共有 3 个文件被更改,包括 308 次插入8 次删除
  1. 121 0
      mozilla/mozilla.pod
  2. 173 2
      mozilla/mozilla.sh
  3. 14 6
      mozilla/mozilla.spec

+ 121 - 0
mozilla/mozilla.pod

@@ -0,0 +1,121 @@
+##
+##  mozilla.pod -- Mozilla Browser Startup Control Utility (manpage)
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+=pod
+
+=head1 NAME
+
+B<mozilla> -- Mozilla Browser Startup Control Utility
+
+=head1 SYNOPSIS
+
+B<mozilla>
+[B<-v>|B<--verbose>]
+[B<-w>|B<--window>]
+[B<-t>|B<--tab>]
+[B<-r>|B<-remote>|B<--remote> I<command>]
+[I<url> ...]
+
+=head1 DESCRIPTION
+
+The B<mozilla> command is small startup control utility for the
+B<Mozilla> browser (http://www.mozilla.org/). It makes sure that no more
+than one B<Mozilla> instance is running at the same time and allows
+you to conviniently load URLs from the command line into new browser
+windows, new browser tabs or into the currently open browser view.
+
+The following command line options are recognized:
+
+=over 4
+
+=item B<-v>, B<--verbose>
+
+Displays verbose messages on F<stderr> while performing the
+B<Mozilla> control actions.
+
+=item B<-w>, B<--window>
+
+Opens the URL(s) into new browser windows.
+
+=item B<-t>, B<--tab>
+
+Opens the URL(s) into new browser tabs.
+
+=item B<-r>, B<-remote>, B<--remote> I<command>
+
+This is for compatibility with the lower level C<mozilla>
+executable. It just passes through the options I<command>.
+
+=back
+
+The following URL(s) are recognized on the command line:
+
+=over 4
+
+=item C<http://>..., C<https://...>, C<ftp://>...
+
+Fully qualified URLs are passed through as-is.
+
+=item C<google:>I<wordlist>
+
+Expands into a Google (http://www.google.com/) query URL for the given
+I<wordlist>.
+
+=item C<leo:>I<wordlist>
+
+Expands into a Leo English/German Dictionary (http://dict.leo.org/)
+query URL for the given I<wordlist>.
+
+=item C<ftpsearch:>I<wordlist>
+
+Expands into an AllTheWeb FTPSearch (http://www.alltheweb.com/) query URL for the given
+I<wordlist>.
+
+=item C</>I<path>, I<path>
+
+Expands the absolute or relative Unix filesystem I<path> into a fully
+qualified C<file> scheme URL.
+
+=item C<auto:>...
+
+Trys to autodetect the query.
+
+=back 
+
+Additionally any URL argument can contain an at-sign ("C<@>"), which
+is replaced with the current contents of the X11 selection buffer.
+
+=head1 SEE ALSO
+
+http://www.mozilla.org/unix/remote.html
+
+=head1 HISTORY
+
+This utility was written in November 2002 by B<Ralf S. Engelschall>
+E<lt>rse@engelschall.comE<gt> for use with the B<OpenPKG> I<mozilla>
+package.
+
+=cut
+

+ 173 - 2
mozilla/mozilla.sh

@@ -1,3 +1,174 @@
 #!/bin/sh
-cd @l_prefix@/lib/mozilla
-exec ./mozilla ${1+"$@"}
+##
+##  mozilla -- Mozilla Browser Startup Control Utility
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   configuration
+mozilla_dir="@l_prefix@/lib/mozilla"
+mozilla_bin="@l_prefix@/lib/mozilla/mozilla"
+xsel_bin="@l_prefix@/bin/xsel"
+
+#   option parsing
+opt_v=no
+opt_w=no
+opt_t=no
+opt_r=""
+while [ ".$1" != . ]; do
+    case $1 in
+        -v|--verbose ) opt_v=yes; shift ;;
+        -w|--window  ) opt_w=yes; shift ;;
+        -t|--tab     ) opt_t=yes; shift ;;
+        -r|-remote|--remote ) opt_r="$2"; shift; shift ;;
+        -* ) echo "$0:ERROR: invalid option \"$1\"" 1>&2; exit 1 ;;
+        * ) break ;;
+    esac
+done
+if [ $# -eq 0 ]; then
+    set -- ""
+fi
+
+verbose () {
+    if [ ".$opt_v" = .yes ]; then
+        echo "mozilla: $*" 1>&2
+    fi
+}
+
+#   establish Mozilla environment
+MOZILLA_FIVE_HOME="$mozilla_dir"
+export MOZILLA_FIVE_HOME
+
+#   special case of direct remote option
+if [ ".$opt_r" != . ]; then
+    verbose "exec: $mozilla_bin -remote \"$opt_r\""
+    exec $mozilla_bin -remote "$opt_r"
+fi
+
+#   determine Mozilla run-time status
+$mozilla_bin -remote "ping()" >/dev/null 2>&1
+if [ $? -eq 0 ]; then
+    verbose "process already running (available remotely)"
+    restart=no
+else
+    verbose "process still not running (not available remotely)"
+    restart=yes
+fi
+
+#   open one or more URLs
+first=yes
+for url in "$@"; do
+    #   determine URL to open
+    if [ ".`echo .$url | grep '@'`" != . ]; then
+        #   expand at-sign into X11 selection buffer
+        xsel=`($xsel_bin --paste) 2>/dev/null`
+        url=`echo "$url" | sed -e "s;@;$xsel;"`
+    fi
+    if [ ".$url" = . ]; then
+        #   expand an empty URL into the internal blank page
+        url="about:blank"
+    else
+        #   expand special URL constructs
+        case "$url" in
+            auto:* )
+                url=`echo "$url" | sed -e 's;^auto:;;'`
+                case "$url" in
+                    http://* | https://* | ftp://* ) ;;
+                    www.* ) url="http://$url" ;;
+                    ftp.* ) url="ftp://$url" ;;
+                    *.tar.gz | *.tgz ) url="ftpsearch:$url" ;;
+                    *" "* ) url="google:$url" ;;
+                    * ) url="leo:$url" ;;
+                esac
+                ;;
+        esac
+        case "$url" in
+            http://* | https://* | ftp://* )
+                : # URL is already fully qualified
+                ;;
+            google:* ) 
+                #   expand Google query
+                url=`echo "$url" | sed -e 's;^google:;;' | tr ' ' '+'`
+                url="http://www.google.com/search?q=$url"
+                ;;
+            leo:* ) 
+                #   expand Leo Dictionary query
+                url=`echo "$url" | sed -e 's;^leo:;;' | tr ' ' '+'`
+                url="http://dict.leo.org/?search=$url"
+                ;;
+            ftpsearch:* ) 
+                #   expand FTPSearch query
+                url=`echo "$url" | sed -e 's;^ftpsearch:;;' | sed -e 's; ;%20;g'`
+                url="http://www.alltheweb.com/search?advanced=1&cat=ftp&q=$url"
+                ;;
+            /* ) 
+                #   expand absolute filename into file URL
+                url="file://$url"
+                ;;
+            * ) 
+                #   expand relative filename into file URL
+                url="file://`pwd`/$url"
+                ;;
+        esac
+    fi
+
+    if [ ".$first" = .yes -a ".$restart" = .yes ]; then
+        #   handling of first URL if restarting is necessary
+        verbose "running new process"
+        verbose "exec: $mozilla_bin \"$url\" >/dev/null 2>&1 &"
+        $mozilla_bin "$url" >/dev/null 2>&1 &
+    else
+        #   delayed waiting for process to be finally remotely available
+        #   if it was started from scratch for the handling of the first
+        #   URL. This way we wait only if necessary, i.e., if more than
+        #   one URL was given.
+        if [ ".$first" = .no -a ".$restart" = .yes ]; then
+            verbose "waiting for new process to be available remotely"
+            sleep 4 # give it a little bit of time to fully startup
+            i=0
+            while [ $i -lt 10 ]; do
+                $mozilla_bin -remote "ping()" >/dev/null 2>&1
+                if [ $? -eq 0 ]; then
+                    break
+                fi
+                sleep 1 # give it a little bit more time to startup
+                i=`expr $i + 1`
+            done
+        fi
+
+        #   determine remote command
+        if [ ".$opt_w" = .yes ]; then
+            cmd="openURL($url, new-window)"
+        elif [ ".$opt_t" = .yes ]; then
+            cmd="openURL($url, new-tab)"
+        else
+            cmd="openURL($url)"
+        fi
+
+        #   perform remote command
+        verbose "sending remote command to running process"
+        verbose "exec: $mozilla_bin -remote \"$cmd\" >/dev/null 2>&1"
+        $mozilla_bin -remote "$cmd" >/dev/null 2>&1
+    fi
+    first=no
+done
+

+ 14 - 6
mozilla/mozilla.spec

@@ -33,18 +33,19 @@ Distribution: OpenPKG [EVAL]
 Group:        Web
 License:      MPL
 Version:      1.2
-Release:      20021201
+Release:      20021203
 
 #   list of sources
 Source0:      ftp://ftp.mozilla.org/pub/mozilla/releases/mozilla%{version}/src/mozilla-source-%{version}.tar.bz2
 Source1:      mozilla.sh
+Source2:      mozilla.pod
 Patch0:       mozilla.patch
 
 #   build information
 Prefix:       %{l_prefix}
 BuildRoot:    %{l_buildroot}
-BuildPreReq:  OpenPKG, openpkg >= 20020206, X11, glib, gtk, orbit, infozip, make, gcc
-PreReq:       OpenPKG, openpkg >= 20020206, X11, glib, gtk, orbit, infozip
+BuildPreReq:  OpenPKG, openpkg >= 20020206, X11, glib, gtk, orbit, infozip, make, gcc, perl
+PreReq:       OpenPKG, openpkg >= 20020206, X11, glib, gtk, orbit, infozip, xsel
 AutoReq:      no
 AutoReqProv:  no
 
@@ -87,7 +88,9 @@ AutoReqProv:  no
         --enable-xinerama \
         --enable-chrome-format=jar \
         --enable-static \
+        --enable-strip \
         --disable-shared \
+        --disable-tests \
         --disable-mailnews \
         --disable-composer \
         --disable-svg \
@@ -104,8 +107,6 @@ AutoReqProv:  no
         --disable-optimize \
         --disable-xterm-updates \
         --with-pthreads
-        #FIXME# --enable-strip
-        #FIXME# --disable-tests
     %{l_make} %{l_mflags}
     ( cd dist/bin
       LD_LIBRARY_PATH=.; export LD_LIBRARY_PATH
@@ -113,11 +114,16 @@ AutoReqProv:  no
       ./regxpcom || true
       ./regchrome || true
       touch chrome/user-skins.rdf chrome/user-locales.rdf
-      #FIXME# find . -type d -depth -print | xargs rmdir >/dev/null 2>&1 || true
+      #find . -type d -depth -print | xargs rmdir >/dev/null 2>&1 || true
       %{l_shtool} subst \
           -e "s;`pwd`;%{l_prefix}/lib/mozilla;" \
           components/xpti.dat components/compreg.dat
+      mkdir .autoreg
     )
+    %{l_prefix}/bin/pod2man \
+        --section=1 --quotes=none \
+        --release="Mozilla %{version}" --center="%{packager}" \
+        %{SOURCE mozilla.pod} >mozilla.1
 
 %install
     rm -rf $RPM_BUILD_ROOT
@@ -128,6 +134,8 @@ AutoReqProv:  no
 	    (cd $RPM_BUILD_ROOT%{l_prefix}/lib/mozilla && %{l_tar} -xf -)
     %{l_shtool} install -c -m 755 -e 's;@l_prefix@;%{l_prefix};g' \
         %{SOURCE mozilla.sh} $RPM_BUILD_ROOT%{l_prefix}/bin/mozilla
+    %{l_shtool} install -c -m 644 \
+        %{SOURCE mozilla.1} $RPM_BUILD_ROOT%{l_prefix}/man/man1/
     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
 
 %files -f files