Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.18-r3.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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