Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.14.0-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2845 - (show annotations) (download)
Fri Sep 2 19:44:38 2011 UTC (12 years, 9 months ago) by niro
File size: 14609 byte(s)
-fixed post/preinstall handling, removed deprecated patches
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.14.0"
5 PBUILD="r1"
6
7 PCATEGORIE="sys-libs"
8
9 HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
10
11 # we force headers to one specific version
12 # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!)
13 SDEPEND="== sys-kernel/linux-libc-headers-3.0.0
14 >= sys-libs/libstdc++-4.6
15 >= sys-apps/base-files-0.1"
16
17 # functions to include in the mage file
18 SPECIAL_FUNCTIONS="fix_db_files"
19
20 SRCFILE="glibc-${PVER/.0/}.tar.bz2"
21 SRCDIR="${BUILDDIR}/glibc-${PVER/.0/}"
22
23 # locale.gen CVS revision
24 LOCALEGEN_CVS_REV=1.3
25
26 sminclude mtools alx
27
28 SRC_URI=(
29 ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
30 ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
31 gnu://glibc/${SRCFILE}
32 mirror://glibc/${SRCFILE}
33 mirror://glibc/nsswitch.conf
34 mirror://glibc/nscd.conf
35 mirror://glibc/glibc.envd
36 mirror://glibc/locale-gen
37 mirror://glibc/locale.gen-${LOCALEGEN_CVS_REV}
38 mirror://glibc/glibc-2.12.1-bz4781.patch
39 mirror://glibc/glibc-2.12.1-i686.patch
40 mirror://glibc/glibc-2.12.2-ignore-origin-of-privileged-program.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 NOSTRIP=true
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 # than add our defaults for glibc
72 [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
73 export CFLAGS="${CFLAGS} -mtune=generic" # all arches
74 export CXXFLAGS="${CFLAGS}"
75
76 # use other linux-headers
77 [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
78
79 # kernel support
80 export ENABLE_KERNEL=2.6.12
81
82 SPLIT_PACKAGES="glibc glibc-dev"
83
84 split_info_glibc()
85 {
86 DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads."
87 DEPEND=">= sys-libs/libstdc++-4.5
88 >= virtual/base-files"
89 PROVIDE="virtual/glibc"
90
91 _PNAME="${PNAME}"
92 }
93
94 split_info_glibc-dev()
95 {
96 DESCRIPTION="Development files for sys-libs/glibc-${PVER}."
97 DEPEND="== sys-libs/glibc-${PVER}"
98
99 _PNAME="${PNAME}"
100 }
101
102 src_prepare()
103 {
104 munpack ${SRCFILE} || die
105 cd ${SRCDIR}
106
107 # disable binutils -as-needed
108 sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die
109
110 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=4781
111 mpatch glibc-2.12.1-bz4781.patch || die
112
113 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=411
114 # http://sourceware.org/ml/libc-alpha/2009-07/msg00072.html
115 mpatch glibc-2.12.1-i686.patch || die
116
117 # security fix, fixes CVE-2010-3847
118 # see: http://www.exploit-db.com/exploits/15274/
119 mpatch glibc-2.12.2-ignore-origin-of-privileged-program.patch || die
120
121 # fix permissions on some of the scripts
122 chmod u+x ${SRCDIR}/scripts/*.sh || die
123
124 install -d ${SRCDIR}/build || die
125 cd ${SRCDIR}/build
126
127 if [ ! -f /etc/ld.so.conf ]
128 then
129 touch /etc/ld.so.conf || die
130 fi
131 }
132
133 src_compile()
134 {
135 # support multilib lib64 dir (x86_64 only)
136 if [[ ${ARCH} = x86_64 ]]
137 then
138 # first build a -m32 version
139 install -d ${SRCDIR}/build-m32
140 cd ${SRCDIR}/build-m32
141
142 CC="gcc -m32" CXX="g++ -m32" \
143 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
144 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
145 ../configure \
146 --build=${CHOST} \
147 --host=i686-pc-linux-gnu \
148 --prefix=/usr \
149 --mandir=/usr/share/man \
150 --infodir=/usr/share/info \
151 --disable-profile \
152 --enable-add-ons=nptl,libidn \
153 --with-tls \
154 --with-__thread \
155 --enable-kernel=${ENABLE_KERNEL} \
156 --without-cvs \
157 --without-gd \
158 --libdir=/usr/lib \
159 --libexecdir=/usr/lib/glibc \
160 --with-headers=${ALT_HEADERS} \
161 --enable-bind-now \
162 || die
163
164 make PARALLELMFLAGS="${MAKEOPTS}" || die
165 fi
166
167 cd ${SRCDIR}/build
168
169 if [[ ${ARCH} = x86_64 ]]; then
170 # make sure the -m64 libs goes really to /lib64
171 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
172 fi
173
174 # kernel-2.6 with nptl needs this
175 ../configure \
176 --build=${CHOST} \
177 --host=${CHOST} \
178 --prefix=/usr \
179 --mandir=/usr/share/man \
180 --infodir=/usr/share/info \
181 --disable-profile \
182 --enable-add-ons=nptl,libidn \
183 --with-tls \
184 --with-__thread \
185 --enable-kernel=${ENABLE_KERNEL} \
186 --without-cvs \
187 --without-gd \
188 --libdir=/usr/$(mlibdir) \
189 --libexecdir=/usr/$(mlibdir)/glibc \
190 --with-headers=${ALT_HEADERS} \
191 --enable-bind-now \
192 || die
193
194 make PARALLELMFLAGS="${MAKEOPTS}" || die
195 }
196
197 src_install_glibc()
198 {
199 if [[ ${ARCH} = x86_64 ]]
200 then
201 # install -m32 libs
202 cd ${SRCDIR}/build-m32
203 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
204 fi
205
206 cd ${SRCDIR}/build
207 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
208
209 # cleanup
210 zapmost ${BINDIR} $(mlibdir) \
211 usr/$(mlibdir)/*.so \
212 $([[ ${ARCH} = x86_64 ]] && echo 'lib usr/lib/*.so') \
213 sbin/ldconfig \
214 usr/bin/iconv \
215 usr/bin/locale \
216 usr/$(mlibdir)/gconv/IBM850.so \
217 usr/$(mlibdir)/gconv/ISO8859-1.so \
218 usr/$(mlibdir)/gconv/ISO8859-15.so \
219 usr/$(mlibdir)/gconv/UNICODE.so \
220 usr/$(mlibdir)/gconv/gconv-modules \
221 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/IBM850.so') \
222 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \
223 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-15.so') \
224 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \
225 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
226 || die
227
228 # base environment
229 minstallenv glibc.envd 00glibc || die
230 if [[ ${ARCH} = x86_64 ]]
231 then
232 echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
233 echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
234 fi
235
236 # nsswitch configuration file
237 minstalletc nsswitch.conf || die
238
239 # move some libs and tools to proper locations
240 # will suppress some ldconfig errors too
241 mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die
242 mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die
243 mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die
244 mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die
245
246 # strip all binaries
247 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
248
249 # strip all libraries
250 # want to be safe here; --strip-unneeded seems to cause pthread problems
251 # strip all but libpthread
252 install -d ${BUILDDIR}/thread-backup || die
253 mv ${BINDIR}/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
254 # now strip
255 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
256 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/$(mlibdir)/ || die
257 # remove stale directory
258 rm -rf ${BUILDDIR}/thread-backup || die
259
260 # prepare glibc for installation; slackware method
261 minstalldir /incoming || die
262 mv ${BINDIR}/$(mlibdir)/* ${BINDIR}/incoming || die
263 mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die
264 mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die
265 }
266
267 src_install_glibc-dev()
268 {
269 if [[ ${ARCH} = x86_64 ]]
270 then
271 # install -m32 libs
272 cd ${SRCDIR}/build-m32
273 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
274 fi
275
276 cd ${SRCDIR}/build
277 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
278
279 # cleanup -> in glibc
280 rm -r ${BINDIR}/$(mlibdir) || die
281 rm ${BINDIR}/usr/$(mlibdir)/*.so || die
282 rm ${BINDIR}/usr/$(mlibdir)/gconv/IBM850.so || die
283 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
284 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-15.so || die
285 rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
286 rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
287 if [[ ${ARCH} = x86_64 ]]
288 then
289 rm -r ${BINDIR}/lib || die
290 rm ${BINDIR}/usr/lib/*.so || die
291 rm ${BINDIR}/usr/lib/gconv/IBM850.so || die
292 rm ${BINDIR}/usr/lib/gconv/ISO8859-1.so || die
293 rm ${BINDIR}/usr/lib/gconv/ISO8859-15.so || die
294 rm ${BINDIR}/usr/lib/gconv/UNICODE.so || die
295 rm ${BINDIR}/usr/lib/gconv/gconv-modules || die
296 fi
297 rm ${BINDIR}/sbin/ldconfig || die
298 rm ${BINDIR}/usr/bin/iconv || die
299 rm ${BINDIR}/usr/bin/locale || die
300
301 # do not generate the locales here, let it the user do with the locale-gen tool
302 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
303
304 # install locales list and generate tools
305 # to generate this listing see the glibc-2.5/localedata/SUPPORTED file
306 minstalletc locale.gen-${LOCALEGEN_CVS_REV} locale.gen || die
307 minstalldir /usr/sbin || die
308 minstallexec -s locale-gen /usr/sbin || die
309
310 # nscd configuration file
311 minstalletc nscd.conf || die
312
313 # busybox compat
314 local args
315 if [[ $(readlink /bin/cp) = */busybox ]]
316 then
317 args="-f"
318 else
319 args="--remove-destination"
320 fi
321 # we use Berlin as default
322 cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
323
324 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
325 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
326
327 # strip all binaries
328 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
329
330 # strip all libraries
331 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
332 }
333
334 fix_db_files()
335 {
336 local i
337 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
338
339 for i in .files .symlinks .dirs
340 do
341 [ ! -f ${DB_ENTRY}/${i} ] && continue
342 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
343
344 echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..."
345
346 # /lib/incoming -> empty line; sed2 removes all empty lines
347 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
348 # do not simply emtpy the line, but change it the the correct path,
349 # so no stale libs are around if the package gets updated!
350 sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \
351 -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
352 done
353 }
354
355
356 preinstall_glibc()
357 {
358 add_conf_prot_mask /etc/env.d
359
360 # remove libmemusage and libpcprofile as these libs now
361 # resides in /usr/lib and are symlinked to /lib
362 if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]]
363 then
364 rm ${MROOT}/$(mlibdir)/libmemusage.so
365 fi
366
367 if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]]
368 then
369 rm ${MROOT}/$(mlibdir)/libpcprofile.so
370 fi
371 }
372
373 postinstall_glibc()
374 {
375 # first save the old libpthread.so.0;
376 # it will later used to determinate that there are no stale
377 # libpthreads that breaks ldconfig
378 local OLD_PTHREAD
379 OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
380
381 # slackware install method
382
383 # we cannot easily install the glibc libs,
384 # because our tools for cp etc needs them to run
385
386 local file
387
388 echo " Switching to new glibc ..."
389 # swap libraries on the fly:
390 if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
391 then
392 # first create copies of the incoming libraries:
393 cd /$(mlibdir)/incoming
394 for file in $(find /$(mlibdir)/incoming -type f)
395 do
396 if [ ! -r "../$(basename ${file}).incoming" ]
397 then
398 cp -a ${file} ../$(basename ${file}).incoming
399 fi
400 done
401
402 # then switch to them all at once:
403 /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null
404
405 # finally, rename them and clean up:
406 cd /$(mlibdir)
407 for file in *.incoming
408 do
409 rm -f $(basename ${file} .incoming)
410 cp -a ${file} $(basename ${file} .incoming)
411 /sbin/ldconfig -l $(basename ${file} .incoming)
412 rm -f ${file}
413 done
414
415 # no ldconfig?
416 # good, it's safe to just jam it on home (and make links below):
417 else
418 (
419 cd ${MROOT}/$(mlibdir)/incoming
420 for file in *
421 do
422 cp -a ${file} ..
423 done
424
425 local my_sym
426 local my_dest
427
428 # rebuild symlinks
429 echo " Recreating Symlinks:"
430 for i in $(find ${MROOT}/$(mlibdir)/incoming -type l)
431 do
432 my_sym="$(readlink ${i})"
433 my_dest="$(basename ${i})"
434
435 echo " ${my_dest} -> ${my_dest}"
436
437 # assure to remove the old ones;
438 [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \
439 rm ${MROOT}/$(mlibdir)/"${my_dest}"
440
441 ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}"
442 done
443 )
444 fi
445
446 # now, get rid of the temporary directory:
447 rm -rf ${MROOT}/$(mlibdir)/incoming
448
449 # remove stale nptl libpthread-2.?.?.so,
450 # fix only needed for glibc with linuxthreads;
451 # prevent reloc errors such as:
452 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
453
454 # get our new libpthread.so.0
455 local NEW_PTHREAD
456 NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
457
458 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
459 then
460 echo " Removing stale libpthread libraries ..."
461 for file in ${MROOT}/$(mlibdir)/libpthread-*
462 do
463 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
464 then
465 rm -f ${file}
466 fi
467 done
468
469 #rm -f /lib/${OLD_PTHREAD}
470
471 ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0
472 fi
473
474 if [ -x /usr/sbin/iconvconfig ]
475 then
476 # generate fastloading iconv module configuration file.
477 echo " Generate iconv module config ..."
478 /usr/sbin/iconvconfig --prefix=${MROOT}/
479 fi
480
481 # not working with busybox
482 if [[ $(basename $(readlink /sbin/init)) != busybox ]]
483 then
484 # reloading init
485 echo " Reloading init ..."
486 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
487 fi
488
489 if [[ -x /usr/sbin/locale-gen ]] && [[ -z ${MROOT} ]]
490 then
491 # generating user def locales
492 echo " Generating user defined locales ..."
493 /usr/sbin/locale-gen
494 fi
495
496 # now we must fix the mage db files
497 # to stop the annoying errors messages
498 fix_db_files
499
500 # run alx_postinstall
501 alx_postinstall
502 }
503
504 postinstall_glibc-dev()
505 {
506 if [ -x /usr/sbin/iconvconfig ]
507 then
508 # generate fastloading iconv module configuration file.
509 echo " Generate iconv module config ..."
510 /usr/sbin/iconvconfig --prefix=${MROOT}/
511 fi
512
513 # not working with busybox
514 if [[ $(basename $(readlink /sbin/init)) != busybox ]]
515 then
516 # reloading init
517 echo " Reloading init ..."
518 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
519 fi
520
521 if [[ -x /usr/sbin/locale-gen ]] && [[ -z ${MROOT} ]]
522 then
523 # generating user def locales
524 echo " Generating user defined locales ..."
525 /usr/sbin/locale-gen
526 fi
527
528 # run alx_postinstall
529 alx_postinstall
530 }