Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.16.0-r3.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4024 - (show annotations) (download)
Tue Aug 7 09:42:15 2012 UTC (11 years, 9 months ago) by niro
File size: 14852 byte(s)
-fixed a typo
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.16.0"
5 PBUILD="r3"
6
7 SPLIT_PACKAGES="glibc glibc-dev"
8
9 PCAT="sys-libs"
10
11 GLIBC_DEPEND=">= sys-apps/base-files-0.1"
12
13 # we force headers to one specific version
14 # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!)
15 SDEPEND="== sys-kernel/linux-libc-headers-3.4.4
16 ${GLIBC_DEPEND}"
17
18 # functions to include in the mage file
19 SPECIAL_FUNCTIONS="fix_db_files"
20
21 SRCFILE="glibc-${PVER}.tar.xz"
22 SRCDIR="${BUILDDIR}/glibc-${PVER}"
23
24 ENVD_REV="1.2"
25
26 sminclude mtools cleanutils 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://${PNAME}/${SRCFILE}
32 mirror://${PNAME}/${SRCFILE}
33 mirror://${PNAME}/glibc.envd-${ENVD_REV}
34 mirror://${PNAME}/locale.gen-header
35 mirror://${PNAME}/locale-gen
36 mirror://${PNAME}/${PNAME}-2.15-fix-res_query-assert.patch
37 mirror://${PNAME}/${PNAME}-${PVER}-revert-c5a0802a.patch
38 )
39
40 # sed line: on 2 digits add an zero: 2.7 -> 2.7.0
41 UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'"
42
43 # glibc don't like strong CFLAGS
44 export CFLAGS="${CFLAGS//-O?} -O2"
45 # glibc -> nptl thread don't like striping
46 msetfeature "!strip"
47 # gcc 3.0 - 3.3 needs this:
48 export CFLAGS="${CFLAGS} -finline-limit=2000"
49 export CXXFLAGS="${CFLAGS}"
50 export LDFLAGS="${LDFLAGS//-Wl,--relax}"
51
52 # hack to fix NPTL issues with xen, only required on 32bit arches
53 if [[ ${ARCH} = i*86 ]]
54 then
55 export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
56 fi
57
58 # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
59 # first filter -mtune and -march from flags
60 for flag in ${CFLAGS}
61 do
62 case ${flag} in
63 -mtune=*) continue ;;
64 -march=*) continue ;;
65 esac
66 newflags="${newflags} ${flag}"
67 done
68 export CFLAGS="${newflags}"
69
70 # than add our defaults for glibc
71 [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
72 export CFLAGS="${CFLAGS} -mtune=generic" # all arches
73 export CXXFLAGS="${CFLAGS}"
74
75 # use other linux-headers
76 [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
77
78 # kernel support
79 export ENABLE_KERNEL=2.6.32
80
81 split_info_glibc()
82 {
83 DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads."
84 DEPEND="${GLIBC_DEPEND}"
85 PROVIDE="virtual/glibc"
86 }
87
88 split_info_glibc-dev()
89 {
90 DESCRIPTION="Development files for sys-libs/glibc-${PVER}."
91 DEPEND="== sys-libs/glibc-${PVER}"
92 PROVIDE="virtual/glibc-dev"
93 }
94
95 src_prepare()
96 {
97 munpack ${SRCFILE} || die
98 cd ${SRCDIR}
99
100 # fix res_query assertion
101 # http://sourceware.org/bugzilla/show_bug.cgi?id=13013
102 mpatch ${PNAME}-2.15-fix-res_query-assert.patch || die
103
104 # revert commit c5a0802a - causes various hangs
105 # https://bugzilla.redhat.com/show_bug.cgi?id=769421
106 # Note: fedora may have actual fix (not submitted upstream yet...)
107 # http://pkgs.fedoraproject.org/gitweb/?p=glibc.git;a=blob_plain;f=glibc-rh552960-2.patch
108 mpatch ${PNAME}-${PVER}-revert-c5a0802a.patch || die
109
110 # scripts/test-installation.pl sometime fails
111 #
112 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
113 # /usr/src/glibc-2.16.0.bld/
114 # Unmatched ( in regex; marked by <-- HERE in m/$( <-- HERE if $(abi-32-ld-soname),$(abi-32-ld-soname),ld/ at scripts/test-installation.pl line 172, <LDD>
115 # line 1
116 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
117
118 # binutils patch needs reconf
119 # autoconf --force || 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 local myopts
136
137 # generic pathes
138 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
139 # disable profiling
140 myopts+=" --disable-profile"
141 # enable addons
142 myopts+=" --enable-add-ons=nptl,libidn"
143 # enable tls
144 myopts+=" --with-tls --with-__thread"
145 # supported kernel-release
146 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
147 # disable cvs and gd support
148 myopts+=" --without-cvs --without-gd"
149 # enable bindnow
150 myopts+=" --enable-bind-now"
151 # enable obsolete rpc implementation
152 myopts+=" --enable-obsolete-rpc"
153
154 # support multilib lib64 dir (x86_64 only)
155 if [[ ${ARCH} = x86_64 ]]
156 then
157 # first build a -m32 version
158 install -d ${SRCDIR}/build-m32
159 cd ${SRCDIR}/build-m32
160
161 CC="gcc -m32" CXX="g++ -m32" \
162 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
163 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
164 ../configure \
165 --build=${CHOST} \
166 --host=i686-pc-linux-gnu \
167 --libdir=/usr/lib \
168 --libexecdir=/usr/lib/glibc \
169 ${myopts} \
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 --libdir=/usr/$(mlibdir) \
187 --libexecdir=/usr/$(mlibdir)/glibc \
188 ${myopts} \
189 || die
190
191 make PARALLELMFLAGS="${MAKEOPTS}" || die
192 }
193
194 src_install_glibc()
195 {
196 if [[ ${ARCH} = x86_64 ]]
197 then
198 # install -m32 libs
199 cd ${SRCDIR}/build-m32
200 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
201 fi
202
203 cd ${SRCDIR}/build
204 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
205
206 # cleanup
207 # utf-16 is needed by wfica >= 12.1
208 zapmost ${BINDIR} usr/$(mlibdir)/\*.so \
209 usr/$(mlibdir)/\*.so.\* \
210 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/*.so usr/lib/*.so.*') \
211 usr/sbin/ldconfig \
212 usr/bin/iconv \
213 usr/bin/locale \
214 usr/bin/ldd \
215 usr/$(mlibdir)/gconv/IBM850.so \
216 usr/$(mlibdir)/gconv/ISO8859-1.so \
217 usr/$(mlibdir)/gconv/ISO8859-15.so \
218 usr/$(mlibdir)/gconv/UNICODE.so \
219 usr/$(mlibdir)/gconv/UTF-16.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/UTF-16.so') \
226 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
227 || die
228
229 # nsswitch configuration file
230 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
231
232 # base environment
233 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
234 if [[ ${ARCH} = x86_64 ]]
235 then
236 MCONFIG="/etc/env.d/00glibc"
237 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
238 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
239 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
240 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
241 fi
242
243 # strip all binaries
244 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
245
246 # strip all libraries
247 # want to be safe here; --strip-unneeded seems to cause pthread problems
248 # strip all but libpthread
249 install -d ${BUILDDIR}/thread-backup || die
250 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
251
252 # now strip
253 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
254 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
255 # remove stale directory
256 rm -rf ${BUILDDIR}/thread-backup || die
257
258 # prepare glibc for installation; slackware method
259 minstalldir /incoming || die
260 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
261 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
262 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
263 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
264 }
265
266 src_install_glibc-dev()
267 {
268 if [[ ${ARCH} = x86_64 ]]
269 then
270 # install -m32 libs
271 cd ${SRCDIR}/build-m32
272 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
273 fi
274
275 cd ${SRCDIR}/build
276 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
277
278 # cleanup -> in glibc
279 rm ${BINDIR}/usr/$(mlibdir)/*.so || die
280 rm ${BINDIR}/usr/$(mlibdir)/*.so.* || die
281 rm ${BINDIR}/usr/$(mlibdir)/gconv/IBM850.so || die
282 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
283 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-15.so || die
284 rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
285 rm ${BINDIR}/usr/$(mlibdir)/gconv/UTF-16.so || die
286 rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
287 if [[ ${ARCH} = x86_64 ]]
288 then
289 rm ${BINDIR}/usr/lib/*.so || 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/UTF-16.so || die
296 rm ${BINDIR}/usr/lib/gconv/gconv-modules || die
297 fi
298 rm ${BINDIR}/usr/sbin/ldconfig || die
299 rm ${BINDIR}/usr/bin/iconv || die
300 rm ${BINDIR}/usr/bin/locale || die
301 rm ${BINDIR}/usr/bin/ldd || die
302
303 # do not generate the locales here, let it the user do with the locale-gen tool
304 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
305
306 # install locales list and generate tools
307 # generate locale.gen file from localedata/SUPPORTED file
308 minstalletc locale.gen-header locale.gen || die
309 sed \
310 -e 's:/: :g' \
311 -e 's:\\: :g' \
312 -e 's:SUPPORTED-LOCALES=::' \
313 -e 's:\ \ $::g' \
314 -e '/^#/d' \
315 -e 's:^:#:g' \
316 ${SRCDIR}/localedata/SUPPORTED \
317 >> ${BINDIR}/etc/locale.gen || die
318 minstalldir /usr/sbin || die
319 minstallexec -s locale-gen /usr/sbin || die
320
321 # nscd configuration file
322 minstalletc ${SRCDIR}/nscd/nscd.conf || die
323
324 # gai configuration file
325 minstalletc ${SRCDIR}/posix/gai.conf || die
326
327 # now in tzdata
328 # we use Berlin as default
329 # busybox compat
330 #local args
331 #if need_busybox_support /bin/cp
332 #then
333 # args="-f"
334 #else
335 # args="--remove-destination"
336 #fi
337 #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
338
339 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
340 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
341
342 # strip all binaries
343 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
344
345 # strip all libraries
346 # want to be safe here; --strip-unneeded seems to cause pthread problems
347 # strip all but libpthread
348 install -d ${BUILDDIR}/thread-backup || die
349 mv ${BINDIR}/usr/$(mlibdir)/libpthread* ${BUILDDIR}/thread-backup/ || die
350
351 # now strip
352 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
353 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
354 # remove stale directory
355 rm -rf ${BUILDDIR}/thread-backup || die
356 }
357
358 fix_db_files()
359 {
360 local i
361 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
362
363 for i in .files .symlinks .dirs
364 do
365 [ ! -f ${DB_ENTRY}/${i} ] && continue
366 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
367
368 echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
369
370 # /usr/lib/incoming -> empty line; sed2 removes all empty lines
371 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
372 # do not simply emtpy the line, but change it the the correct path,
373 # so no stale libs are around if the package gets updated!
374 sed -i \
375 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
376 -e "s:/usr/$(mlibdir)/incoming.*::g" \
377 -e '/^$/d' ${DB_ENTRY}/${i}
378 done
379 }
380
381 preinstall_glibc()
382 {
383 add_conf_prot_mask /etc/env.d /etc/nsswitch.conf
384 }
385
386 postinstall_glibc()
387 {
388 # first save the old libpthread.so.0;
389 # it will later used to determinate that there are no stale
390 # libpthreads that breaks ldconfig
391 local OLD_PTHREAD
392 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
393
394 # slackware install method
395
396 # we cannot easily install the glibc libs,
397 # because our tools for cp etc needs them to run
398
399 local file
400
401 echo " Switching to new glibc ..."
402 # swap libraries on the fly:
403 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
404 then
405 # first create copies of the incoming libraries:
406 cd /usr/$(mlibdir)/incoming
407 for file in $(find /usr/$(mlibdir)/incoming -type f)
408 do
409 if [ ! -r "../$(basename ${file}).incoming" ]
410 then
411 cp -a ${file} ../$(basename ${file}).incoming
412 fi
413 done
414
415 # then switch to them all at once:
416 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
417
418 # finally, rename them and clean up:
419 cd /usr/$(mlibdir)
420 for file in *.incoming
421 do
422 rm -f $(basename ${file} .incoming)
423 cp -a ${file} $(basename ${file} .incoming)
424 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
425 rm -f ${file}
426 done
427
428 # no ldconfig?
429 # good, it's safe to just jam it on home (and make links below):
430 else
431 (
432 cd ${MROOT}/usr/$(mlibdir)/incoming
433 for file in *
434 do
435 cp -a ${file} ..
436 done
437
438 local my_sym
439 local my_dest
440
441 # rebuild symlinks
442 echo " Recreating Symlinks:"
443 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
444 do
445 my_sym="$(readlink ${i})"
446 my_dest="$(basename ${i})"
447
448 echo " ${my_dest} -> ${my_dest}"
449
450 # assure to remove the old ones;
451 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
452 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
453
454 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
455 done
456 )
457 fi
458
459 # now, get rid of the temporary directory:
460 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
461
462 # remove stale nptl libpthread-2.?.?.so,
463 # fix only needed for glibc with linuxthreads;
464 # prevent reloc errors such as:
465 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
466
467 # get our new libpthread.so.0
468 local NEW_PTHREAD
469 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
470
471 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
472 then
473 echo " Removing stale libpthread libraries ..."
474 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
475 do
476 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
477 then
478 rm -f ${file}
479 fi
480 done
481
482 #rm -f /lib/${OLD_PTHREAD}
483
484 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
485 fi
486
487 # now we must fix the mage db files
488 # to stop the annoying errors messages
489 fix_db_files
490 }
491
492 postinstall_glibc-dev()
493 {
494 if [ -x /usr/sbin/iconvconfig ]
495 then
496 # generate fastloading iconv module configuration file.
497 echo " Generate iconv module config ..."
498 /usr/sbin/iconvconfig --prefix=${MROOT}/
499 fi
500
501 # not working with busybox
502 if ! need_busybox_support /sbin/init
503 then
504 # reloading init
505 echo " Reloading init ..."
506 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
507 fi
508
509 # generating user def locales
510 echo " Generating user defined locales ..."
511 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
512 }