Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3998 - (show annotations) (download)
Tue Jul 31 11:55:46 2012 UTC (11 years, 10 months ago) by niro
File size: 14618 byte(s)
-keep ldd and fixed missing provide
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.16.0"
5 PBUILD="r2"
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 zapmost ${BINDIR} usr/$(mlibdir)/\*.so \
208 usr/$(mlibdir)/\*.so.\* \
209 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/*.so usr/lib/*.so.*') \
210 usr/sbin/ldconfig \
211 usr/bin/iconv \
212 usr/bin/locale \
213 usr/bin/ldd \
214 usr/$(mlibdir)/gconv/IBM850.so \
215 usr/$(mlibdir)/gconv/ISO8859-1.so \
216 usr/$(mlibdir)/gconv/ISO8859-15.so \
217 usr/$(mlibdir)/gconv/UNICODE.so \
218 usr/$(mlibdir)/gconv/gconv-modules \
219 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/IBM850.so') \
220 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \
221 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-15.so') \
222 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \
223 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
224 || die
225
226 # nsswitch configuration file
227 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
228
229 # base environment
230 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
231 if [[ ${ARCH} = x86_64 ]]
232 then
233 MCONFIG="/etc/env.d/00glibc"
234 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
235 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
236 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
237 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
238 fi
239
240 # strip all binaries
241 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
242
243 # strip all libraries
244 # want to be safe here; --strip-unneeded seems to cause pthread problems
245 # strip all but libpthread
246 install -d ${BUILDDIR}/thread-backup || die
247 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
248
249 # now strip
250 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
251 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
252 # remove stale directory
253 rm -rf ${BUILDDIR}/thread-backup || die
254
255 # prepare glibc for installation; slackware method
256 minstalldir /incoming || die
257 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
258 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
259 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
260 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
261 }
262
263 src_install_glibc-dev()
264 {
265 if [[ ${ARCH} = x86_64 ]]
266 then
267 # install -m32 libs
268 cd ${SRCDIR}/build-m32
269 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
270 fi
271
272 cd ${SRCDIR}/build
273 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
274
275 # cleanup -> in glibc
276 rm ${BINDIR}/usr/$(mlibdir)/*.so || die
277 rm ${BINDIR}/usr/$(mlibdir)/*.so.* || die
278 rm ${BINDIR}/usr/$(mlibdir)/gconv/IBM850.so || die
279 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
280 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-15.so || die
281 rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
282 rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
283 if [[ ${ARCH} = x86_64 ]]
284 then
285 rm ${BINDIR}/usr/lib/*.so || die
286 rm ${BINDIR}/usr/lib/*.so.* || die
287 rm ${BINDIR}/usr/lib/gconv/IBM850.so || die
288 rm ${BINDIR}/usr/lib/gconv/ISO8859-1.so || die
289 rm ${BINDIR}/usr/lib/gconv/ISO8859-15.so || die
290 rm ${BINDIR}/usr/lib/gconv/UNICODE.so || die
291 rm ${BINDIR}/usr/lib/gconv/gconv-modules || die
292 fi
293 rm ${BINDIR}/usr/sbin/ldconfig || die
294 rm ${BINDIR}/usr/bin/iconv || die
295 rm ${BINDIR}/usr/bin/locale || die
296 rm ${BINDIR}/usr/bin/ldd || die
297
298 # do not generate the locales here, let it the user do with the locale-gen tool
299 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
300
301 # install locales list and generate tools
302 # generate locale.gen file from localedata/SUPPORTED file
303 minstalletc locale.gen-header locale.gen || die
304 sed \
305 -e 's:/: :g' \
306 -e 's:\\: :g' \
307 -e 's:SUPPORTED-LOCALES=::' \
308 -e 's:\ \ $::g' \
309 -e '/^#/d' \
310 -e 's:^:#:g' \
311 ${SRCDIR}/localedata/SUPPORTED \
312 >> ${BINDIR}/etc/locale.gen || die
313 minstalldir /usr/sbin || die
314 minstallexec -s locale-gen /usr/sbin || die
315
316 # nscd configuration file
317 minstalletc ${SRCDIR}/nscd/nscd.conf || die
318
319 # gai configuration file
320 minstalletc ${SRCDIR}/posix/gai.conf || die
321
322 # now in tzdata
323 # we use Berlin as default
324 # busybox compat
325 #local args
326 #if need_busybox_support /bin/cp
327 #then
328 # args="-f"
329 #else
330 # args="--remove-destination"
331 #fi
332 #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
333
334 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
335 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
336
337 # strip all binaries
338 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
339
340 # strip all libraries
341 # want to be safe here; --strip-unneeded seems to cause pthread problems
342 # strip all but libpthread
343 install -d ${BUILDDIR}/thread-backup || die
344 mv ${BINDIR}/usr/$(mlibdir)/libpthread* ${BUILDDIR}/thread-backup/ || die
345
346 # now strip
347 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
348 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
349 # remove stale directory
350 rm -rf ${BUILDDIR}/thread-backup || die
351 }
352
353 fix_db_files()
354 {
355 local i
356 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
357
358 for i in .files .symlinks .dirs
359 do
360 [ ! -f ${DB_ENTRY}/${i} ] && continue
361 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
362
363 echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
364
365 # /usr/lib/incoming -> empty line; sed2 removes all empty lines
366 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
367 # do not simply emtpy the line, but change it the the correct path,
368 # so no stale libs are around if the package gets updated!
369 sed -i \
370 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
371 -e "s:/usr/$(mlibdir)/incoming.*::g" \
372 -e '/^$/d' ${DB_ENTRY}/${i}
373 done
374 }
375
376 preinstall_glibc()
377 {
378 add_conf_prot_mask /etc/env.d /etc/nsswitch.conf
379 }
380
381 postinstall_glibc()
382 {
383 # first save the old libpthread.so.0;
384 # it will later used to determinate that there are no stale
385 # libpthreads that breaks ldconfig
386 local OLD_PTHREAD
387 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
388
389 # slackware install method
390
391 # we cannot easily install the glibc libs,
392 # because our tools for cp etc needs them to run
393
394 local file
395
396 echo " Switching to new glibc ..."
397 # swap libraries on the fly:
398 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
399 then
400 # first create copies of the incoming libraries:
401 cd /usr/$(mlibdir)/incoming
402 for file in $(find /usr/$(mlibdir)/incoming -type f)
403 do
404 if [ ! -r "../$(basename ${file}).incoming" ]
405 then
406 cp -a ${file} ../$(basename ${file}).incoming
407 fi
408 done
409
410 # then switch to them all at once:
411 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
412
413 # finally, rename them and clean up:
414 cd /usr/$(mlibdir)
415 for file in *.incoming
416 do
417 rm -f $(basename ${file} .incoming)
418 cp -a ${file} $(basename ${file} .incoming)
419 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
420 rm -f ${file}
421 done
422
423 # no ldconfig?
424 # good, it's safe to just jam it on home (and make links below):
425 else
426 (
427 cd ${MROOT}/usr/$(mlibdir)/incoming
428 for file in *
429 do
430 cp -a ${file} ..
431 done
432
433 local my_sym
434 local my_dest
435
436 # rebuild symlinks
437 echo " Recreating Symlinks:"
438 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
439 do
440 my_sym="$(readlink ${i})"
441 my_dest="$(basename ${i})"
442
443 echo " ${my_dest} -> ${my_dest}"
444
445 # assure to remove the old ones;
446 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
447 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
448
449 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
450 done
451 )
452 fi
453
454 # now, get rid of the temporary directory:
455 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
456
457 # remove stale nptl libpthread-2.?.?.so,
458 # fix only needed for glibc with linuxthreads;
459 # prevent reloc errors such as:
460 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
461
462 # get our new libpthread.so.0
463 local NEW_PTHREAD
464 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
465
466 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
467 then
468 echo " Removing stale libpthread libraries ..."
469 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
470 do
471 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
472 then
473 rm -f ${file}
474 fi
475 done
476
477 #rm -f /lib/${OLD_PTHREAD}
478
479 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
480 fi
481
482 # now we must fix the mage db files
483 # to stop the annoying errors messages
484 fix_db_files
485 }
486
487 postinstall_glibc-dev()
488 {
489 if [ -x /usr/sbin/iconvconfig ]
490 then
491 # generate fastloading iconv module configuration file.
492 echo " Generate iconv module config ..."
493 /usr/sbin/iconvconfig --prefix=${MROOT}/
494 fi
495
496 # not working with busybox
497 if ! need_busybox_support /sbin/init
498 then
499 # reloading init
500 echo " Reloading init ..."
501 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
502 fi
503
504 # generating user def locales
505 echo " Generating user defined locales ..."
506 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
507 }