openpkg/man.sh

Tue, 29 Mar 2011 20:04:34 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 29 Mar 2011 20:04:34 +0200
changeset 334
4a34d7a82eab
child 428
f880f219c566
permissions
-rw-r--r--

Rework package yet again, correcting and introducing new buildconf logic:
Conditionally disable bootstrap stage comparison correctly, correct
english grammar, better find system as(1) and ld(1), indotruce detailed
optimization option messages, more completely guess cpu types, allow
profiled bootstrapping without a preinstalled GCC because many other
compilers have long since implemented 64-bit arithmetic, instruct make
to build sequentially (not in sparallel) when building a profiled
bootstrap as GCC online documents recommend, and generally improve
comment blocks.

The single most important correction in this changeset relates to the
GCC changed optimization policy since at least GCC 4.5, in which -march
is always passed and not always correctly guessed. In the case of this
package, allowing GCC to guess the architecture leads to wild build
errors at various subcomponents (zlib, libgcc, libiberty...) and
bootstrap stages. It seems quite platform specific, and the safest
approach to correcting this seems to be explicitly always specifying the
-march argument when bootstrapping GCC. Because the best choice 'native'
is not available when bootstrapping using a foreign (non GCC) compiler,
a guess is made according to rpmmacros l_platform in that case.

It is questionable as to whether these recent optimization changes
on the part of GCC or this package are compatible with each other,
or if either are complete or correct at all. At least applying these
corrections allows this package to build again in most cases test.

     1 #!@l_prefix@/lib/openpkg/bash
     2 ##
     3 ##  man -- OpenPKG Tool Chain "man" command
     4 ##  Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
     5 ##  Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
     6 ##
     7 ##  Permission to use, copy, modify, and distribute this software for
     8 ##  any purpose with or without fee is hereby granted, provided that
     9 ##  the above copyright notice and this permission notice appear in all
    10 ##  copies.
    11 ##
    12 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    13 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    14 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    15 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    16 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    17 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    18 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    19 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    20 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    21 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    22 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    23 ##  SUCH DAMAGE.
    24 ##
    26 #   configuration
    27 prefix="@l_prefix@"
    29 #   minimum command line parsing
    30 opt_h=no
    31 while [ 1 ]; do
    32     case "$1" in
    33         -h | --help ) opt_h=yes; shift ;;
    34         * ) break ;;
    35     esac
    36 done
    37 if [ ".$opt_h" = .yes ]; then
    38     echo "openpkg:man:USAGE: openpkg man [--help] [<section>] <command>"
    39     exit 0
    40 fi
    41 if [ $# -eq 1 ]; then
    42     man_page="$1"
    43 elif [ $# -eq 2 ]; then
    44     man_sect="$1"
    45     man_page="$2"
    46 else
    47     echo "openpkg:man:ERROR: invalid number of arguments" 1>&2
    48     exit 1
    49 fi
    51 #   determine path to commands
    52 openpkg_tools="${OPENPKG_TOOLS}"
    53 openpkg_tools_cmdpath="${OPENPKG_TOOLS_CMDPATH}"
    54 if [ ".${openpkg_tools}" != . -a ".${openpkg_tools_cmdpath}" = . ]; then
    55     openpkg_tools_cmdpath="${openpkg_tools}/cmd:@"
    56 fi
    57 cmdpath="${prefix}/libexec/openpkg"
    58 if [ -d "${prefix}/libexec/openpkg-tools" ]; then
    59     cmdpath="${prefix}/libexec/openpkg-tools:${cmdpath}"
    60 fi
    61 if [ -d "${prefix}/libexec/openpkg-audit" ]; then
    62     cmdpath="${prefix}/libexec/openpkg-audit:${cmdpath}"
    63 fi
    64 if [ ".${openpkg_tools_cmdpath}" != . ]; then
    65     cmdpath=`echo "${openpkg_tools_cmdpath}" | sed -e "s;@;${cmdpath};"`
    66 fi
    67 openpkg_tools_cmdpath=`echo "${cmdpath}" | sed -e 's/::/:/g' -e 's/^://' -e 's/:$//'`
    69 #   search for manual page in OpenPKG Tool Chain
    70 man_file=""
    71 man_type=""
    72 OIFS="$IFS"; IFS=":"
    73 for dir in ${openpkg_tools_cmdpath}; do
    74     IFS="$OIFS"
    75     for file in $dir/$man_page.${man_sect-"1"} $dir/$man_page.[1-9]; do
    76         if [ -f "$file" ]; then
    77             man_file="$file"
    78             man_type="roff"
    79             if [ ".$man_sect" = . ]; then
    80                 man_sect=`echo "$man_file" |\
    81                     sed -e 's;^;X;' -e 's;^X.*\.\([1-9]\)$;\1;' -e 's;^X.*;;'`
    82             fi
    83             break
    84         fi
    85     done
    86     if [ ".$man_type" = . ]; then
    87         for file in $dir/$man_page.pod $dir/$man_page.pl $dir/$man_page.sh; do
    88             if [ -f "$file" ]; then
    89                 if [ ".`grep '^=pod' $file`" != . ]; then
    90                     man_file="$file"
    91                     man_type="pod"
    92                     break
    93                 fi
    94             fi
    95         done
    96     fi
    97     if [ ".$man_type" != . ]; then
    98         break
    99     fi
   100 done
   101 IFS="$OIFS"
   102 if [ ".$man_type" != . ]; then
   103     #   determine POD to Roff converter
   104     pod2roff=""
   105     if [ ".$man_type" = .pod ]; then
   106         pod2roff=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" pod2man`
   107         if [ ".$pod2roff" = . ]; then
   108             echo "openpkg:man:ERROR: unable to find POD to Roff converter (pod2man)" 1>&2
   109             exit 1
   110         fi
   111         if [ ".$man_sect" = . ]; then
   112             man_sect=1
   113         fi
   114         pod2roff="$pod2roff --section=${man_sect}"
   115         pod2roff="$pod2roff --release=\"$man_page(${man_sect})\""
   116         pod2roff="$pod2roff --center=OpenPKG --date=OpenPKG"
   117         pod2roff="$pod2roff --quotes=none"
   118     fi
   120     #   determine Roff to ASCII converter
   121     roff2ascii=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" nroff groff`
   122     if [ ".$roff2ascii" = . ]; then
   123         echo "openpkg:man:ERROR: unable to find Roff to ASCII converter (nroff, groff)" 1>&2
   124         exit 1
   125     fi
   126     roff2ascii="$roff2ascii -man"
   127     case "$roff2ascii" in
   128         */groff ) roff2ascii="$roff2ascii -Tascii" ;;
   129     esac
   131     #   determine pager
   132     pager="$PAGER"
   133     if [ ".$pager" = . ]; then
   134         pager=`$prefix/lib/openpkg/shtool path -p "$prefix/bin:$PATH" less more cat`
   135     fi
   136     if [ ".$pager" = . ]; then
   137         echo "openpkg:man:ERROR: unable to find text viewer ($PAGER, less, more, cat)" 1>&2
   138         exit 1
   139     fi
   141     #   render the manual page to the TTY
   142     if [ ".$man_type" = .roff ]; then
   143         eval "$roff2ascii $man_file | $pager"
   144     elif [ ".$man_type" = .pod ]; then
   145         eval "$pod2roff $man_file | $roff2ascii | $pager"
   146     fi
   147     exit 0
   148 fi
   150 #   fallback to the man(1) command
   151 MANPATH="$prefix/man:$prefix/local/man:${MANPATH-/usr/man}:/usr/man:/usr/share/man"
   152 export MANPATH
   153 eval "exec man $man_sect $man_page"

mercurial