Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.21-r6.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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