Magellan Linux

Annotation of /smage/trunk/core/eglibc/eglibc-2.12.2_20110125-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1068 - (hide annotations) (download)
Tue Jan 25 18:45:14 2011 UTC (13 years, 3 months ago) by niro
File size: 15312 byte(s)
-fixed private futix errors on x86_64 and enabled kernel-2.6.27
1 niro 1067 # $Id: eglibc-2.10.0_20091229-r4.smage2 497 2010-05-07 20:36:34Z niro $
2    
3     PNAME="eglibc"
4     PVER="2.12.2_20110125"
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 niro 1068 export ENABLE_KERNEL=2.6.27
74 niro 1067
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 niro 1068 # 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 niro 1067 # fix permissions on some of the scripts
292     chmod u+x ${SRCDIR}/scripts/*.sh || die
293    
294     install -d ${SRCDIR}/build || die
295     cd ${SRCDIR}/build
296    
297     if [ ! -f /etc/ld.so.conf ]
298     then
299     touch /etc/ld.so.conf || die
300     fi
301    
302     # disable some eglibc defaults:
303     # no ipv6 support
304     # sed -i "s:^\(OPTION_EGLIBC_ADVANCED_INET6 =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
305     # only some default charsets
306     # sed -i "s:^\(OPTION_EGLIBC_CHARSETS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
307     # disable support for locales
308     # sed -i "s:^\(OPTION_EGLIBC_CATGETS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
309     # sed -i "s:^\(OPTION_EGLIBC_LOCALES =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
310     # sed -i "s:^\(OPTION_EGLIBC_LOCALE_CODE =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
311     # disable mail aliases support
312     # sed -i "s:^\(OPTION_EGLIBC_DB_ALIASES =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
313     # # disable nis support
314     # sed -i "s:^\(OPTION_EGLIBC_NIS =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
315     # no remote services via rsh
316     # sed -i "s:^\(OPTION_EGLIBC_RCMD =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
317     # no sunrpc
318     # sed -i "s:^\(OPTION_EGLIBC_SUNRPC =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
319     # no support for old access of utmp
320     # sed -i "s:^\(OPTION_EGLIBC_UTMP =\).*:\1 n:" ${SRCDIR}/option-groups.defaults || die
321     }
322    
323     src_compile()
324     {
325     # support multilib lib64 dir (x86_64 only)
326     if [[ ${ARCH} = x86_64 ]]
327     then
328     # first build a -m32 version
329     install -d ${SRCDIR}/build-m32
330     cd ${SRCDIR}/build-m32
331    
332     CC="gcc -m32" CXX="g++ -m32" \
333     CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
334     CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
335     ../configure \
336     --build=${CHOST} \
337     --host=i686-pc-linux-gnu \
338     --prefix=/usr \
339     --mandir=/usr/share/man \
340     --infodir=/usr/share/info \
341     --disable-profile \
342     --enable-add-ons=nptl,libidn \
343     --with-tls \
344     --with-__thread \
345     --enable-kernel=${ENABLE_KERNEL} \
346     --without-cvs \
347     --without-gd \
348     --libdir=/usr/lib \
349     --libexecdir=/usr/lib/eglibc \
350     --with-headers=${ALT_HEADERS} \
351     --disable-nls \
352     --enable-bind-now \
353     || die
354    
355     make PARALLELMFLAGS="${MAKEOPTS}" || die
356     fi
357    
358     cd ${SRCDIR}/build
359    
360     if [[ ${ARCH} = x86_64 ]]; then
361     # make sure the -m64 libs goes really to /lib64
362     echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
363     fi
364    
365     # kernel-2.6 with nptl needs this
366     ../configure \
367     --build=${CHOST} \
368     --host=${CHOST} \
369     --prefix=/usr \
370     --mandir=/usr/share/man \
371     --infodir=/usr/share/info \
372     --disable-profile \
373     --enable-add-ons=nptl,libidn \
374     --with-tls \
375     --with-__thread \
376     --enable-kernel=${ENABLE_KERNEL} \
377     --without-cvs \
378     --without-gd \
379     --libdir=/usr/$(mlibdir) \
380     --libexecdir=/usr/$(mlibdir)/eglibc \
381     --with-headers=${ALT_HEADERS} \
382     --enable-bind-now \
383     || die
384    
385     make PARALLELMFLAGS="${MAKEOPTS}" || die
386     }
387    
388     src_install_eglibc()
389     {
390     if [[ ${ARCH} = x86_64 ]]
391     then
392     # install -m32 libs
393     cd ${SRCDIR}/build-m32
394     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
395     fi
396    
397     cd ${SRCDIR}/build
398     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
399    
400     # cleanup
401     zapmost ${BINDIR} $(mlibdir) \
402     usr/$(mlibdir)/*.so \
403     $([[ ${ARCH} = x86_64 ]] && echo 'lib usr/lib/*.so') \
404     sbin/ldconfig \
405     usr/bin/iconv \
406     usr/bin/locale \
407     usr/$(mlibdir)/gconv/ISO8859-1.so \
408     usr/$(mlibdir)/gconv/UNICODE.so \
409     usr/$(mlibdir)/gconv/gconv-modules \
410     $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \
411     $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \
412     $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
413     || die
414    
415     # base environment
416     minstallenv eglibc.envd 00eglibc || die
417     if [[ ${ARCH} = x86_64 ]]
418     then
419     echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00eglibc || die
420     echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00eglibc || die
421     fi
422    
423     # move some libs and tools to proper locations
424     # will suppress some ldconfig errors too
425     mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die
426     mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die
427     mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die
428     mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die
429    
430     # strip all binaries
431     find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
432    
433     # strip all libraries
434     # want to be safe here; --strip-unneeded seems to cause pthread problems
435     # strip all but libpthread
436     install -d ${BUILDDIR}/thread-backup || die
437     mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
438     # now strip
439     find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
440     mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die
441     # remove stale directory
442     rm -rf ${BUILDDIR}/thread-backup || die
443    
444     # prepare glibc for installation; slackware method
445     minstalldir /incoming || die
446     mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die
447     mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die
448     mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die
449     }
450    
451     src_install_eglibc-dev()
452     {
453     if [[ ${ARCH} = x86_64 ]]
454     then
455     # install -m32 libs
456     cd ${SRCDIR}/build-m32
457     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
458     fi
459    
460     cd ${SRCDIR}/build
461     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
462    
463     # cleanup -> in eglibc
464     rm -r ${BINDIR}/$(mlibdir) || die
465     rm ${BINDIR}/usr/$(mlibdir)/*.so || die
466     rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
467     rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
468     rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
469     if [[ ${ARCH} = x86_64 ]]
470     then
471     rm -r ${BINDIR}/lib || die
472     rm ${BINDIR}/usr/lib/*.so || die
473     rm ${BINDIR}/usr/lib/gconv/ISO8859-1.so || die
474     rm ${BINDIR}/usr/lib/gconv/UNICODE.so || die
475     rm ${BINDIR}/usr/lib/gconv/gconv-modules || die
476     fi
477     rm ${BINDIR}/sbin/ldconfig || die
478     rm ${BINDIR}/usr/bin/iconv || die
479     rm ${BINDIR}/usr/bin/locale || die
480    
481     # do not generate the locales here, let it the user do with the locale-gen tool
482     # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
483    
484     # install locales list and generate tools
485     # to generate this listing see the glibc-2.5/localedata/SUPPORTED file
486     minstalletc locale.gen || die
487     minstalldir /usr/sbin || die
488     minstallexec -s locale-gen /usr/sbin || die
489    
490     # nsswitch configuration file
491     minstalletc nsswitch.conf || die
492    
493     # nscd configuration file
494     minstalletc nscd.conf || die
495    
496     # we use Berlin as default
497     cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
498     [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
499     [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
500    
501     # strip all binaries
502     find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
503    
504     # strip all libraries
505     find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
506     }
507    
508     fix_db_files()
509     {
510     local i
511     local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
512    
513     for i in .files .symlinks .dirs
514     do
515     [ ! -f ${DB_ENTRY}/${i} ] && continue
516     [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
517    
518     echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..."
519    
520     # /lib/incoming -> empty line; sed2 removes all empty lines
521     #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
522     # do not simply emtpy the line, but change it the the correct path,
523     # so no stale libs are around if the package gets updated!
524     sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \
525     -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
526     done
527     }