Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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