Magellan Linux

Annotation of /branches/R11-stable/core/glibc/glibc-2.19-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21619 - (hide annotations) (download)
Mon Jul 21 09:22:55 2014 UTC (9 years, 10 months ago) by niro
File size: 11552 byte(s)
-release branches/R11-stable
1 niro 21250 # $Id$
2    
3     PNAME="glibc"
4     PVER="2.19"
5     PBUILD="r2"
6    
7     PCAT="sys-libs"
8    
9     DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads."
10     HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
11    
12     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.14.5"
17     PROVIDE="virtual/glibc"
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
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-xattr-compat-hack.patch
39     )
40    
41     # sed line: on 2 digits add an zero: 2.7 -> 2.7.0
42     UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'"
43    
44     # glibc don't like strong CFLAGS
45     export CFLAGS="${CFLAGS//-O?} -O2"
46     # glibc -> nptl thread don't like striping
47     msetfeature "!strip"
48    
49     # hack to fix NPTL issues with xen, only required on 32bit arches
50     if [[ ${ARCH} = i*86 ]]
51     then
52     export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
53     fi
54    
55     # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
56     # first filter -mtune and -march from flags
57     for flag in ${CFLAGS}
58     do
59     case ${flag} in
60     -mtune=*) continue ;;
61     -march=*) continue ;;
62     esac
63     newflags="${newflags} ${flag}"
64     done
65     export CFLAGS="${newflags}"
66    
67     # than add our defaults for glibc
68     [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
69     export CFLAGS="${CFLAGS} -mtune=generic" # all arches
70     export CXXFLAGS="${CFLAGS}"
71    
72     # use other linux-headers
73     [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
74    
75     # kernel support
76     export ENABLE_KERNEL=2.6.32
77    
78     src_prepare()
79     {
80     munpack ${SRCFILE} || die
81     cd ${SRCDIR}
82    
83     # xattr compat fix
84     mpatch ${PNAME}-2.18-xattr-compat-hack.patch || die
85    
86     # fixes an infinite loop while syscall.d creation
87     # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711
88     mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die
89     # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines)
90     sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die
91    
92     # scripts/test-installation.pl sometime fails
93     #
94     # CC="gcc" /usr/bin/perl scripts/test-installation.pl
95     # /usr/src/glibc-2.16.0.bld/
96     # 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>
97     # line 1
98     sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
99    
100     # fix build with make-4.0
101     sed -i 's:3.79\* | 3.\[89\]\*:& | 4.0:' configure || die
102    
103     # binutils patch needs reconf
104     # autoconf --force || die
105    
106     # fix permissions on some of the scripts
107     chmod u+x ${SRCDIR}/scripts/*.sh || die
108    
109     install -d ${SRCDIR}/build || die
110     cd ${SRCDIR}/build
111    
112     if [ ! -f /etc/ld.so.conf ]
113     then
114     touch /etc/ld.so.conf || die
115     fi
116     }
117    
118     src_compile()
119     {
120     local myopts
121    
122     # generic pathes
123     myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
124     # disable profiling
125     myopts+=" --disable-profile"
126     # enable addons
127     myopts+=" --enable-add-ons=nptl,libidn"
128     # enable tls
129     myopts+=" --with-tls --with-__thread"
130     # supported kernel-release
131     myopts+=" --enable-kernel=${ENABLE_KERNEL}"
132     # disable cvs and gd support
133     myopts+=" --without-cvs --without-gd"
134     # enable bindnow
135     myopts+=" --enable-bind-now"
136     # enable obsolete rpc implementation
137     myopts+=" --enable-obsolete-rpc"
138     # enable lock elesion
139     myopts+=" --enable-lock-elision"
140    
141     # support multilib lib64 dir (x86_64 only)
142     if [[ ${ARCH} = x86_64 ]]
143     then
144     # first build a -m32 version
145     install -d ${SRCDIR}/build-m32
146     cd ${SRCDIR}/build-m32
147    
148     CC="gcc -m32" CXX="g++ -m32" \
149     CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
150     CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
151     ../configure \
152     --build=${CHOST} \
153     --host=i686-pc-linux-gnu \
154     --libdir=/usr/lib \
155     --libexecdir=/usr/lib/glibc \
156     ${myopts} \
157     || die
158    
159     make PARALLELMFLAGS="${MAKEOPTS}" || die
160     fi
161    
162     cd ${SRCDIR}/build
163    
164     if [[ ${ARCH} = x86_64 ]]; then
165     # make sure the -m64 libs goes really to /lib64
166     echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
167     fi
168    
169     # kernel-2.6 with nptl needs this
170     ../configure \
171     --build=${CHOST} \
172     --host=${CHOST} \
173     --libdir=/usr/$(mlibdir) \
174     --libexecdir=/usr/$(mlibdir)/glibc \
175     ${myopts} \
176     || die
177    
178     make PARALLELMFLAGS="${MAKEOPTS}" || die
179     }
180    
181     src_install()
182     {
183     if [[ ${ARCH} = x86_64 ]]
184     then
185     # install -m32 libs
186     cd ${SRCDIR}/build-m32
187     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
188     fi
189    
190     cd ${SRCDIR}/build
191     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
192    
193     # do not generate the locales here, let it the user do with the locale-gen tool
194     # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
195    
196     # install locales list and generate tools
197     # generate locale.gen file from localedata/SUPPORTED file
198     minstalletc locale.gen-header locale.gen || die
199     sed \
200     -e 's:/: :g' \
201     -e 's:\\: :g' \
202     -e 's:SUPPORTED-LOCALES=::' \
203     -e 's:\ \ $::g' \
204     -e '/^#/d' \
205     -e 's:^:#:g' \
206     ${SRCDIR}/localedata/SUPPORTED \
207     >> ${BINDIR}/etc/locale.gen || die
208     minstalldir /usr/sbin || die
209     minstallexec -s locale-gen /usr/sbin || die
210    
211     # nsswitch configuration file
212     minstalletc ${SRCDIR}/nss/nsswitch.conf || die
213    
214     # nscd configuration file
215     minstalletc ${SRCDIR}/nscd/nscd.conf || die
216    
217     # gai configuration file
218     minstalletc ${SRCDIR}/posix/gai.conf || die
219    
220     # now in tzdata
221     ## we use Berlin as default
222     ## busybox compat
223     #local args
224     #if need_busybox_support /bin/cp
225     #then
226     # args="-f"
227     #else
228     # args="--remove-destination"
229     #fi
230     #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
231     [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
232     [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
233    
234     # base environment
235     minstallenv glibc.envd-${ENVD_REV} 00glibc || die
236     if [[ ${ARCH} = x86_64 ]]
237     then
238     MCONFIG="/etc/env.d/00glibc"
239     maddconfig "LDPATH=\"/$(mlibdir)\"" || die
240     maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
241     maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
242     maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
243     fi
244    
245     # strip all binaries
246     find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
247    
248     # strip all libraries
249     # want to be safe here; --strip-unneeded seems to cause pthread problems
250     # strip all but libpthread
251     install -d ${BUILDDIR}/thread-backup || die
252     mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
253    
254     # now strip
255     find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
256     mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
257     # remove stale directory
258     rm -rf ${BUILDDIR}/thread-backup || die
259    
260     # prepare glibc for installation; slackware method
261     minstalldir /incoming || die
262     mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
263     mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
264     mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
265     mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
266     }
267    
268     fix_db_files()
269     {
270     local i
271     local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
272    
273     for i in .files .symlinks .dirs
274     do
275     [ ! -f ${DB_ENTRY}/${i} ] && continue
276     [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
277    
278     echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
279    
280     # /usr/lib/incoming -> empty line; sed2 removes all empty lines
281     #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
282     # do not simply emtpy the line, but change it the the correct path,
283     # so no stale libs are around if the package gets updated!
284     sed -i \
285     -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
286     -e "s:/usr/$(mlibdir)/incoming.*::g" \
287     -e '/^$/d' ${DB_ENTRY}/${i}
288     done
289     }
290    
291     postinstall()
292     {
293     # first save the old libpthread.so.0;
294     # it will later used to determinate that there are no stale
295     # libpthreads that breaks ldconfig
296     local OLD_PTHREAD
297     OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
298    
299     # slackware install method
300    
301     # we cannot easily install the glibc libs,
302     # because our tools for cp etc needs them to run
303    
304     local file
305    
306     echo " Switching to new glibc ..."
307     # swap libraries on the fly:
308     if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
309     then
310     # first create copies of the incoming libraries:
311     cd /usr/$(mlibdir)/incoming
312     for file in $(find /usr/$(mlibdir)/incoming -type f)
313     do
314     if [ ! -r "../$(basename ${file}).incoming" ]
315     then
316     cp -a ${file} ../$(basename ${file}).incoming
317     fi
318     done
319    
320     # then switch to them all at once:
321     /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
322    
323     # finally, rename them and clean up:
324     cd /usr/$(mlibdir)
325     for file in *.incoming
326     do
327     rm -f $(basename ${file} .incoming)
328     cp -a ${file} $(basename ${file} .incoming)
329     /usr/sbin/ldconfig -l $(basename ${file} .incoming)
330     rm -f ${file}
331     done
332    
333     # no ldconfig?
334     # good, it's safe to just jam it on home (and make links below):
335     else
336     (
337     cd ${MROOT}/usr/$(mlibdir)/incoming
338     for file in *
339     do
340     cp -a ${file} ..
341     done
342    
343     local my_sym
344     local my_dest
345    
346     # rebuild symlinks
347     echo " Recreating Symlinks:"
348     for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
349     do
350     my_sym="$(readlink ${i})"
351     my_dest="$(basename ${i})"
352    
353     echo " ${my_dest} -> ${my_dest}"
354    
355     # assure to remove the old ones;
356     [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
357     rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
358    
359     ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
360     done
361     )
362     fi
363    
364     # now, get rid of the temporary directory:
365     rm -rf ${MROOT}/usr/$(mlibdir)/incoming
366    
367     # remove stale nptl libpthread-2.?.?.so,
368     # fix only needed for glibc with linuxthreads;
369     # prevent reloc errors such as:
370     # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
371    
372     # get our new libpthread.so.0
373     local NEW_PTHREAD
374     NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
375    
376     if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
377     then
378     echo " Removing stale libpthread libraries ..."
379     for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
380     do
381     if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
382     then
383     rm -f ${file}
384     fi
385     done
386    
387     #rm -f /lib/${OLD_PTHREAD}
388    
389     ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
390     fi
391    
392     if [ -x /usr/sbin/iconvconfig ]
393     then
394     # generate fastloading iconv module configuration file.
395     echo " Generate iconv module config ..."
396     /usr/sbin/iconvconfig --prefix=${MROOT}/
397     fi
398    
399     # not working with busybox
400     if ! need_busybox_support /sbin/init
401     then
402     # reloading init
403     echo " Reloading init ..."
404     [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
405     fi
406    
407     # generating user def locales
408     echo " Generating user defined locales ..."
409     [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
410    
411     # now we must fix the mage db files
412     # to stop the annoying errors messages
413     fix_db_files
414     }