Magellan Linux

Contents of /trunk/core/glibc/glibc-2.27-r9.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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