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