Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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