Magellan Linux

Annotation of /smage/branches/alx-0_6_0/core/glibc/glibc-2.13.0-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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