Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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