Magellan Linux

Contents of /smage/branches/alx-0_6_0/core/glibc/glibc-2.13.0-r4.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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