Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.14.0-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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