Magellan Linux

Annotation of /branches/R11-stable/core/glibc/glibc-2.18-r4.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19764 - (hide annotations) (download)
Thu Oct 17 12:08:19 2013 UTC (10 years, 11 months ago) by niro
Original Path: trunk/core/glibc/glibc-2.18-r4.smage2
File size: 11964 byte(s)
-fixed build with make-4.0
1 niro 19763 # $Id$
2    
3     PNAME="glibc"
4     PVER="2.18"
5     PBUILD="r4"
6    
7     PCAT="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-apps/base-files-0.7
13     >= sys-libs/tzdata-2013"
14    
15     # we force headers to one specific version
16     SDEPEND="== sys-kernel/linux-libc-headers-3.11.5"
17     PROVIDE="virtual/glibc"
18    
19     # functions to include in the mage file
20     SPECIAL_FUNCTIONS="fix_db_files"
21    
22     SRCFILE="glibc-${PVER}.tar.xz"
23     SRCDIR="${BUILDDIR}/glibc-${PVER}"
24    
25     ENVD_REV="1.2"
26    
27     sminclude mtools
28    
29     SRC_URI=(
30     ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
31     ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
32     gnu://${PNAME}/${SRCFILE}
33     mirror://${PNAME}/${SRCFILE}
34     mirror://${PNAME}/glibc.envd-${ENVD_REV}
35     mirror://${PNAME}/locale.gen-header
36     mirror://${PNAME}/locale-gen
37     mirror://${PNAME}/${PNAME}-2.17-syscalld-infinite-loop.patch
38     mirror://${PNAME}/${PNAME}-2.18-readdir_r-CVE-2013-4237.patch
39     mirror://${PNAME}/${PNAME}-2.18-malloc-corrupt-CVE-2013-4332.patch
40     mirror://${PNAME}/${PNAME}-2.18-strcoll-CVE-2012-4412+4424.patch
41     mirror://${PNAME}/${PNAME}-2.18-strstr-hackfix.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    
52     # hack to fix NPTL issues with xen, only required on 32bit arches
53     if [[ ${ARCH} = i*86 ]]
54     then
55     export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
56     fi
57    
58     # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
59     # first filter -mtune and -march from flags
60     for flag in ${CFLAGS}
61     do
62     case ${flag} in
63     -mtune=*) continue ;;
64     -march=*) continue ;;
65     esac
66     newflags="${newflags} ${flag}"
67     done
68     export CFLAGS="${newflags}"
69    
70     # than add our defaults for glibc
71     [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
72     export CFLAGS="${CFLAGS} -mtune=generic" # all arches
73     export CXXFLAGS="${CFLAGS}"
74    
75     # use other linux-headers
76     [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
77    
78     # kernel support
79     export ENABLE_KERNEL=2.6.32
80    
81     src_prepare()
82     {
83     munpack ${SRCFILE} || die
84     cd ${SRCDIR}
85    
86     # security fixes
87     mpatch ${PNAME}-2.18-readdir_r-CVE-2013-4237.patch || die
88     mpatch ${PNAME}-2.18-malloc-corrupt-CVE-2013-4332.patch || die
89     mpatch ${PNAME}-2.18-strcoll-CVE-2012-4412+4424.patch || die
90    
91     # hack fix for strstr issues on x86
92     mpatch ${PNAME}-2.18-strstr-hackfix.patch || die
93    
94     # fixes an infinite loop while syscall.d creation
95     # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711
96     mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die
97     # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines)
98     sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die
99    
100     # scripts/test-installation.pl sometime fails
101     #
102     # CC="gcc" /usr/bin/perl scripts/test-installation.pl
103     # /usr/src/glibc-2.16.0.bld/
104     # Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if $(abi-32-ld-soname),$(abi-32-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD>
105     # line 1
106     sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
107    
108 niro 19764 # fix build with make-4.0
109     sed -i 's:3.79\* | 3.\[89\]\*:& | 4.0:' configure || die
110    
111 niro 19763 # binutils patch needs reconf
112     # autoconf --force || die
113    
114     # fix permissions on some of the scripts
115     chmod u+x ${SRCDIR}/scripts/*.sh || die
116    
117     install -d ${SRCDIR}/build || die
118     cd ${SRCDIR}/build
119    
120     if [ ! -f /etc/ld.so.conf ]
121     then
122     touch /etc/ld.so.conf || die
123     fi
124     }
125    
126     src_compile()
127     {
128     local myopts
129    
130     # generic pathes
131     myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
132     # disable profiling
133     myopts+=" --disable-profile"
134     # enable addons
135     myopts+=" --enable-add-ons=nptl,libidn"
136     # enable tls
137     myopts+=" --with-tls --with-__thread"
138     # supported kernel-release
139     myopts+=" --enable-kernel=${ENABLE_KERNEL}"
140     # disable cvs and gd support
141     myopts+=" --without-cvs --without-gd"
142     # enable bindnow
143     myopts+=" --enable-bind-now"
144     # enable obsolete rpc implementation
145     myopts+=" --enable-obsolete-rpc"
146     # enable lock elesion
147     myopts+=" --enable-lock-elision"
148    
149     # support multilib lib64 dir (x86_64 only)
150     if [[ ${ARCH} = x86_64 ]]
151     then
152     # first build a -m32 version
153     install -d ${SRCDIR}/build-m32
154     cd ${SRCDIR}/build-m32
155    
156     CC="gcc -m32" CXX="g++ -m32" \
157     CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
158     CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
159     ../configure \
160     --build=${CHOST} \
161     --host=i686-pc-linux-gnu \
162     --libdir=/usr/lib \
163     --libexecdir=/usr/lib/glibc \
164     ${myopts} \
165     || die
166    
167     make PARALLELMFLAGS="${MAKEOPTS}" || die
168     fi
169    
170     cd ${SRCDIR}/build
171    
172     if [[ ${ARCH} = x86_64 ]]; then
173     # make sure the -m64 libs goes really to /lib64
174     echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
175     fi
176    
177     # kernel-2.6 with nptl needs this
178     ../configure \
179     --build=${CHOST} \
180     --host=${CHOST} \
181     --libdir=/usr/$(mlibdir) \
182     --libexecdir=/usr/$(mlibdir)/glibc \
183     ${myopts} \
184     || die
185    
186     make PARALLELMFLAGS="${MAKEOPTS}" || die
187     }
188    
189     src_install()
190     {
191     if [[ ${ARCH} = x86_64 ]]
192     then
193     # install -m32 libs
194     cd ${SRCDIR}/build-m32
195     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
196     fi
197    
198     cd ${SRCDIR}/build
199     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
200    
201     # do not generate the locales here, let it the user do with the locale-gen tool
202     # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
203    
204     # install locales list and generate tools
205     # generate locale.gen file from localedata/SUPPORTED file
206     minstalletc locale.gen-header locale.gen || die
207     sed \
208     -e 's:/: :g' \
209     -e 's:\\: :g' \
210     -e 's:SUPPORTED-LOCALES=::' \
211     -e 's:\ \ $::g' \
212     -e '/^#/d' \
213     -e 's:^:#:g' \
214     ${SRCDIR}/localedata/SUPPORTED \
215     >> ${BINDIR}/etc/locale.gen || die
216     minstalldir /usr/sbin || die
217     minstallexec -s locale-gen /usr/sbin || die
218    
219     # nsswitch configuration file
220     minstalletc ${SRCDIR}/nss/nsswitch.conf || die
221    
222     # nscd configuration file
223     minstalletc ${SRCDIR}/nscd/nscd.conf || die
224    
225     # gai configuration file
226     minstalletc ${SRCDIR}/posix/gai.conf || die
227    
228     # now in tzdata
229     ## we use Berlin as default
230     ## busybox compat
231     #local args
232     #if need_busybox_support /bin/cp
233     #then
234     # args="-f"
235     #else
236     # args="--remove-destination"
237     #fi
238     #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
239     [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
240     [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
241    
242     # base environment
243     minstallenv glibc.envd-${ENVD_REV} 00glibc || die
244     if [[ ${ARCH} = x86_64 ]]
245     then
246     MCONFIG="/etc/env.d/00glibc"
247     maddconfig "LDPATH=\"/$(mlibdir)\"" || die
248     maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
249     maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
250     maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
251     fi
252    
253     # strip all binaries
254     find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
255    
256     # strip all libraries
257     # want to be safe here; --strip-unneeded seems to cause pthread problems
258     # strip all but libpthread
259     install -d ${BUILDDIR}/thread-backup || die
260     mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
261    
262     # now strip
263     find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
264     mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
265     # remove stale directory
266     rm -rf ${BUILDDIR}/thread-backup || die
267    
268     # prepare glibc for installation; slackware method
269     minstalldir /incoming || die
270     mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
271     mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
272     mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
273     mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(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 /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
287    
288     # /usr/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 \
293     -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
294     -e "s:/usr/$(mlibdir)/incoming.*::g" \
295     -e '/^$/d' ${DB_ENTRY}/${i}
296     done
297     }
298    
299     postinstall()
300     {
301     # first save the old libpthread.so.0;
302     # it will later used to determinate that there are no stale
303     # libpthreads that breaks ldconfig
304     local OLD_PTHREAD
305     OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
306    
307     # slackware install method
308    
309     # we cannot easily install the glibc libs,
310     # because our tools for cp etc needs them to run
311    
312     local file
313    
314     echo " Switching to new glibc ..."
315     # swap libraries on the fly:
316     if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
317     then
318     # first create copies of the incoming libraries:
319     cd /usr/$(mlibdir)/incoming
320     for file in $(find /usr/$(mlibdir)/incoming -type f)
321     do
322     if [ ! -r "../$(basename ${file}).incoming" ]
323     then
324     cp -a ${file} ../$(basename ${file}).incoming
325     fi
326     done
327    
328     # then switch to them all at once:
329     /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
330    
331     # finally, rename them and clean up:
332     cd /usr/$(mlibdir)
333     for file in *.incoming
334     do
335     rm -f $(basename ${file} .incoming)
336     cp -a ${file} $(basename ${file} .incoming)
337     /usr/sbin/ldconfig -l $(basename ${file} .incoming)
338     rm -f ${file}
339     done
340    
341     # no ldconfig?
342     # good, it's safe to just jam it on home (and make links below):
343     else
344     (
345     cd ${MROOT}/usr/$(mlibdir)/incoming
346     for file in *
347     do
348     cp -a ${file} ..
349     done
350    
351     local my_sym
352     local my_dest
353    
354     # rebuild symlinks
355     echo " Recreating Symlinks:"
356     for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
357     do
358     my_sym="$(readlink ${i})"
359     my_dest="$(basename ${i})"
360    
361     echo " ${my_dest} -> ${my_dest}"
362    
363     # assure to remove the old ones;
364     [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
365     rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
366    
367     ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
368     done
369     )
370     fi
371    
372     # now, get rid of the temporary directory:
373     rm -rf ${MROOT}/usr/$(mlibdir)/incoming
374    
375     # remove stale nptl libpthread-2.?.?.so,
376     # fix only needed for glibc with linuxthreads;
377     # prevent reloc errors such as:
378     # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
379    
380     # get our new libpthread.so.0
381     local NEW_PTHREAD
382     NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
383    
384     if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
385     then
386     echo " Removing stale libpthread libraries ..."
387     for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
388     do
389     if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
390     then
391     rm -f ${file}
392     fi
393     done
394    
395     #rm -f /lib/${OLD_PTHREAD}
396    
397     ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
398     fi
399    
400     if [ -x /usr/sbin/iconvconfig ]
401     then
402     # generate fastloading iconv module configuration file.
403     echo " Generate iconv module config ..."
404     /usr/sbin/iconvconfig --prefix=${MROOT}/
405     fi
406    
407     # not working with busybox
408     if ! need_busybox_support /sbin/init
409     then
410     # reloading init
411     echo " Reloading init ..."
412     [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
413     fi
414    
415     # generating user def locales
416     echo " Generating user defined locales ..."
417     [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
418    
419     # now we must fix the mage db files
420     # to stop the annoying errors messages
421     fix_db_files
422     }