Magellan Linux

Contents of /smage/trunk/core/eglibc/eglibc-2.14.0_20110915-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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