Magellan Linux

Contents of /branches/magellan-next/core/glibc-nptl/glibc-nptl-2.13-r3.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9210 - (show annotations) (download)
Tue Nov 8 21:43:32 2011 UTC (12 years, 6 months ago) by niro
File size: 12145 byte(s)
-added patch to fix dlclose issues
1 # $Id$
2
3 PNAME="glibc-nptl"
4 PVER="2.13"
5 PBUILD="r3"
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 # locale.gen CVS revision
27 LOCALEGEN_CVS_REV=1.3
28
29 sminclude mtools
30
31 SRC_URI=(
32 ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
33 ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
34 gnu://glibc/${SRCFILE}
35 mirror://glibc/${SRCFILE}
36 mirror://glibc/nsswitch.conf
37 mirror://glibc/nscd.conf
38 mirror://glibc/glibc.envd
39 mirror://glibc/locale-gen
40 mirror://glibc/locale.gen-${LOCALEGEN_CVS_REV}
41 mirror://glibc/glibc-2.12.1-bz4781.patch
42 mirror://glibc/glibc-2.12.1-i686.patch
43 mirror://glibc/glibc-2.12.1-static-shared-getpagesize.patch
44 mirror://glibc/glibc-2.12.2-ignore-origin-of-privileged-program.patch
45 mirror://glibc/glibc-2.13-prelink.patch
46 mirror://glibc/glibc-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 NOSTRIP=true
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 glibc-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 glibc-2.12.1-i686.patch || die
102
103 # fixes static link issues
104 # http://bugs.gentoo.org/332927
105 mpatch glibc-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 glibc-2.12.2-ignore-origin-of-privileged-program.patch || die
110
111 # fix prelinking
112 mpatch glibc-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 glibc-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 # support multilib lib64 dir (x86_64 only)
144 if [[ ${ARCH} = x86_64 ]]
145 then
146 # first build a -m32 version
147 install -d ${SRCDIR}/build-m32
148 cd ${SRCDIR}/build-m32
149
150 CC="gcc -m32" CXX="g++ -m32" \
151 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
152 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
153 ../configure \
154 --build=${CHOST} \
155 --host=i686-pc-linux-gnu \
156 --prefix=/usr \
157 --mandir=/usr/share/man \
158 --infodir=/usr/share/info \
159 --disable-profile \
160 --enable-add-ons=nptl,libidn \
161 --with-tls \
162 --with-__thread \
163 --enable-kernel=${ENABLE_KERNEL} \
164 --without-cvs \
165 --without-gd \
166 --libdir=/usr/lib \
167 --libexecdir=/usr/lib/glibc \
168 --with-headers=${ALT_HEADERS} \
169 --enable-bind-now \
170 || die
171
172 make PARALLELMFLAGS="${MAKEOPTS}" || die
173 fi
174
175 cd ${SRCDIR}/build
176
177 if [[ ${ARCH} = x86_64 ]]; then
178 # make sure the -m64 libs goes really to /lib64
179 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
180 fi
181
182 # kernel-2.6 with nptl needs this
183 ../configure \
184 --build=${CHOST} \
185 --host=${CHOST} \
186 --prefix=/usr \
187 --mandir=/usr/share/man \
188 --infodir=/usr/share/info \
189 --disable-profile \
190 --enable-add-ons=nptl,libidn \
191 --with-tls \
192 --with-__thread \
193 --enable-kernel=${ENABLE_KERNEL} \
194 --without-cvs \
195 --without-gd \
196 --libdir=/usr/$(mlibdir) \
197 --libexecdir=/usr/$(mlibdir)/glibc \
198 --with-headers=${ALT_HEADERS} \
199 --enable-bind-now \
200 || die
201
202 make PARALLELMFLAGS="${MAKEOPTS}" || die
203 }
204
205 src_install()
206 {
207 if [[ ${ARCH} = x86_64 ]]
208 then
209 # install -m32 libs
210 cd ${SRCDIR}/build-m32
211 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
212 fi
213
214 cd ${SRCDIR}/build
215 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
216
217 # do not generate the locales here, let it the user do with the locale-gen tool
218 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
219
220 # install locales list and generate tools
221 # to generate this listing see the glibc-2.5/localedata/SUPPORTED file
222 minstalletc locale.gen-${LOCALEGEN_CVS_REV} locale.gen || die
223 minstalldir /usr/sbin || die
224 minstallexec -s locale-gen /usr/sbin || die
225
226 # nsswitch configuration file
227 minstalletc nsswitch.conf || die
228
229 # nscd configuration file
230 minstalletc nscd.conf || die
231
232 # we use Berlin as default
233 cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
234 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
235 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
236
237 # base environment
238 minstallenv glibc.envd 00glibc || die
239 if [[ ${ARCH} = x86_64 ]]
240 then
241 echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
242 echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
243 fi
244
245 # move some libs and tools to proper locations
246 # will suppress some ldconfig errors too
247 mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die
248 mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die
249 mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die
250 mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die
251
252 # strip all binaries
253 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
254
255 # strip all libraries
256 # want to be safe here; --strip-unneeded seems to cause pthread problems
257 # strip all but libpthread
258 install -d ${BUILDDIR}/thread-backup || die
259 mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
260
261 # now strip
262 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
263 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die
264 # remove stale directory
265 rm -rf ${BUILDDIR}/thread-backup || die
266
267 # prepare glibc for installation; slackware method
268 minstalldir /incoming || die
269 mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die
270 mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die
271 mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die
272 }
273
274 fix_db_files()
275 {
276 local i
277 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
278
279 for i in .files .symlinks .dirs
280 do
281 [ ! -f ${DB_ENTRY}/${i} ] && continue
282 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
283
284 echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..."
285
286 # /lib/incoming -> empty line; sed2 removes all empty lines
287 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
288 # do not simply emtpy the line, but change it the the correct path,
289 # so no stale libs are around if the package gets updated!
290 sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \
291 -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
292 done
293 }
294
295 preinstall()
296 {
297 # remove libmemusage and libpcprofile as these libs now
298 # resides in /usr/lib and are symlinked to /lib
299 if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]]
300 then
301 rm ${MROOT}/$(mlibdir)/libmemusage.so
302 fi
303
304 if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]]
305 then
306 rm ${MROOT}/$(mlibdir)/libpcprofile.so
307 fi
308 }
309
310 postinstall()
311 {
312 # first save the old libpthread.so.0;
313 # it will later used to determinate that there are no stale
314 # libpthreads that breaks ldconfig
315 local OLD_PTHREAD
316 OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
317
318 # slackware install method
319
320 # we cannot easily install the glibc libs,
321 # because our tools for cp etc needs them to run
322
323 local file
324
325 echo " Switching to new glibc ..."
326 # swap libraries on the fly:
327 if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
328 then
329 # first create copies of the incoming libraries:
330 cd /$(mlibdir)/incoming
331 for file in $(find /$(mlibdir)/incoming -type f)
332 do
333 if [ ! -r "../$(basename ${file}).incoming" ]
334 then
335 cp -a ${file} ../$(basename ${file}).incoming
336 fi
337 done
338
339 # then switch to them all at once:
340 /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null
341
342 # finally, rename them and clean up:
343 cd /$(mlibdir)
344 for file in *.incoming
345 do
346 rm -f $(basename ${file} .incoming)
347 cp -a ${file} $(basename ${file} .incoming)
348 /sbin/ldconfig -l $(basename ${file} .incoming)
349 rm -f ${file}
350 done
351
352 # no ldconfig?
353 # good, it's safe to just jam it on home (and make links below):
354 else
355 (
356 cd ${MROOT}/$(mlibdir)/incoming
357 for file in *
358 do
359 cp -a ${file} ..
360 done
361
362 local my_sym
363 local my_dest
364
365 # rebuild symlinks
366 echo " Recreating Symlinks:"
367 for i in $(find ${MROOT}/$(mlibdir)/incoming -type l)
368 do
369 my_sym="$(readlink ${i})"
370 my_dest="$(basename ${i})"
371
372 echo " ${my_dest} -> ${my_dest}"
373
374 # assure to remove the old ones;
375 [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \
376 rm ${MROOT}/$(mlibdir)/"${my_dest}"
377
378 ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}"
379 done
380 )
381 fi
382
383 # now, get rid of the temporary directory:
384 rm -rf ${MROOT}/$(mlibdir)/incoming
385
386 # remove stale nptl libpthread-2.?.?.so,
387 # fix only needed for glibc with linuxthreads;
388 # prevent reloc errors such as:
389 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
390
391 # get our new libpthread.so.0
392 local NEW_PTHREAD
393 NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
394
395 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
396 then
397 echo " Removing stale libpthread libraries ..."
398 for file in ${MROOT}/$(mlibdir)/libpthread-*
399 do
400 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
401 then
402 rm -f ${file}
403 fi
404 done
405
406 #rm -f /lib/${OLD_PTHREAD}
407
408 ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0
409 fi
410
411 if [ -x /usr/sbin/iconvconfig ]
412 then
413 # generate fastloading iconv module configuration file.
414 echo " Generate iconv module config ..."
415 /usr/sbin/iconvconfig --prefix=${MROOT}/
416 fi
417
418 # reloading init
419 echo " Reloading init ..."
420 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
421
422 # generating user def locales
423 echo " Generating user defined locales ..."
424 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
425
426 # now we must fix the mage db files
427 # to stop the annoying errors messages
428 fix_db_files
429 }