Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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