Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3623 - (show annotations) (download)
Thu Jul 12 08:19:05 2012 UTC (11 years, 10 months ago) by niro
File size: 14199 byte(s)
-several fixes
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.16.0"
5 PBUILD="r1"
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 }
93
94 src_prepare()
95 {
96 munpack ${SRCFILE} || die
97 cd ${SRCDIR}
98
99 # fix res_query assertion
100 # http://sourceware.org/bugzilla/show_bug.cgi?id=13013
101 mpatch ${PNAME}-2.15-fix-res_query-assert.patch || die
102
103 # revert commit c5a0802a - causes various hangs
104 # https://bugzilla.redhat.com/show_bug.cgi?id=769421
105 # Note: fedora may have actual fix (not submitted upstream yet...)
106 # http://pkgs.fedoraproject.org/gitweb/?p=glibc.git;a=blob_plain;f=glibc-rh552960-2.patch
107 mpatch ${PNAME}-${PVER}-revert-c5a0802a.patch || die
108
109 # scripts/test-installation.pl sometime fails
110 #
111 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
112 # /usr/src/glibc-2.16.0.bld/
113 # 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>
114 # line 1
115 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
116
117 # binutils patch needs reconf
118 # autoconf --force || die
119
120 # fix permissions on some of the scripts
121 chmod u+x ${SRCDIR}/scripts/*.sh || die
122
123 install -d ${SRCDIR}/build || die
124 cd ${SRCDIR}/build
125
126 if [ ! -f /etc/ld.so.conf ]
127 then
128 touch /etc/ld.so.conf || die
129 fi
130 }
131
132 src_compile()
133 {
134 local myopts
135
136 # generic pathes
137 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
138 # disable profiling
139 myopts+=" --disable-profile"
140 # enable addons
141 myopts+=" --enable-add-ons=nptl,libidn"
142 # enable tls
143 myopts+=" --with-tls --with-__thread"
144 # supported kernel-release
145 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
146 # disable cvs and gd support
147 myopts+=" --without-cvs --without-gd"
148 # enable bindnow
149 myopts+=" --enable-bind-now"
150 # enable obsolete rpc implementation
151 myopts+=" --enable-obsolete-rpc"
152
153 # support multilib lib64 dir (x86_64 only)
154 if [[ ${ARCH} = x86_64 ]]
155 then
156 # first build a -m32 version
157 install -d ${SRCDIR}/build-m32
158 cd ${SRCDIR}/build-m32
159
160 CC="gcc -m32" CXX="g++ -m32" \
161 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
162 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
163 ../configure \
164 --build=${CHOST} \
165 --host=i686-pc-linux-gnu \
166 --libdir=/usr/lib \
167 --libexecdir=/usr/lib/glibc \
168 ${myopts} \
169 || die
170
171 make PARALLELMFLAGS="${MAKEOPTS}" || die
172 fi
173
174 cd ${SRCDIR}/build
175
176 if [[ ${ARCH} = x86_64 ]]; then
177 # make sure the -m64 libs goes really to /lib64
178 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
179 fi
180
181 # kernel-2.6 with nptl needs this
182 ../configure \
183 --build=${CHOST} \
184 --host=${CHOST} \
185 --libdir=/usr/$(mlibdir) \
186 --libexecdir=/usr/$(mlibdir)/glibc \
187 ${myopts} \
188 || die
189
190 make PARALLELMFLAGS="${MAKEOPTS}" || die
191 }
192
193 src_install_glibc()
194 {
195 if [[ ${ARCH} = x86_64 ]]
196 then
197 # install -m32 libs
198 cd ${SRCDIR}/build-m32
199 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
200 fi
201
202 cd ${SRCDIR}/build
203 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
204
205 # cleanup
206 zapmost ${BINDIR} usr/$(mlibdir)/*.so \
207 usr/$(mlibdir)/*.so.* \
208 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/*.so usr/lib/*.so.*') \
209 usr/sbin/ldconfig \
210 usr/bin/iconv \
211 usr/bin/locale \
212 usr/$(mlibdir)/gconv/IBM850.so \
213 usr/$(mlibdir)/gconv/ISO8859-1.so \
214 usr/$(mlibdir)/gconv/ISO8859-15.so \
215 usr/$(mlibdir)/gconv/UNICODE.so \
216 usr/$(mlibdir)/gconv/gconv-modules \
217 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/IBM850.so') \
218 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \
219 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-15.so') \
220 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \
221 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
222 || die
223
224 # nsswitch configuration file
225 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
226
227 # base environment
228 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
229 if [[ ${ARCH} = x86_64 ]]
230 then
231 MCONFIG="/etc/env.d/00glibc"
232 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
233 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
234 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
235 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
236 fi
237
238 # strip all binaries
239 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
240
241 # strip all libraries
242 # want to be safe here; --strip-unneeded seems to cause pthread problems
243 # strip all but libpthread
244 install -d ${BUILDDIR}/thread-backup || die
245 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
246
247 # now strip
248 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
249 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
250 # remove stale directory
251 rm -rf ${BUILDDIR}/thread-backup || die
252
253 # prepare glibc for installation; slackware method
254 minstalldir /incoming || die
255 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
256 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
257 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
258 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
259 }
260
261 src_install_glibc-dev()
262 {
263 if [[ ${ARCH} = x86_64 ]]
264 then
265 # install -m32 libs
266 cd ${SRCDIR}/build-m32
267 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
268 fi
269
270 cd ${SRCDIR}/build
271 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
272
273 # cleanup -> in glibc
274 rm -r ${BINDIR}/usr/$(mlibdir)/*.so || die
275 rm ${BINDIR}/usr/$(mlibdir)/*.so.* || die
276 rm ${BINDIR}/usr/$(mlibdir)/gconv/IBM850.so || die
277 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
278 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-15.so || die
279 rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
280 rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
281 if [[ ${ARCH} = x86_64 ]]
282 then
283 rm -r ${BINDIR}/usr/lib/*.so || die
284 rm ${BINDIR}/usr/lib/*.so.* || die
285 rm ${BINDIR}/usr/lib/gconv/IBM850.so || die
286 rm ${BINDIR}/usr/lib/gconv/ISO8859-1.so || die
287 rm ${BINDIR}/usr/lib/gconv/ISO8859-15.so || die
288 rm ${BINDIR}/usr/lib/gconv/UNICODE.so || die
289 rm ${BINDIR}/usr/lib/gconv/gconv-modules || die
290 fi
291 rm ${BINDIR}/usr/sbin/ldconfig || die
292 rm ${BINDIR}/usr/bin/iconv || die
293 rm ${BINDIR}/usr/bin/locale || die
294
295 # do not generate the locales here, let it the user do with the locale-gen tool
296 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
297
298 # install locales list and generate tools
299 # generate locale.gen file from localedata/SUPPORTED file
300 minstalletc locale.gen-header locale.gen || die
301 sed \
302 -e 's:/: :g' \
303 -e 's:\\: :g' \
304 -e 's:SUPPORTED-LOCALES=::' \
305 -e 's:\ \ $::g' \
306 -e '/^#/d' \
307 -e 's:^:#:g' \
308 ${SRCDIR}/localedata/SUPPORTED \
309 >> ${BINDIR}/etc/locale.gen || die
310 minstalldir /usr/sbin || die
311 minstallexec -s locale-gen /usr/sbin || die
312
313 # nscd configuration file
314 minstalletc ${SRCDIR}/nscd/nscd.conf || die
315
316 # gai configuration file
317 minstalletc ${SRCDIR}/posix/gai.conf || die
318
319 # now in tzdata
320 # we use Berlin as default
321 # busybox compat
322 #local args
323 #if [[ $(readlink /bin/cp) = */busybox ]]
324 #then
325 # args="-f"
326 #else
327 # args="--remove-destination"
328 #fi
329 #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
330
331 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
332 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
333
334 # strip all binaries
335 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
336
337 # strip all libraries
338 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
339 }
340
341 fix_db_files()
342 {
343 local i
344 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
345
346 for i in .files .symlinks .dirs
347 do
348 [ ! -f ${DB_ENTRY}/${i} ] && continue
349 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
350
351 echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
352
353 # /usr/lib/incoming -> empty line; sed2 removes all empty lines
354 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
355 # do not simply emtpy the line, but change it the the correct path,
356 # so no stale libs are around if the package gets updated!
357 sed -i \
358 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
359 -e "s:/usr/$(mlibdir)/incoming.*::g" \
360 -e '/^$/d' ${DB_ENTRY}/${i}
361 done
362 }
363
364 preinstall_glibc()
365 {
366 add_conf_prot_mask /etc/env.d /etc/nsswitch.conf
367 }
368
369 postinstall_glibc()
370 {
371 # first save the old libpthread.so.0;
372 # it will later used to determinate that there are no stale
373 # libpthreads that breaks ldconfig
374 local OLD_PTHREAD
375 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
376
377 # slackware install method
378
379 # we cannot easily install the glibc libs,
380 # because our tools for cp etc needs them to run
381
382 local file
383
384 echo " Switching to new glibc ..."
385 # swap libraries on the fly:
386 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
387 then
388 # first create copies of the incoming libraries:
389 cd /usr/$(mlibdir)/incoming
390 for file in $(find /usr/$(mlibdir)/incoming -type f)
391 do
392 if [ ! -r "../$(basename ${file}).incoming" ]
393 then
394 cp -a ${file} ../$(basename ${file}).incoming
395 fi
396 done
397
398 # then switch to them all at once:
399 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
400
401 # finally, rename them and clean up:
402 cd /usr/$(mlibdir)
403 for file in *.incoming
404 do
405 rm -f $(basename ${file} .incoming)
406 cp -a ${file} $(basename ${file} .incoming)
407 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
408 rm -f ${file}
409 done
410
411 # no ldconfig?
412 # good, it's safe to just jam it on home (and make links below):
413 else
414 (
415 cd ${MROOT}/usr/$(mlibdir)/incoming
416 for file in *
417 do
418 cp -a ${file} ..
419 done
420
421 local my_sym
422 local my_dest
423
424 # rebuild symlinks
425 echo " Recreating Symlinks:"
426 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
427 do
428 my_sym="$(readlink ${i})"
429 my_dest="$(basename ${i})"
430
431 echo " ${my_dest} -> ${my_dest}"
432
433 # assure to remove the old ones;
434 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
435 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
436
437 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
438 done
439 )
440 fi
441
442 # now, get rid of the temporary directory:
443 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
444
445 # remove stale nptl libpthread-2.?.?.so,
446 # fix only needed for glibc with linuxthreads;
447 # prevent reloc errors such as:
448 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
449
450 # get our new libpthread.so.0
451 local NEW_PTHREAD
452 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
453
454 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
455 then
456 echo " Removing stale libpthread libraries ..."
457 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
458 do
459 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
460 then
461 rm -f ${file}
462 fi
463 done
464
465 #rm -f /lib/${OLD_PTHREAD}
466
467 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
468 fi
469
470 # now we must fix the mage db files
471 # to stop the annoying errors messages
472 fix_db_files
473 }
474
475 postinstall_glibc-dev()
476 {
477 if [ -x /usr/sbin/iconvconfig ]
478 then
479 # generate fastloading iconv module configuration file.
480 echo " Generate iconv module config ..."
481 /usr/sbin/iconvconfig --prefix=${MROOT}/
482 fi
483
484 # not working with busybox
485 if [[ $(basename $(readlink /sbin/init)) != busybox ]]
486 then
487 # reloading init
488 echo " Reloading init ..."
489 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
490 fi
491
492 # generating user def locales
493 echo " Generating user defined locales ..."
494 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
495 }