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.

michael@13 1 #!@l_prefix@/lib/openpkg/bash
michael@13 2 ##
michael@13 3 ## release -- OpenPKG Release Determination Utility
michael@13 4 ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
michael@13 5 ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
michael@13 6 ##
michael@13 7 ## Permission to use, copy, modify, and distribute this software for
michael@13 8 ## any purpose with or without fee is hereby granted, provided that
michael@13 9 ## the above copyright notice and this permission notice appear in all
michael@13 10 ## copies.
michael@13 11 ##
michael@13 12 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@13 13 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@13 14 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@13 15 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@13 16 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@13 17 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@13 18 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@13 19 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@13 20 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@13 21 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@13 22 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@13 23 ## SUCH DAMAGE.
michael@13 24 ##
michael@13 25
michael@13 26 # configuration
michael@13 27 prefix="@l_prefix@"
michael@13 28
michael@13 29 # minimum command line parsing
michael@13 30 opt_F="OpenPKG-%t %u"
michael@13 31 opt_r=""
michael@13 32 while [ $# -gt 0 ]; do
michael@13 33 case "$1" in
michael@13 34 -F ) opt_F="$2"; shift; shift ;;
michael@13 35 --fmt ) opt_F="$2"; shift; shift ;;
michael@13 36 -F* ) opt_F="`expr ".$1" : '.-F\(.*\)'`"; shift ;;
michael@13 37 --fmt=* ) opt_F="`expr ".$1" : '.--fmt=\(.*\)'`"; shift ;;
michael@13 38 -r ) opt_r="$2"; shift; shift ;;
michael@13 39 --release ) opt_r="$2"; shift; shift ;;
michael@13 40 -r* ) opt_r="`expr ".$1" : '.-r\(.*\)'`"; shift ;;
michael@13 41 --release=* ) opt_r="`expr ".$1" : '.--release=\(.*\)'`"; shift ;;
michael@13 42 * ) break ;;
michael@13 43 esac
michael@13 44 done
michael@13 45
michael@13 46 # translate a release number to a release tag
michael@13 47 number_to_tag () {
michael@13 48 sed -e 's;^;X;' \
michael@13 49 -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*$;\1-SOLID;' \
michael@13 50 -e 's;^X\([^.-][^.-]*\.[^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-RELEASE;' \
michael@13 51 -e 's;^X\([^.-][^.-]*\)\.[^.-][^.-]*.*$;\1-STABLE;' \
michael@13 52 -e 's;^X[^.-][^.-]*.*$;CURRENT;' \
michael@13 53 -e 's;^X.*$;UNKNOWN;'
michael@13 54 }
michael@13 55
michael@13 56 # sanity check a release tag
michael@13 57 tag_sanity () {
michael@13 58 sed -e 's;^;X;' \
michael@13 59 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-RELEASE$;OK;' \
michael@13 60 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 61 -e 's;^X[^.-][^.-]*\.[^.-][^.-]*-SOLID$;OK;' \
michael@13 62 -e 's;^X[^.-][^.-]*-STABLE-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 63 -e 's;^X[^.-][^.-]*-STABLE$;OK;' \
michael@13 64 -e 's;^XCURRENT-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$;OK;' \
michael@13 65 -e 's;^XCURRENT$;OK;' \
michael@13 66 -e 's;^X.*$;ERROR;'
michael@13 67 }
michael@13 68
michael@13 69 # determine release
michael@13 70 tag=""
michael@13 71 if [ ".$opt_r" != . ]; then
michael@13 72 tag=`echo ".$opt_r" | sed -e 's;^\.;;' | number_to_tag`
michael@13 73 elif [ -f "$prefix/etc/openpkg/release" ]; then
michael@13 74 tag=`(cat $prefix/etc/openpkg/release; echo "") | sed \
michael@13 75 -e 's;^;X;' \
michael@13 76 -e 's;^X *TAG *= *\([^ ][^ ]*\).*;\1;' \
michael@13 77 -e '/^X/d' | \
michael@13 78 sed -n -e '$p'`
michael@13 79 else
michael@13 80 tag=`$prefix/bin/openpkg rpm \
michael@13 81 -q --qf '%{VERSION}\n' openpkg | number_to_tag`
michael@13 82 fi
michael@13 83 if [ .`echo ".$tag" | sed -e 's;^\.;;' | tag_sanity` = .ERROR ]; then
michael@13 84 echo "openpkg:release: WARNING: unable to determine OpenPKG release tag" 1>&2
michael@13 85 tag="UNKNOWN"
michael@13 86 fi
michael@13 87
michael@13 88 # determine distribution URL
michael@13 89 url=""
michael@13 90 if [ -f "$prefix/etc/openpkg/release" ]; then
michael@13 91 url=`(cat $prefix/etc/openpkg/release; echo "") | sed \
michael@13 92 -e 's;^;X;' \
michael@13 93 -e 's;^X *URL *= *\([^ ][^ ]*\).*;\1;' \
michael@13 94 -e '/^X/d' | \
michael@13 95 sed -n -e '$p'`
michael@13 96 fi
michael@13 97 if [ ".$url" = . ]; then
michael@13 98 url="ftp://ftp.openpkg.org/*"
michael@13 99 fi
michael@13 100 case ".$url" in
michael@13 101 */\* )
michael@13 102 url=`echo ".$url" | sed -e 's;^\.;;' -e 's;/\*$;;'`
michael@13 103 case "$tag" in
michael@13 104 CURRENT )
michael@13 105 url="$url/current/SRC/"
michael@13 106 ;;
michael@13 107 CURRENT-* )
michael@13 108 version=`echo "$tag" | sed -e 's;^CURRENT-;;'`
michael@13 109 url="$url/current/$version/"
michael@13 110 ;;
michael@13 111 *-STABLE )
michael@13 112 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE$;\1;'`
michael@13 113 url="$url/stable/$version/"
michael@13 114 ;;
michael@13 115 *-STABLE-* )
michael@13 116 version=`echo "$tag" | sed -e 's;^\(.*\)-STABLE-\(.*\)$;\1.\2;'`
michael@13 117 url="$url/stable/$version/"
michael@13 118 ;;
michael@13 119 *-SOLID )
michael@13 120 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID$;\1;'`
michael@13 121 url="$url/solid/$version/"
michael@13 122 ;;
michael@13 123 *-SOLID-* )
michael@13 124 version=`echo "$tag" | sed -e 's;^\(.*\)-SOLID-\(.*\)$;\1.\2;'`
michael@13 125 url="$url/solid/$version/"
michael@13 126 ;;
michael@13 127 *-RELEASE )
michael@13 128 version=`echo "$tag" | sed -e 's;^\(.*\)-RELEASE$;\1;'`
michael@13 129 url="$url/release/$version/"
michael@13 130 ;;
michael@13 131 esac
michael@13 132 ;;
michael@13 133 esac
michael@13 134
michael@13 135 # read uuid
michael@13 136 [ -f "$prefix/etc/openpkg/uuid" ] && . "$prefix/etc/openpkg/uuid"
michael@13 137
michael@13 138 # generate output
michael@13 139 echo "X$opt_F" |\
michael@13 140 sed -e 's/^X//' \
michael@13 141 -e "s;%t;${tag};g" \
michael@13 142 -e "s;%u;${url};g" \
michael@13 143 -e "s;%r;${UUID_REGISTRY};g" \
michael@13 144 -e "s;%i;${UUID_INSTANCE};g" \
michael@13 145 -e "s;%p;${UUID_PLATFORM};g" \
michael@13 146 -e 's/\\n/^/g' | tr '^' '\012'
michael@13 147

mercurial