Magellan Linux

Annotation of /smage/trunk/core/eglibc/eglibc-2.12.0_20101019-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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