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