Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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