Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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