Contents of /trunk/core/glibc/glibc-2.16.0-r3.smage2
Parent Directory | Revision Log
Revision 13893 -
(show annotations)
(download)
Mon Oct 29 11:20:22 2012 UTC (11 years, 10 months ago) by niro
File size: 12438 byte(s)
Mon Oct 29 11:20:22 2012 UTC (11 years, 10 months ago) by niro
File size: 12438 byte(s)
-replaced mutex patch with upstream one and added mor patches to fix some seqfaults and other issues
1 | # $Id$ |
2 | |
3 | PNAME="glibc" |
4 | PVER="2.16.0" |
5 | PBUILD="r3" |
6 | |
7 | PCAT="sys-libs" |
8 | |
9 | DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads." |
10 | HOMEPAGE="http://www.gnu.org/software/libc/libc.html" |
11 | |
12 | DEPEND=">= sys-apps/base-files-0.1" |
13 | |
14 | # we force headers to one specific version |
15 | SDEPEND="== sys-kernel/linux-libc-headers-3.6.3" |
16 | PROVIDE="virtual/glibc" |
17 | |
18 | # functions to include in the mage file |
19 | SPECIAL_FUNCTIONS="fix_db_files" |
20 | |
21 | SRCFILE="glibc-${PVER}.tar.xz" |
22 | SRCDIR="${BUILDDIR}/glibc-${PVER}" |
23 | |
24 | ENVD_REV="1.2" |
25 | |
26 | sminclude mtools |
27 | |
28 | SRC_URI=( |
29 | ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE} |
30 | ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE} |
31 | gnu://${PNAME}/${SRCFILE} |
32 | mirror://${PNAME}/${SRCFILE} |
33 | mirror://${PNAME}/glibc.envd-${ENVD_REV} |
34 | mirror://${PNAME}/locale.gen-header |
35 | mirror://${PNAME}/locale-gen |
36 | mirror://${PNAME}/${PNAME}-2.15-fix-res_query-assert.patch |
37 | mirror://${PNAME}/${PNAME}-${PVER}-unlock-mutex.patch |
38 | mirror://${PNAME}/${PNAME}-${PVER}-rpcgen-cpp-path.patch |
39 | mirror://${PNAME}/${PNAME}-${PVER}-strncasecmp-segfault.patch |
40 | mirror://${PNAME}/${PNAME}-${PVER}-strtod-overflow.patch |
41 | mirror://${PNAME}/${PNAME}-${PVER}-detect-fma.patch |
42 | mirror://${PNAME}/${PNAME}-${PVER}-glob-use-size_t.patch |
43 | ) |
44 | |
45 | # sed line: on 2 digits add an zero: 2.7 -> 2.7.0 |
46 | UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'" |
47 | |
48 | # glibc don't like strong CFLAGS |
49 | export CFLAGS="${CFLAGS//-O?} -O2" |
50 | # glibc -> nptl thread don't like striping |
51 | msetfeature "!strip" |
52 | # gcc 3.0 - 3.3 needs this: |
53 | export CFLAGS="${CFLAGS} -finline-limit=2000" |
54 | export CXXFLAGS="${CFLAGS}" |
55 | export LDFLAGS="${LDFLAGS//-Wl,--relax}" |
56 | |
57 | # hack to fix NPTL issues with xen, only required on 32bit arches |
58 | if [[ ${ARCH} = i*86 ]] |
59 | then |
60 | export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs" |
61 | fi |
62 | |
63 | # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic |
64 | # first filter -mtune and -march from flags |
65 | for flag in ${CFLAGS} |
66 | do |
67 | case ${flag} in |
68 | -mtune=*) continue ;; |
69 | -march=*) continue ;; |
70 | esac |
71 | newflags="${newflags} ${flag}" |
72 | done |
73 | export CFLAGS="${newflags}" |
74 | |
75 | # than add our defaults for glibc |
76 | [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86 |
77 | export CFLAGS="${CFLAGS} -mtune=generic" # all arches |
78 | export CXXFLAGS="${CFLAGS}" |
79 | |
80 | # use other linux-headers |
81 | [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include" |
82 | |
83 | # kernel support |
84 | export ENABLE_KERNEL=2.6.32 |
85 | |
86 | src_prepare() |
87 | { |
88 | munpack ${SRCFILE} || die |
89 | cd ${SRCDIR} |
90 | |
91 | # fix res_query assertion |
92 | # http://sourceware.org/bugzilla/show_bug.cgi?id=13013 |
93 | mpatch ${PNAME}-2.15-fix-res_query-assert.patch || die |
94 | |
95 | # prevent hang by locked mutex |
96 | # http://sourceware.org/git/?p=glibc.git;a=patch;h=c30e8edf |
97 | mpatch ${PNAME}-${PVER}-unlock-mutex.patch || die |
98 | |
99 | # prevent need for /lib/cpp symlink |
100 | # http://sourceware.org/git/?p=glibc.git;a=commit;h=bf9b740a |
101 | mpatch ${PNAME}-${PVER}-rpcgen-cpp-path.patch || die |
102 | |
103 | # strncasecmp segfault on i686 |
104 | # http://sourceware.org/git/?p=glibc.git;a=commit;h=6db8f737 |
105 | mpatch ${PNAME}-${PVER}-strncasecmp-segfault.patch || die |
106 | |
107 | # strtod integer/buffer overflow |
108 | # http://sourceware.org/git/?p=glibc.git;a=commit;h=da1f4319 |
109 | mpatch ${PNAME}-${PVER}-strtod-overflow.patch || die |
110 | |
111 | # detect FMA supprt |
112 | # http://sourceware.org/git/?p=glibc.git;a=commit;h=a5cfcf08 |
113 | mpatch ${PNAME}-${PVER}-detect-fma.patch || die |
114 | |
115 | # prevent overflow in globc |
116 | # http://sourceware.org/git/?p=glibc.git;a=commit;h=6c62f108 |
117 | mpatch ${PNAME}-${PVER}-glob-use-size_t.patch || die |
118 | |
119 | # scripts/test-installation.pl sometime fails |
120 | # |
121 | # CC="gcc" /usr/bin/perl scripts/test-installation.pl |
122 | # /usr/src/glibc-2.16.0.bld/ |
123 | # Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if $(abi-32-ld-soname),$(abi-32-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD> |
124 | # line 1 |
125 | sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die |
126 | |
127 | # binutils patch needs reconf |
128 | # autoconf --force || die |
129 | |
130 | # fix permissions on some of the scripts |
131 | chmod u+x ${SRCDIR}/scripts/*.sh || die |
132 | |
133 | install -d ${SRCDIR}/build || die |
134 | cd ${SRCDIR}/build |
135 | |
136 | if [ ! -f /etc/ld.so.conf ] |
137 | then |
138 | touch /etc/ld.so.conf || die |
139 | fi |
140 | } |
141 | |
142 | src_compile() |
143 | { |
144 | local myopts |
145 | |
146 | # generic pathes |
147 | myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info" |
148 | # disable profiling |
149 | myopts+=" --disable-profile" |
150 | # enable addons |
151 | myopts+=" --enable-add-ons=nptl,libidn" |
152 | # enable tls |
153 | myopts+=" --with-tls --with-__thread" |
154 | # supported kernel-release |
155 | myopts+=" --enable-kernel=${ENABLE_KERNEL}" |
156 | # disable cvs and gd support |
157 | myopts+=" --without-cvs --without-gd" |
158 | # enable bindnow |
159 | myopts+=" --enable-bind-now" |
160 | # enable obsolete rpc implementation |
161 | myopts+=" --enable-obsolete-rpc" |
162 | |
163 | # support multilib lib64 dir (x86_64 only) |
164 | if [[ ${ARCH} = x86_64 ]] |
165 | then |
166 | # first build a -m32 version |
167 | install -d ${SRCDIR}/build-m32 |
168 | cd ${SRCDIR}/build-m32 |
169 | |
170 | CC="gcc -m32" CXX="g++ -m32" \ |
171 | CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \ |
172 | CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \ |
173 | ../configure \ |
174 | --build=${CHOST} \ |
175 | --host=i686-pc-linux-gnu \ |
176 | --libdir=/usr/lib \ |
177 | --libexecdir=/usr/lib/glibc \ |
178 | ${myopts} \ |
179 | || die |
180 | |
181 | make PARALLELMFLAGS="${MAKEOPTS}" || die |
182 | fi |
183 | |
184 | cd ${SRCDIR}/build |
185 | |
186 | if [[ ${ARCH} = x86_64 ]]; then |
187 | # make sure the -m64 libs goes really to /lib64 |
188 | echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die |
189 | fi |
190 | |
191 | # kernel-2.6 with nptl needs this |
192 | ../configure \ |
193 | --build=${CHOST} \ |
194 | --host=${CHOST} \ |
195 | --libdir=/usr/$(mlibdir) \ |
196 | --libexecdir=/usr/$(mlibdir)/glibc \ |
197 | ${myopts} \ |
198 | || die |
199 | |
200 | make PARALLELMFLAGS="${MAKEOPTS}" || die |
201 | } |
202 | |
203 | src_install() |
204 | { |
205 | if [[ ${ARCH} = x86_64 ]] |
206 | then |
207 | # install -m32 libs |
208 | cd ${SRCDIR}/build-m32 |
209 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die |
210 | fi |
211 | |
212 | cd ${SRCDIR}/build |
213 | make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die |
214 | |
215 | # do not generate the locales here, let it the user do with the locale-gen tool |
216 | # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die |
217 | |
218 | # install locales list and generate tools |
219 | # generate locale.gen file from localedata/SUPPORTED file |
220 | minstalletc locale.gen-header locale.gen || die |
221 | sed \ |
222 | -e 's:/: :g' \ |
223 | -e 's:\\: :g' \ |
224 | -e 's:SUPPORTED-LOCALES=::' \ |
225 | -e 's:\ \ $::g' \ |
226 | -e '/^#/d' \ |
227 | -e 's:^:#:g' \ |
228 | ${SRCDIR}/localedata/SUPPORTED \ |
229 | >> ${BINDIR}/etc/locale.gen || die |
230 | minstalldir /usr/sbin || die |
231 | minstallexec -s locale-gen /usr/sbin || die |
232 | |
233 | # nsswitch configuration file |
234 | minstalletc ${SRCDIR}/nss/nsswitch.conf || die |
235 | |
236 | # nscd configuration file |
237 | minstalletc ${SRCDIR}/nscd/nscd.conf || die |
238 | |
239 | # gai configuration file |
240 | minstalletc ${SRCDIR}/posix/gai.conf || die |
241 | |
242 | # now in tzdata |
243 | ## we use Berlin as default |
244 | ## busybox compat |
245 | #local args |
246 | #if need_busybox_support /bin/cp |
247 | #then |
248 | # args="-f" |
249 | #else |
250 | # args="--remove-destination" |
251 | #fi |
252 | #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die |
253 | [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; } |
254 | [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; } |
255 | |
256 | # base environment |
257 | minstallenv glibc.envd-${ENVD_REV} 00glibc || die |
258 | if [[ ${ARCH} = x86_64 ]] |
259 | then |
260 | MCONFIG="/etc/env.d/00glibc" |
261 | maddconfig "LDPATH=\"/$(mlibdir)\"" || die |
262 | maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die |
263 | maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die |
264 | maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die |
265 | fi |
266 | |
267 | # strip all binaries |
268 | find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die |
269 | |
270 | # strip all libraries |
271 | # want to be safe here; --strip-unneeded seems to cause pthread problems |
272 | # strip all but libpthread |
273 | install -d ${BUILDDIR}/thread-backup || die |
274 | mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die |
275 | |
276 | # now strip |
277 | find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die |
278 | mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die |
279 | # remove stale directory |
280 | rm -rf ${BUILDDIR}/thread-backup || die |
281 | |
282 | # prepare glibc for installation; slackware method |
283 | minstalldir /incoming || die |
284 | mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die |
285 | mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die |
286 | mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die |
287 | mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die |
288 | } |
289 | |
290 | fix_db_files() |
291 | { |
292 | local i |
293 | local DB_ENTRY="${BUILDDIR}/${PKGNAME}" |
294 | |
295 | for i in .files .symlinks .dirs |
296 | do |
297 | [ ! -f ${DB_ENTRY}/${i} ] && continue |
298 | [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue |
299 | |
300 | echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..." |
301 | |
302 | # /usr/lib/incoming -> empty line; sed2 removes all empty lines |
303 | #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i} |
304 | # do not simply emtpy the line, but change it the the correct path, |
305 | # so no stale libs are around if the package gets updated! |
306 | sed -i \ |
307 | -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \ |
308 | -e "s:/usr/$(mlibdir)/incoming.*::g" \ |
309 | -e '/^$/d' ${DB_ENTRY}/${i} |
310 | done |
311 | } |
312 | |
313 | postinstall() |
314 | { |
315 | # first save the old libpthread.so.0; |
316 | # it will later used to determinate that there are no stale |
317 | # libpthreads that breaks ldconfig |
318 | local OLD_PTHREAD |
319 | OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" |
320 | |
321 | # slackware install method |
322 | |
323 | # we cannot easily install the glibc libs, |
324 | # because our tools for cp etc needs them to run |
325 | |
326 | local file |
327 | |
328 | echo " Switching to new glibc ..." |
329 | # swap libraries on the fly: |
330 | if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]] |
331 | then |
332 | # first create copies of the incoming libraries: |
333 | cd /usr/$(mlibdir)/incoming |
334 | for file in $(find /usr/$(mlibdir)/incoming -type f) |
335 | do |
336 | if [ ! -r "../$(basename ${file}).incoming" ] |
337 | then |
338 | cp -a ${file} ../$(basename ${file}).incoming |
339 | fi |
340 | done |
341 | |
342 | # then switch to them all at once: |
343 | /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null |
344 | |
345 | # finally, rename them and clean up: |
346 | cd /usr/$(mlibdir) |
347 | for file in *.incoming |
348 | do |
349 | rm -f $(basename ${file} .incoming) |
350 | cp -a ${file} $(basename ${file} .incoming) |
351 | /usr/sbin/ldconfig -l $(basename ${file} .incoming) |
352 | rm -f ${file} |
353 | done |
354 | |
355 | # no ldconfig? |
356 | # good, it's safe to just jam it on home (and make links below): |
357 | else |
358 | ( |
359 | cd ${MROOT}/usr/$(mlibdir)/incoming |
360 | for file in * |
361 | do |
362 | cp -a ${file} .. |
363 | done |
364 | |
365 | local my_sym |
366 | local my_dest |
367 | |
368 | # rebuild symlinks |
369 | echo " Recreating Symlinks:" |
370 | for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l) |
371 | do |
372 | my_sym="$(readlink ${i})" |
373 | my_dest="$(basename ${i})" |
374 | |
375 | echo " ${my_dest} -> ${my_dest}" |
376 | |
377 | # assure to remove the old ones; |
378 | [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \ |
379 | rm ${MROOT}/usr/$(mlibdir)/"${my_dest}" |
380 | |
381 | ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}" |
382 | done |
383 | ) |
384 | fi |
385 | |
386 | # now, get rid of the temporary directory: |
387 | rm -rf ${MROOT}/usr/$(mlibdir)/incoming |
388 | |
389 | # remove stale nptl libpthread-2.?.?.so, |
390 | # fix only needed for glibc with linuxthreads; |
391 | # prevent reloc errors such as: |
392 | # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory |
393 | |
394 | # get our new libpthread.so.0 |
395 | local NEW_PTHREAD |
396 | NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)" |
397 | |
398 | if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ] |
399 | then |
400 | echo " Removing stale libpthread libraries ..." |
401 | for file in ${MROOT}/usr/$(mlibdir)/libpthread-* |
402 | do |
403 | if [ "$(basename ${file})" != "${NEW_PTHREAD}" ] |
404 | then |
405 | rm -f ${file} |
406 | fi |
407 | done |
408 | |
409 | #rm -f /lib/${OLD_PTHREAD} |
410 | |
411 | ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0 |
412 | fi |
413 | |
414 | if [ -x /usr/sbin/iconvconfig ] |
415 | then |
416 | # generate fastloading iconv module configuration file. |
417 | echo " Generate iconv module config ..." |
418 | /usr/sbin/iconvconfig --prefix=${MROOT}/ |
419 | fi |
420 | |
421 | # not working with busybox |
422 | if ! need_busybox_support /sbin/init |
423 | then |
424 | # reloading init |
425 | echo " Reloading init ..." |
426 | [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null |
427 | fi |
428 | |
429 | # generating user def locales |
430 | echo " Generating user defined locales ..." |
431 | [[ -z ${MROOT} ]] && /usr/sbin/locale-gen |
432 | |
433 | # now we must fix the mage db files |
434 | # to stop the annoying errors messages |
435 | fix_db_files |
436 | } |