Magellan Linux

Annotation of /trunk/core/glibc/glibc-2.27-r12.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32040 - (hide annotations) (download)
Thu Mar 7 11:33:02 2019 UTC (5 years, 2 months ago) by niro
File size: 13318 byte(s)
auto added: ver bump to 2.27-r12
1 niro 32040 # $Id$
2    
3     PNAME="glibc"
4     PVER="2.27"
5     PBUILD="r12"
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-2018"
14    
15     # we force headers to one specific version
16     SDEPEND="== sys-kernel/linux-libc-headers-4.20.13"
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     )
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     # keep static libs to honor -static-pie or nptl/pthreads segfault may occur
47     msetfeature "!strip static"
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=3.2.0
77    
78     src_prepare()
79     {
80     munpack ${SRCFILE} || die
81     cd ${SRCDIR}
82    
83     # fix a test case that fails when built using gcc-5.x
84     sed -i '/tst-audit2-ENV/i CFLAGS-tst-audit2.c += -fno-builtin' elf/Makefile || 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     # binutils patch needs reconf
101     # autoconf --force || die
102    
103     # fix permissions on some of the scripts
104     chmod u+x ${SRCDIR}/scripts/*.sh || die
105    
106     install -d ${SRCDIR}/build || die
107     cd ${SRCDIR}/build
108    
109     if [ ! -f /etc/ld.so.conf ]
110     then
111     touch /etc/ld.so.conf || die
112     fi
113     }
114    
115     src_compile()
116     {
117     local myopts
118    
119     # generic pathes
120     myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
121     myopts+=" --with-headers=/usr/include"
122     # bugurl
123     myopts+=" --with-bugurl=http://bugs.magellan-linux.de/"
124     # disable profiling
125     myopts+=" --disable-profile"
126     # enable addons
127     myopts+=" --enable-add-ons"
128     # supported kernel-release
129     myopts+=" --enable-kernel=${ENABLE_KERNEL}"
130     # disable cvs and gd support
131     myopts+=" --without-cvs --without-gd"
132     # enable bindnow
133     # myopts+=" --enable-bind-now"
134     # enable lock elision
135     myopts+=" --enable-lock-elision"
136     # disable -werror
137     myopts+=" --disable-werror"
138     # enable multi-arch
139     myopts+=" --enable-multi-arch"
140     # enable stackguard randomization
141     myopts+=" --enable-stackguard-randomization"
142     # enable stack protector
143     myopts+=" --enable-stack-protector=strong"
144     # enable static pie
145     myopts+=" --enable-static-pie"
146    
147     # fortify_source not supported
148     export CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
149    
150     # support multilib lib64 dir (x86_64 only)
151     if [[ ${ARCH} = x86_64 ]]
152     then
153     # first build a -m32 version
154     install -d ${SRCDIR}/build-m32
155     cd ${SRCDIR}/build-m32
156    
157     # honor /usr move
158     echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build-m32/configparms || die
159     # make sure the -m32 libs goes really to /usr/lib
160     echo "slibdir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
161     echo "rtlddir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
162    
163     CC="gcc -m32" CXX="g++ -m32" \
164     CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
165     CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
166     ../configure \
167     --build=${CHOST} \
168     --host=i686-pc-linux-gnu \
169     --libdir=/usr/lib \
170     --libexecdir=/usr/lib/glibc \
171     ${myopts} \
172     || die
173    
174     make PARALLELMFLAGS="${MAKEOPTS}" || die
175     fi
176    
177     cd ${SRCDIR}/build
178    
179     # honor /usr move
180     echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build/configparms || die
181     # make sure the -m64 libs goes really to /lib64
182     echo "slibdir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
183     echo "rtlddir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
184    
185     ../configure \
186     --build=${CHOST} \
187     --host=${CHOST} \
188     --libdir=/usr/$(mlibdir) \
189     --libexecdir=/usr/$(mlibdir)/glibc \
190     ${myopts} \
191     || die
192    
193     make PARALLELMFLAGS="${MAKEOPTS}" || die
194     }
195    
196     src_install()
197     {
198     if [[ ${ARCH} = x86_64 ]]
199     then
200     # install -m32 libs
201     cd ${SRCDIR}/build-m32
202     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
203     fi
204    
205     cd ${SRCDIR}/build
206     make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
207    
208     # do not generate the locales here, let it the user do with the locale-gen tool
209     # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
210    
211     # install locales list and generate tools
212     # generate locale.gen file from localedata/SUPPORTED file
213     minstalletc locale.gen-header locale.gen || die
214     sed \
215     -e 's:/: :g' \
216     -e 's:\\: :g' \
217     -e 's:SUPPORTED-LOCALES=::' \
218     -e 's:\ \ $::g' \
219     -e '/^#/d' \
220     -e 's:^:#:g' \
221     ${SRCDIR}/localedata/SUPPORTED \
222     >> ${BINDIR}/etc/locale.gen || die
223     minstalldir /usr/sbin || die
224     minstallexec -s locale-gen /usr/sbin || die
225    
226     # nsswitch configuration file
227     minstalletc ${SRCDIR}/nss/nsswitch.conf || die
228    
229     # nscd configuration file
230     minstalletc ${SRCDIR}/nscd/nscd.conf || die
231     # systemd services, but do not include systemd.sminc to have a hard depend on systemd
232     minstalldir /usr/lib/systemd/system || die
233     minstallfile ${SRCDIR}/nscd/nscd.service /usr/lib/systemd/system || die
234     minstalldir /etc/tmpfiles.d || die
235     minstallfile ${SRCDIR}/nscd/nscd.tmpfiles /etc/tmpfiles.d/nscd.conf || die
236    
237     # gai configuration file
238     minstalletc ${SRCDIR}/posix/gai.conf || die
239    
240     # now in tzdata
241     ## we use Berlin as default
242     ## busybox compat
243     #local args
244     #if need_busybox_support /bin/cp
245     #then
246     # args="-f"
247     #else
248     # args="--remove-destination"
249     #fi
250     #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
251     [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
252     [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
253    
254     # base environment
255     minstallenv glibc.envd-${ENVD_REV} 00glibc || die
256     if [[ ${ARCH} = x86_64 ]]
257     then
258     MCONFIG="/etc/env.d/00glibc"
259     maddconfig "LDPATH=\"/$(mlibdir)\"" || die
260     maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
261     maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
262     maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
263     fi
264    
265     # strip all binaries
266     find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-unneeded || die
267    
268     # strip all libraries
269     # want to be safe here; --strip-unneeded seems to cause pthread problems
270     # strip all but libpthread, libc and ld
271     install -d ${BUILDDIR}/thread-backup/$(mlibdir) || die
272     mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db,c-}* ${BUILDDIR}/thread-backup/$(mlibdir)/ || die
273     mv ${BINDIR}/usr/$(mlibdir)/ld-* ${BUILDDIR}/thread-backup/$(mlibdir)/ || die
274     if [[ ${ARCH} = x86_64 ]]
275     then
276     install -d ${BUILDDIR}/thread-backup/lib || die
277     mv ${BINDIR}/usr/lib/lib{pthread,thread_db,c-}* ${BUILDDIR}/thread-backup/lib/ || die
278     mv ${BINDIR}/usr/lib/ld-* ${BUILDDIR}/thread-backup/lib/ || die
279     fi
280    
281     # now strip but only debuging symbols
282     find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die
283     find ${BINDIR} ! -type d | xargs --no-run-if-empty file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip --strip-debug || die
284     mv -f ${BUILDDIR}/thread-backup/$(mlibdir)/* ${BINDIR}/usr/$(mlibdir)/ || die
285     if [[ ${ARCH} = x86_64 ]]
286     then
287     mv -f ${BUILDDIR}/thread-backup/lib/* ${BINDIR}/usr/lib/ || die
288     fi
289     # remove stale directory
290     rm -rf ${BUILDDIR}/thread-backup || die
291    
292     # prepare glibc for installation; slackware method
293     minstalldir /incoming || die
294     mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
295     mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
296     mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
297     mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
298     }
299    
300     fix_db_files()
301     {
302     local i
303     local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
304    
305     for i in .files .symlinks .dirs
306     do
307     [ ! -f ${DB_ENTRY}/${i} ] && continue
308     [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
309    
310     echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
311    
312     # /usr/lib/incoming -> empty line; sed2 removes all empty lines
313     #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
314     # do not simply emtpy the line, but change it the the correct path,
315     # so no stale libs are around if the package gets updated!
316     sed -i \
317     -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
318     -e "s:/usr/$(mlibdir)/incoming.*::g" \
319     -e '/^$/d' ${DB_ENTRY}/${i}
320     done
321     }
322    
323     postinstall()
324     {
325     # first save the old libpthread.so.0;
326     # it will later used to determinate that there are no stale
327     # libpthreads that breaks ldconfig
328     local OLD_PTHREAD
329     OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
330    
331     # slackware install method
332    
333     # we cannot easily install the glibc libs,
334     # because our tools for cp etc needs them to run
335    
336     local file
337    
338     echo " Switching to new glibc ..."
339     # swap libraries on the fly:
340     if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
341     then
342     # first create copies of the incoming libraries:
343     cd /usr/$(mlibdir)/incoming
344     for file in $(find /usr/$(mlibdir)/incoming -type f)
345     do
346     if [ ! -r "../$(basename ${file}).incoming" ]
347     then
348     cp -a ${file} ../$(basename ${file}).incoming
349     fi
350     done
351    
352     # then switch to them all at once:
353     /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
354    
355     # finally, rename them and clean up:
356     cd /usr/$(mlibdir)
357     for file in *.incoming
358     do
359     rm -f $(basename ${file} .incoming)
360     cp -a ${file} $(basename ${file} .incoming)
361     /usr/sbin/ldconfig -l $(basename ${file} .incoming)
362     rm -f ${file}
363     done
364    
365     # no ldconfig?
366     # good, it's safe to just jam it on home (and make links below):
367     else
368     (
369     cd ${MROOT}/usr/$(mlibdir)/incoming
370     for file in *
371     do
372     cp -a ${file} ..
373     done
374    
375     local my_sym
376     local my_dest
377    
378     # rebuild symlinks
379     echo " Recreating Symlinks:"
380     for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
381     do
382     my_sym="$(readlink ${i})"
383     my_dest="$(basename ${i})"
384    
385     echo " ${my_dest} -> ${my_dest}"
386    
387     # assure to remove the old ones;
388     [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
389     rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
390    
391     ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
392     done
393     )
394     fi
395    
396     # now, get rid of the temporary directory:
397     rm -rf ${MROOT}/usr/$(mlibdir)/incoming
398    
399     # remove stale nptl libpthread-2.?.?.so,
400     # fix only needed for glibc with linuxthreads;
401     # prevent reloc errors such as:
402     # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
403    
404     # get our new libpthread.so.0
405     local NEW_PTHREAD
406     NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
407    
408     if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
409     then
410     echo " Removing stale libpthread libraries ..."
411     for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
412     do
413     if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
414     then
415     rm -f ${file}
416     fi
417     done
418    
419     #rm -f /lib/${OLD_PTHREAD}
420    
421     ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
422     fi
423    
424     if [ -x /usr/sbin/iconvconfig ]
425     then
426     # generate fastloading iconv module configuration file.
427     echo " Generate iconv module config ..."
428     /usr/sbin/iconvconfig --prefix=${MROOT}/
429     fi
430    
431     # not working with busybox
432     if ! need_busybox_support /sbin/telinit
433     then
434     # reloading init
435     echo " Reloading init ..."
436     [[ -z ${MROOT} ]] && /sbin/telinit U &> /dev/null
437     fi
438    
439     # generating user def locales
440     echo " Generating user defined locales ..."
441     [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
442    
443     # now we must fix the mage db files
444     # to stop the annoying errors messages
445     fix_db_files
446     }