Magellan Linux

Contents of /smage/trunk/core/eglibc/eglibc-2.13.0_20110228-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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