Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9114 - (show annotations) (download)
Tue Oct 11 08:49:29 2016 UTC (7 years, 6 months ago) by niro
File size: 16058 byte(s)
-linux-libc-headers-4.4.21, binutils-2.27, glibc-2.24, gcc-6.2.0 toolchain - stage2
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.24"
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-2016"
14
15 # we force headers to one specific version
16 SDEPEND="== sys-kernel/linux-libc-headers-4.4.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 )
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 # fix a test case that fails when built using gcc-5.x
103 sed -i '/tst-audit2-ENV/i CFLAGS-tst-audit2.c += -fno-builtin' elf/Makefile || die
104
105 # fixes an infinite loop while syscall.d creation
106 # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711
107 mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die
108 # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines)
109 sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die
110
111 # scripts/test-installation.pl sometime fails
112 #
113 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
114 # /usr/src/glibc-2.16.0.bld/
115 # 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>
116 # line 1
117 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
118
119 # binutils patch needs reconf
120 # autoconf --force || die
121
122 # fix permissions on some of the scripts
123 chmod u+x ${SRCDIR}/scripts/*.sh || die
124
125 install -d ${SRCDIR}/build || die
126 cd ${SRCDIR}/build
127
128 if [ ! -f /etc/ld.so.conf ]
129 then
130 touch /etc/ld.so.conf || die
131 fi
132 }
133
134 src_compile()
135 {
136 local myopts
137
138 # generic pathes
139 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
140 myopts+=" --with-headers=/usr/include"
141 # bugurl
142 myopts+=" --with-bugurl=http://bugs.magellan-linux.de/"
143 # disable profiling
144 myopts+=" --disable-profile"
145 # enable addons
146 myopts+=" --enable-add-ons"
147 # supported kernel-release
148 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
149 # disable cvs and gd support
150 myopts+=" --without-cvs --without-gd"
151 # enable bindnow
152 myopts+=" --enable-bind-now"
153 # enable obsolete rpc implementation
154 myopts+=" --enable-obsolete-rpc"
155 # enable lock elision
156 myopts+=" --enable-lock-elision"
157 # disable -werror
158 myopts+=" --disable-werror"
159 # enable multi-arch
160 myopts+=" --enable-multi-arch"
161 # enable stackguard randomization
162 myopts+=" --enable-stackguard-randomization"
163
164 # support multilib lib64 dir (x86_64 only)
165 if [[ ${ARCH} = x86_64 ]]
166 then
167 # first build a -m32 version
168 install -d ${SRCDIR}/build-m32
169 cd ${SRCDIR}/build-m32
170
171 # honor /usr move
172 echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build-m32/configparms || die
173 # make sure the -m32 libs goes really to /usr/lib
174 echo "slibdir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
175 echo "rtlddir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
176
177 CC="gcc -m32" CXX="g++ -m32" \
178 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
179 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
180 ../configure \
181 --build=${CHOST} \
182 --host=i686-pc-linux-gnu \
183 --libdir=/usr/lib \
184 --libexecdir=/usr/lib/glibc \
185 ${myopts} \
186 || die
187
188 make PARALLELMFLAGS="${MAKEOPTS}" || die
189 fi
190
191 cd ${SRCDIR}/build
192
193 # honor /usr move
194 echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build/configparms || die
195 # make sure the -m64 libs goes really to /lib64
196 echo "slibdir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
197 echo "rtlddir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
198
199 ../configure \
200 --build=${CHOST} \
201 --host=${CHOST} \
202 --libdir=/usr/$(mlibdir) \
203 --libexecdir=/usr/$(mlibdir)/glibc \
204 ${myopts} \
205 || die
206
207 make PARALLELMFLAGS="${MAKEOPTS}" || die
208 }
209
210 src_install_glibc()
211 {
212 if [[ ${ARCH} = x86_64 ]]
213 then
214 # install -m32 libs
215 cd ${SRCDIR}/build-m32
216 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
217 fi
218
219 cd ${SRCDIR}/build
220 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
221
222 # cleanup
223 # utf-16 is needed by wfica >= 12.1
224 zapmost ${BINDIR} usr/$(mlibdir)/\*.so \
225 usr/$(mlibdir)/\*.so.\* \
226 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/*.so usr/lib/*.so.*') \
227 usr/sbin/ldconfig \
228 usr/bin/iconv \
229 usr/bin/locale \
230 usr/bin/ldd \
231 usr/bin/getent \
232 usr/$(mlibdir)/gconv/CP1252.so \
233 usr/$(mlibdir)/gconv/IBM850.so \
234 usr/$(mlibdir)/gconv/ISO8859-1.so \
235 usr/$(mlibdir)/gconv/ISO8859-15.so \
236 usr/$(mlibdir)/gconv/UNICODE.so \
237 usr/$(mlibdir)/gconv/UTF-16.so \
238 usr/$(mlibdir)/gconv/gconv-modules \
239 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/CP1252.so') \
240 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/IBM850.so') \
241 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-1.so') \
242 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/ISO8859-15.so') \
243 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UNICODE.so') \
244 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/UTF-16.so') \
245 $([[ ${ARCH} = x86_64 ]] && echo 'usr/lib/gconv/gconv-modules') \
246 || die
247
248 # nsswitch configuration file
249 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
250
251 # base environment
252 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
253 if [[ ${ARCH} = x86_64 ]]
254 then
255 MCONFIG="/etc/env.d/00glibc"
256 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
257 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
258 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
259 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
260 fi
261
262 # strip all binaries
263 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
264
265 # strip all libraries
266 # want to be safe here; --strip-unneeded seems to cause pthread problems
267 # strip all but libpthread
268 install -d ${BUILDDIR}/thread-backup || die
269 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
270
271 # now strip
272 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug || die
273 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
274 # remove stale directory
275 rm -rf ${BUILDDIR}/thread-backup || die
276
277 # prepare glibc for installation; slackware method
278 minstalldir /incoming || die
279 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
280 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
281 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
282 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
283 }
284
285 src_install_glibc-dev()
286 {
287 if [[ ${ARCH} = x86_64 ]]
288 then
289 # install -m32 libs
290 cd ${SRCDIR}/build-m32
291 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
292 fi
293
294 cd ${SRCDIR}/build
295 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
296
297 # cleanup -> in glibc
298 rm ${BINDIR}/usr/$(mlibdir)/*.so || die
299 rm ${BINDIR}/usr/$(mlibdir)/*.so.* || die
300 rm ${BINDIR}/usr/$(mlibdir)/gconv/CP1252.so || die
301 rm ${BINDIR}/usr/$(mlibdir)/gconv/IBM850.so || die
302 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-1.so || die
303 rm ${BINDIR}/usr/$(mlibdir)/gconv/ISO8859-15.so || die
304 rm ${BINDIR}/usr/$(mlibdir)/gconv/UNICODE.so || die
305 rm ${BINDIR}/usr/$(mlibdir)/gconv/UTF-16.so || die
306 rm ${BINDIR}/usr/$(mlibdir)/gconv/gconv-modules || die
307 if [[ ${ARCH} = x86_64 ]]
308 then
309 rm ${BINDIR}/usr/lib/*.so || die
310 rm ${BINDIR}/usr/lib/*.so.* || die
311 rm ${BINDIR}/usr/lib/gconv/CP1252.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 }