Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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