Magellan Linux

Contents of /branches/magellan-next/core/glibc-nptl/glibc-nptl-2.12.2-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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