Magellan Linux

Contents of /smage/branches/alx-0_6_0/core/glibc/glibc-2.13.0-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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