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