Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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