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