Magellan Linux

Annotation of /branches/magellan-next/core/glibc/glibc-2.13-r5.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9621 - (hide annotations) (download)
Tue Jan 3 15:06:32 2012 UTC (12 years, 4 months ago) by niro
File size: 12228 byte(s)
-fixed locale.gen generation
1 niro 9619 # $Id$
2    
3     PNAME="glibc"
4     PVER="2.13"
5     PBUILD="r5"
6    
7     PCATEGORIE="sys-libs"
8    
9     DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads."
10     HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
11    
12     DEPEND=">= sys-libs/libstdc++-4.6
13     >= sys-apps/base-files-0.1"
14    
15     # we force headers to one specific version
16     # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!)
17     SDEPEND="== sys-kernel/linux-libc-headers-2.6.39"
18     PROVIDE="virtual/glibc"
19    
20     # functions to include in the mage file
21     SPECIAL_FUNCTIONS="fix_db_files"
22    
23     SRCFILE="glibc-${PVER/.0/}.tar.bz2"
24     SRCDIR="${BUILDDIR}/glibc-${PVER/.0/}"
25    
26     sminclude mtools
27    
28     SRC_URI=(
29     ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
30     ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
31     gnu://${PNAME}/${SRCFILE}
32     mirror://${PNAME}/${SRCFILE}
33     mirror://${PNAME}/glibc.envd
34     mirror://${PNAME}/locale.gen-header
35     mirror://${PNAME}/locale-gen
36     mirror://${PNAME}/${PNAME}-2.12.1-bz4781.patch
37     mirror://${PNAME}/${PNAME}-2.12.1-i686.patch
38     mirror://${PNAME}/${PNAME}-2.12.1-static-shared-getpagesize.patch
39     mirror://${PNAME}/${PNAME}-2.12.2-ignore-origin-of-privileged-program.patch
40     mirror://${PNAME}/${PNAME}-2.13-prelink.patch
41     mirror://${PNAME}/${PNAME}-2.13-dlclose-search-reset.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     # than add our defaults for glibc
73     [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
74     export CFLAGS="${CFLAGS} -mtune=generic" # all arches
75     export CXXFLAGS="${CFLAGS}"
76    
77     # use other linux-headers
78     [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
79    
80     # kernel support
81     export ENABLE_KERNEL=2.6.27
82    
83     src_prepare()
84     {
85     munpack ${SRCFILE} || die
86     cd ${SRCDIR}
87    
88     # disable binutils -as-needed
89     sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die
90    
91     # http://sources.redhat.com/bugzilla/show_bug.cgi?id=4781
92     mpatch ${PNAME}-2.12.1-bz4781.patch || die
93    
94     # http://sources.redhat.com/bugzilla/show_bug.cgi?id=411
95     # http://sourceware.org/ml/libc-alpha/2009-07/msg00072.html
96     mpatch ${PNAME}-2.12.1-i686.patch || die
97    
98     # fixes static link issues
99     # http://bugs.gentoo.org/332927
100     mpatch ${PNAME}-2.12.1-static-shared-getpagesize.patch || die
101    
102     # security fix, fixes CVE-2010-3847
103     # see: http://www.exploit-db.com/exploits/15274/
104     mpatch ${PNAME}-2.12.2-ignore-origin-of-privileged-program.patch || die
105    
106     # fix prelinking
107     mpatch ${PNAME}-2.13-prelink.patch || die
108    
109     # fixes dlopen issues like
110     # 'symbol lookup error: libstdc++.so.6: undefined symbol: _ZNSt14error_categoryD2Ev'
111     # see: https://bugzilla.redhat.com/show_bug.cgi?id=593675
112     # && http://sourceware.org/ml/libc-hacker/2010-05/msg00007.html
113     mpatch ${PNAME}-2.13-dlclose-search-reset.patch || die
114    
115     # http://sourceware.org/bugzilla/show_bug.cgi?id=12403
116     if [[ ${ARCH} = x86_64 ]]
117     then
118     sed -i '/__ASSUME_PRIVATE_FUTEX/d' sysdeps/unix/sysv/linux/kernel-features.h || die
119     fi
120    
121     # binutils patch needs reconf
122     autoconf --force || die
123    
124     # fix permissions on some of the scripts
125     chmod u+x ${SRCDIR}/scripts/*.sh || die
126    
127     install -d ${SRCDIR}/build || die
128     cd ${SRCDIR}/build
129    
130     if [ ! -f /etc/ld.so.conf ]
131     then
132     touch /etc/ld.so.conf || die
133     fi
134     }
135    
136     src_compile()
137     {
138     local myopts
139    
140     # generic paths
141     myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
142     # disable profiling
143     myopts+=" --disable-profile"
144     # enable addons
145     myopts+=" --enable-add-ons=nptl,libidn"
146     # enable tls
147     myopts+=" --with-tls --with-__thread"
148     # supported kernel-release
149     myopts+=" --enable-kernel=${ENABLE_KERNEL}"
150     # disable cvs and gd support
151     myopts+=" --without-cvs --without-gd"
152     # enable bindnow
153     myopts+=" --enable-bind-now"
154    
155     # support multilib lib64 dir (x86_64 only)
156     if [[ ${ARCH} = x86_64 ]]
157     then
158     # first build a -m32 version
159     install -d ${SRCDIR}/build-m32
160     cd ${SRCDIR}/build-m32
161    
162     CC="gcc -m32" CXX="g++ -m32" \
163     CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
164     CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
165     ../configure \
166     --build=${CHOST} \
167     --host=i686-pc-linux-gnu \
168     --libdir=/usr/lib \
169     --libexecdir=/usr/lib/glibc \
170 niro 9620 ${myopts} \
171 niro 9619 || die
172    
173     make PARALLELMFLAGS="${MAKEOPTS}" || die
174     fi
175    
176     cd ${SRCDIR}/build
177    
178     if [[ ${ARCH} = x86_64 ]]; then
179     # make sure the -m64 libs goes really to /lib64
180     echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
181     fi
182    
183     # kernel-2.6 with nptl needs this
184     ../configure \
185     --build=${CHOST} \
186     --host=${CHOST} \
187     --libdir=/usr/$(mlibdir) \
188     --libexecdir=/usr/$(mlibdir)/glibc \
189 niro 9620 ${myopts} \
190 niro 9619 || die
191    
192     make PARALLELMFLAGS="${MAKEOPTS}" || die
193     }
194    
195     src_install()
196     {
197     if [[ ${ARCH} = x86_64 ]]
198     then
199     # install -m32 libs
200     cd ${SRCDIR}/build-m32
201     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
202     fi
203    
204     cd ${SRCDIR}/build
205     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
206    
207     # do not generate the locales here, let it the user do with the locale-gen tool
208     # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
209    
210     # install locales list and generate tools
211     # generate locale.gen file from localedata/SUPPORTED file
212     minstalletc locale.gen-header locale.gen || die
213     sed \
214     -e 's:/: :g' \
215     -e 's:\\: :g' \
216     -e 's:SUPPORTED-LOCALES=::' \
217     -e 's:\ \ $::g' \
218     -e '/^#/d' \
219     -e 's:^:#:g' \
220 niro 9621 ${SRCDIR}/localedata/SUPPORTED \
221 niro 9619 >> ${BINDIR}/etc/locale.gen || die
222     minstalldir /usr/sbin || die
223     minstallexec -s locale-gen /usr/sbin || die
224    
225     # nsswitch configuration file
226     minstalletc nss/nsswitch.conf || die
227    
228     # nscd configuration file
229     minstalletc nscd/nscd.conf || die
230    
231     # gai configuration file
232     minstalletc posix/gai.conf || die
233    
234     # we use Berlin as default
235     cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
236     [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
237     [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
238    
239     # base environment
240     minstallenv glibc.envd 00glibc || die
241     if [[ ${ARCH} = x86_64 ]]
242     then
243     echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
244     echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
245     fi
246    
247     # move some libs and tools to proper locations
248     # will suppress some ldconfig errors too
249     mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die
250     mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die
251     mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die
252     mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die
253    
254     # strip all binaries
255     find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
256    
257     # strip all libraries
258     # want to be safe here; --strip-unneeded seems to cause pthread problems
259     # strip all but libpthread
260     install -d ${BUILDDIR}/thread-backup || die
261     mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
262    
263     # now strip
264     find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
265     mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die
266     # remove stale directory
267     rm -rf ${BUILDDIR}/thread-backup || die
268    
269     # prepare glibc for installation; slackware method
270     minstalldir /incoming || die
271     mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die
272     mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die
273     mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die
274     }
275    
276     fix_db_files()
277     {
278     local i
279     local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
280    
281     for i in .files .symlinks .dirs
282     do
283     [ ! -f ${DB_ENTRY}/${i} ] && continue
284     [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
285    
286     echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..."
287    
288     # /lib/incoming -> empty line; sed2 removes all empty lines
289     #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
290     # do not simply emtpy the line, but change it the the correct path,
291     # so no stale libs are around if the package gets updated!
292     sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \
293     -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
294     done
295     }
296    
297     preinstall()
298     {
299     # remove libmemusage and libpcprofile as these libs now
300     # resides in /usr/lib and are symlinked to /lib
301     if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]]
302     then
303     rm ${MROOT}/$(mlibdir)/libmemusage.so
304     fi
305    
306     if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]]
307     then
308     rm ${MROOT}/$(mlibdir)/libpcprofile.so
309     fi
310     }
311    
312     postinstall()
313     {
314     # first save the old libpthread.so.0;
315     # it will later used to determinate that there are no stale
316     # libpthreads that breaks ldconfig
317     local OLD_PTHREAD
318     OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
319    
320     # slackware install method
321    
322     # we cannot easily install the glibc libs,
323     # because our tools for cp etc needs them to run
324    
325     local file
326    
327     echo " Switching to new glibc ..."
328     # swap libraries on the fly:
329     if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
330     then
331     # first create copies of the incoming libraries:
332     cd /$(mlibdir)/incoming
333     for file in $(find /$(mlibdir)/incoming -type f)
334     do
335     if [ ! -r "../$(basename ${file}).incoming" ]
336     then
337     cp -a ${file} ../$(basename ${file}).incoming
338     fi
339     done
340    
341     # then switch to them all at once:
342     /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null
343    
344     # finally, rename them and clean up:
345     cd /$(mlibdir)
346     for file in *.incoming
347     do
348     rm -f $(basename ${file} .incoming)
349     cp -a ${file} $(basename ${file} .incoming)
350     /sbin/ldconfig -l $(basename ${file} .incoming)
351     rm -f ${file}
352     done
353    
354     # no ldconfig?
355     # good, it's safe to just jam it on home (and make links below):
356     else
357     (
358     cd ${MROOT}/$(mlibdir)/incoming
359     for file in *
360     do
361     cp -a ${file} ..
362     done
363    
364     local my_sym
365     local my_dest
366    
367     # rebuild symlinks
368     echo " Recreating Symlinks:"
369     for i in $(find ${MROOT}/$(mlibdir)/incoming -type l)
370     do
371     my_sym="$(readlink ${i})"
372     my_dest="$(basename ${i})"
373    
374     echo " ${my_dest} -> ${my_dest}"
375    
376     # assure to remove the old ones;
377     [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \
378     rm ${MROOT}/$(mlibdir)/"${my_dest}"
379    
380     ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}"
381     done
382     )
383     fi
384    
385     # now, get rid of the temporary directory:
386     rm -rf ${MROOT}/$(mlibdir)/incoming
387    
388     # remove stale nptl libpthread-2.?.?.so,
389     # fix only needed for glibc with linuxthreads;
390     # prevent reloc errors such as:
391     # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
392    
393     # get our new libpthread.so.0
394     local NEW_PTHREAD
395     NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
396    
397     if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
398     then
399     echo " Removing stale libpthread libraries ..."
400     for file in ${MROOT}/$(mlibdir)/libpthread-*
401     do
402     if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
403     then
404     rm -f ${file}
405     fi
406     done
407    
408     #rm -f /lib/${OLD_PTHREAD}
409    
410     ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0
411     fi
412    
413     if [ -x /usr/sbin/iconvconfig ]
414     then
415     # generate fastloading iconv module configuration file.
416     echo " Generate iconv module config ..."
417     /usr/sbin/iconvconfig --prefix=${MROOT}/
418     fi
419    
420     # reloading init
421     echo " Reloading init ..."
422     [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
423    
424     # generating user def locales
425     echo " Generating user defined locales ..."
426     [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
427    
428     # now we must fix the mage db files
429     # to stop the annoying errors messages
430     fix_db_files
431     }