Tue, 29 Mar 2011 20:04:34 +0200
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 #!/bin/sh
2 ##
3 ## usrgrp.sh -- user/group name/id determination
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 # command line parameters (defaults)
27 help=0
28 usr=''; grp=''
29 susr=''; sgrp=''
30 musr=''; mgrp=''
31 rusr=''; rgrp=''
32 nusr=''; ngrp=''
33 suid=''; sgid=''
34 muid=''; mgid=''
35 ruid=''; rgid=''
36 nuid=''; ngid=''
38 # parse command line options
39 for opt
40 do
41 case $opt in
42 -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
43 *) arg='' ;;
44 esac
45 case $opt in
46 -h | --help ) help=1 ;;
47 --usr=* | --user=* ) usr=$arg ;;
48 --grp=* | --group=* ) grp=$arg ;;
49 --susr=* ) susr=$arg ;;
50 --sgrp=* ) sgrp=$arg ;;
51 --musr=* ) musr=$arg ;;
52 --mgrp=* ) mgrp=$arg ;;
53 --rusr=* ) rusr=$arg ;;
54 --rgrp=* ) rgrp=$arg ;;
55 --nusr=* ) nusr=$arg ;;
56 --ngrp=* ) ngrp=$arg ;;
57 --suid=* ) suid=$arg ;;
58 --sgid=* ) sgid=$arg ;;
59 --muid=* ) muid=$arg ;;
60 --mgid=* ) mgid=$arg ;;
61 --ruid=* ) ruid=$arg ;;
62 --rgid=* ) rgid=$arg ;;
63 --nuid=* ) nuid=$arg ;;
64 --ngid=* ) ngid=$arg ;;
65 * ) help=1 ;;
66 esac
67 done
68 if [ ".$help" = .1 ]; then
69 echo "Usage: sh $0 [-h|--help]" 2>&1
70 echo " [--[smrn]?usr=<usr>] [--[smrn]?grp=<usr>]" 2>&1
71 echo " [--[smrn]uid=<uid>] [--[smrn]gid=<gid>]" 2>&1
72 exit 1
73 fi
75 # determine cusr/cgrp
76 cusr=`(id -un) 2>/dev/null ||\
77 (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
78 (whoami) 2>/dev/null ||\
79 (who am i | cut "-d " -f1) 2>/dev/null ||\
80 echo $LOGNAME`
81 cgid=`(id -g $cusr) 2>/dev/null ||\
82 ((getent passwd "${cusr}"; grep "^${cusr}:" /etc/passwd; ypmatch "${cusr}" passwd; nismatch "${cusr}" passwd; nidump passwd . | grep "^${cusr}:") 2>/dev/null |\
83 sed -n -e '1p' | awk -F: '{ print $4; }')`
84 cgrp=`(id -gn $cusr) 2>/dev/null ||\
85 ((getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null | grep "^[^:]*:[^:]*:${cgid}:" |\
86 sed -n -e '1p' | awk -F: '{ print $1; }')`
87 [ ".$cgrp" = . ] && cgrp="$cusr"
89 # determine OpenPKG susr/sgrp
90 if [ ".$susr" = . ]; then
91 if [ ".$usr" = . ]; then
92 susr="$cusr"
93 else
94 susr="root"
95 fi
96 fi
97 if [ ".$sgrp" = . ]; then
98 sgrp=`(id -gn $susr) 2>/dev/null`
99 if [ ".$sgrp" = . ]; then
100 tgid=`(getent passwd "${susr}"; grep "^${susr}:" /etc/passwd; ypmatch "${susr}" passwd; nismatch "${susr}" passwd; nidump passwd . | grep "^${susr}:") 2>/dev/null |\
101 sed -n -e '1p' | awk -F: '{ print $4; }'`
102 if [ ".$tgid" != . ]; then
103 sgid="${tgid}"
104 sgrp=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
105 grep "^[^:]*:[^:]*:${sgid}:" | sed -n -e '1p' | awk -F: '{ print $1; }'`
106 fi
107 if [ ".$sgrp" = . ]; then
108 sgrp="wheel"
109 fi
110 fi
111 fi
113 # determine OpenPKG musr/mgrp
114 if [ ".$musr" = . ]; then
115 musr="$usr"
116 fi
117 if [ ".$musr" = . ]; then
118 musr="$cusr"
119 fi
120 if [ ".$mgrp" = . ]; then
121 mgrp=`(id -gn $musr) 2>/dev/null`
122 if [ ".$mgrp" = . ]; then
123 tgid=`(getent passwd "${musr}"; grep "^${musr}:" /etc/passwd; ypmatch "${musr}" passwd; nismatch "${musr}" passwd; nidump passwd . | grep "^${musr}:") 2>/dev/null |\
124 sed -n -e '1p' | awk -F: '{ print $4; }'`
125 if [ ".$tgid" != . ]; then
126 mgid="${tgid}"
127 mgrp=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
128 grep "^[^:]*:[^:]*:${mgid}:" | sed -n -e '1p' | awk -F: '{ print $1; }'`
129 fi
130 if [ ".$mgrp" = . ]; then
131 mgrp="$grp"
132 fi
133 if [ ".$mgrp" = . ]; then
134 mgrp="$cgrp"
135 fi
136 fi
137 fi
139 # determine OpenPKG rusr/rgrp
140 if [ ".$rusr" = . ]; then
141 rusr="${usr}-r"
142 fi
143 if [ ".$rusr" = ".-r" ]; then
144 rusr="$cusr"
145 fi
146 if [ ".$rgrp" = . ]; then
147 rgrp=`(id -gn $rusr) 2>/dev/null`
148 if [ ".$rgrp" = . ]; then
149 tgid=`(getent passwd "${rusr}"; grep "^${rusr}:" /etc/passwd; ypmatch "${rusr}" passwd; nismatch "${rusr}" passwd; nidump passwd . | grep "^${rusr}:") 2>/dev/null |\
150 sed -n -e '1p' | awk -F: '{ print $4; }'`
151 if [ ".$tgid" != . ]; then
152 rgid="${tgid}"
153 rgrp=`(getent group; cat /etc/group; ypcat group; nismatch group; nidump group .) 2>/dev/null |\
154 grep "^[^:]*:[^:]*:${rgid}:" | sed -n -e '1p' | awk -F: '{ print $1; }'`
155 fi
156 if [ ".$rgrp" = . ]; then
157 rgrp="${grp}-r"
158 fi
159 if [ ".$rgrp" = ".-r" ]; then
160 rgrp="$cgrp"
161 fi
162 fi
163 fi
165 # determine OpenPKG nusr/ngrp
166 if [ ".$nusr" = . ]; then
167 nusr="${usr}-n"
168 fi
169 if [ ".$nusr" = ".-n" ]; then
170 nusr="$cusr"
171 fi
172 if [ ".$ngrp" = . ]; then
173 ngrp=`(id -gn $nusr) 2>/dev/null`
174 if [ ".$ngrp" = . ]; then
175 tgid=`(getent passwd "${nusr}"; grep "^${nusr}:" /etc/passwd; ypmatch "${nusr}" passwd; nismatch "${nusr}" passwd; nidump passwd . | grep "^${nusr}:") 2>/dev/null |\
176 sed -n -e '1p' | awk -F: '{ print $4; }'`
177 if [ ".$tgid" != . ]; then
178 ngid="${tgid}"
179 ngrp=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
180 grep "^[^:]*:[^:]*:${ngid}:" | sed -n -e '1p' | awk -F: '{ print $1; }'`
181 fi
182 if [ ".$ngrp" = . ]; then
183 ngrp="${grp}-n"
184 fi
185 if [ ".$ngrp" = ".-n" ]; then
186 ngrp="$cgrp"
187 fi
188 fi
189 fi
191 # determine OpenPKG suid/sgid
192 # (currently not necessary)
194 # determine OpenPKG muid/mgid
195 # (currently not necessary)
197 # determine OpenPKG ruid/rgid
198 # (currently not necessary)
200 # determine OpenPKG nuid/ngid
201 # (currently not necessary)
203 # print results
204 output=""
205 for var in \
206 susr sgrp \
207 musr mgrp \
208 rusr rgrp \
209 nusr ngrp \
210 suid sgid \
211 muid mgid \
212 ruid rgid \
213 nuid ngid; do
214 eval "val=\"\$$var\""
215 if [ ".$output" = . ]; then
216 output="$var=\"$val\""
217 else
218 output="$output; $var=\"$val\""
219 fi
220 done
221 echo $output