Magellan Linux

Contents of /smage/trunk/core/glibc/glibc-2.17-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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