Magellan Linux

Contents of /trunk/core/glibc/glibc-2.13-r7.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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