openpkg/release.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 ##  release -- OpenPKG Release Determination Utility
     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_F="OpenPKG-%t %u"
    31 opt_r=""
    32 while [ $# -gt 0 ]; do
    33     case "$1" in
    34         -F          ) opt_F="$2"; shift;                      shift ;;
    35         --fmt       ) opt_F="$2"; shift;                      shift ;;
    36         -F*         ) opt_F="`expr ".$1" : '.-F\(.*\)'`";     shift ;;
    37         --fmt=*     ) opt_F="`expr ".$1" : '.--fmt=\(.*\)'`"; shift ;;
    38         -r          ) opt_r="$2"; shift;                      shift ;;
    39         --release   ) opt_r="$2"; shift;                      shift ;;
    40         -r*         ) opt_r="`expr ".$1" : '.-r\(.*\)'`";     shift ;;
    41         --release=* ) opt_r="`expr ".$1" : '.--release=\(.*\)'`"; shift ;;
    42         *       ) break ;;
    43     esac
    44 done
    46 #   translate a release number to a release tag
    47 number_to_tag () {
    48     sed -e 's;^;X;' \
    49         -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*$;\1-SOLID;' \
    50         -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-RELEASE;' \
    51         -e 's;^X\([^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-STABLE;' \
    52         -e 's;^X[^.-][^.-]*.*$;CURRENT;' \
    53         -e 's;^X.*$;UNKNOWN;'
    54 }
    56 #   sanity check a release tag
    57 tag_sanity () {
    58     sed -e 's;^;X;' \
    59         -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-RELEASE$;OK;' \
    60         -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
    61         -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID$;OK;' \
    62         -e 's;^X[^.-][^.-]*-STABLE-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
    63         -e 's;^X[^.-][^.-]*-STABLE$;OK;' \
    64         -e 's;^XCURRENT-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
    65         -e 's;^XCURRENT$;OK;' \
    66         -e 's;^X.*$;ERROR;'
    67 }
    69 #   determine release
    70 tag=""
    71 if [ ".$opt_r" != . ]; then
    72     tag=`echo ".$opt_r" | sed -e 's;^\.;;' | number_to_tag`
    73 elif [ -f "$prefix/etc/openpkg/release" ]; then
    74     tag=`(cat $prefix/etc/openpkg/release; echo "") | sed \
    75         -e 's;^;X;' \
    76         -e 's;^X *TAG *= *\([^ ][^ ]*\).*;\1;' \
    77         -e '/^X/d' | \
    78         sed -n -e '$p'`
    79 else
    80     tag=`$prefix/bin/openpkg rpm \
    81         -q --qf '%{VERSION}\n' openpkg | number_to_tag`
    82 fi
    83 if [ .`echo ".$tag" | sed -e 's;^\.;;' | tag_sanity` = .ERROR ]; then
    84     echo "openpkg:release: WARNING: unable to determine OpenPKG release tag" 1>&2
    85     tag="UNKNOWN"
    86 fi
    88 #   determine distribution URL
    89 url=""
    90 if [ -f "$prefix/etc/openpkg/release" ]; then
    91     url=`(cat $prefix/etc/openpkg/release; echo "") | sed \
    92         -e 's;^;X;' \
    93         -e 's;^X *URL *= *\([^ ][^ ]*\).*;\1;' \
    94         -e '/^X/d' | \
    95         sed -n -e '$p'`
    96 fi
    97 if [ ".$url" = . ]; then
    98     url="ftp://ftp.openpkg.org/*"
    99 fi
   100 case ".$url" in
   101     */\* )
   102         url=`echo ".$url" | sed -e 's;^\.;;' -e 's;/\*$;;'`
   103         case "$tag" in
   104             CURRENT )
   105                 url="$url/current/SRC/"
   106                 ;;
   107             CURRENT-* )
   108                 version=`echo "$tag" | sed -e 's;^CURRENT-;;'`
   109                 url="$url/current/$version/"
   110                 ;;
   111             *-STABLE )
   112                 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE$;\1;'`
   113                 url="$url/stable/$version/"
   114                 ;;
   115             *-STABLE-* )
   116                 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE-\(.*\)$;\1.\2;'`
   117                 url="$url/stable/$version/"
   118                 ;;
   119             *-SOLID )
   120                 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID$;\1;'`
   121                 url="$url/solid/$version/"
   122                 ;;
   123             *-SOLID-* )
   124                 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID-\(.*\)$;\1.\2;'`
   125                 url="$url/solid/$version/"
   126                 ;;
   127             *-RELEASE )
   128                 version=`echo "$tag" | sed -e 's;^\(.*\)-RELEASE$;\1;'`
   129                 url="$url/release/$version/"
   130                 ;;
   131         esac
   132         ;;
   133 esac
   135 #   read uuid
   136 [ -f "$prefix/etc/openpkg/uuid" ] && . "$prefix/etc/openpkg/uuid"
   138 #   generate output
   139 echo "X$opt_F" |\
   140 sed -e 's/^X//' \
   141     -e "s;%t;${tag};g" \
   142     -e "s;%u;${url};g" \
   143     -e "s;%r;${UUID_REGISTRY};g" \
   144     -e "s;%i;${UUID_INSTANCE};g" \
   145     -e "s;%p;${UUID_PLATFORM};g" \
   146     -e 's/\\n/^/g' | tr '^' '\012'

mercurial