Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.16.0-r4.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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