Magellan Linux

Contents of /trunk/core/glibc/glibc-2.28-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31491 - (show annotations) (download)
Fri Aug 3 08:16:17 2018 UTC (5 years, 8 months ago) by niro
File size: 13016 byte(s)
-disabled atm, glibc-2.28 not working atm
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.28"
5 PBUILD="r1"
6
7 STATE="disabled"
8 PCAT="sys-libs"
9
10 DESCRIPTION="GNU libc6 (also called glibc2) C library with NPTL Threads."
11 HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
12
13 DEPEND=">= sys-apps/base-files-0.7
14 >= sys-libs/tzdata-2018"
15
16 # we force headers to one specific version
17 SDEPEND="== sys-kernel/linux-libc-headers-4.17.11"
18 PROVIDE="virtual/glibc"
19
20 # functions to include in the mage file
21 SPECIAL_FUNCTIONS="fix_db_files"
22
23 SRCFILE="glibc-${PVER}.tar.xz"
24 SRCDIR="${BUILDDIR}/glibc-${PVER}"
25
26 ENVD_REV="1.2"
27
28 sminclude mtools
29
30 SRC_URI=(
31 ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
32 ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
33 gnu://${PNAME}/${SRCFILE}
34 mirror://${PNAME}/${SRCFILE}
35 mirror://${PNAME}/glibc.envd-${ENVD_REV}
36 mirror://${PNAME}/locale.gen-header
37 mirror://${PNAME}/locale-gen
38 mirror://${PNAME}/${PNAME}-2.17-syscalld-infinite-loop.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=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 obsolete rpc implementation
135 myopts+=" --enable-obsolete-rpc"
136 # enable obsolete nsl implementation
137 myopts+=" --enable-obsolete-nsl"
138 # enable lock elision
139 myopts+=" --enable-lock-elision"
140 # disable -werror
141 myopts+=" --disable-werror"
142 # enable multi-arch
143 myopts+=" --enable-multi-arch"
144 # enable stackguard randomization
145 myopts+=" --enable-stackguard-randomization"
146 # enable stack protector
147 myopts+=" --enable-stack-protector=strong"
148 # enable static pie
149 myopts+=" --enable-static-pie"
150 # enable intel cet + branch tracking (IBT) and shadow stack (SHSTK)
151 myopts+=" --enable-cet"
152
153 # fortify_source not supported
154 export CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
155
156 # support multilib lib64 dir (x86_64 only)
157 if [[ ${ARCH} = x86_64 ]]
158 then
159 # first build a -m32 version
160 install -d ${SRCDIR}/build-m32
161 cd ${SRCDIR}/build-m32
162
163 # honor /usr move
164 echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build-m32/configparms || die
165 # make sure the -m32 libs goes really to /usr/lib
166 echo "slibdir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
167 echo "rtlddir=/usr/lib" >> ${SRCDIR}/build-m32/configparms || die
168
169 CC="gcc -m32" CXX="g++ -m32" \
170 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
171 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
172 ../configure \
173 --build=${CHOST} \
174 --host=i686-pc-linux-gnu \
175 --libdir=/usr/lib \
176 --libexecdir=/usr/lib/glibc \
177 ${myopts} \
178 || die
179
180 make PARALLELMFLAGS="${MAKEOPTS}" || die
181 fi
182
183 cd ${SRCDIR}/build
184
185 # honor /usr move
186 echo "rootsbindir=/usr/sbin" >> ${SRCDIR}/build/configparms || die
187 # make sure the -m64 libs goes really to /lib64
188 echo "slibdir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
189 echo "rtlddir=/usr/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
190
191 ../configure \
192 --build=${CHOST} \
193 --host=${CHOST} \
194 --libdir=/usr/$(mlibdir) \
195 --libexecdir=/usr/$(mlibdir)/glibc \
196 ${myopts} \
197 || die
198
199 make PARALLELMFLAGS="${MAKEOPTS}" || die
200 }
201
202 src_install()
203 {
204 if [[ ${ARCH} = x86_64 ]]
205 then
206 # install -m32 libs
207 cd ${SRCDIR}/build-m32
208 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
209 fi
210
211 cd ${SRCDIR}/build
212 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
213
214 # do not generate the locales here, let it the user do with the locale-gen tool
215 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
216
217 # install locales list and generate tools
218 # generate locale.gen file from localedata/SUPPORTED file
219 minstalletc locale.gen-header locale.gen || die
220 sed \
221 -e 's:/: :g' \
222 -e 's:\\: :g' \
223 -e 's:SUPPORTED-LOCALES=::' \
224 -e 's:\ \ $::g' \
225 -e '/^#/d' \
226 -e 's:^:#:g' \
227 ${SRCDIR}/localedata/SUPPORTED \
228 >> ${BINDIR}/etc/locale.gen || die
229 minstalldir /usr/sbin || die
230 minstallexec -s locale-gen /usr/sbin || die
231
232 # nsswitch configuration file
233 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
234
235 # nscd configuration file
236 minstalletc ${SRCDIR}/nscd/nscd.conf || die
237 # systemd services, but do not include systemd.sminc to have a hard depend on systemd
238 minstalldir /usr/lib/systemd/system || die
239 minstallfile ${SRCDIR}/nscd/nscd.service /usr/lib/systemd/system || die
240 minstalldir /etc/tmpfiles.d || die
241 minstallfile ${SRCDIR}/nscd/nscd.tmpfiles /etc/tmpfiles.d/nscd.conf || die
242
243 # gai configuration file
244 minstalletc ${SRCDIR}/posix/gai.conf || die
245
246 # now in tzdata
247 ## we use Berlin as default
248 ## busybox compat
249 #local args
250 #if need_busybox_support /bin/cp
251 #then
252 # args="-f"
253 #else
254 # args="--remove-destination"
255 #fi
256 #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
257 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
258 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
259
260 # base environment
261 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
262 if [[ ${ARCH} = x86_64 ]]
263 then
264 MCONFIG="/etc/env.d/00glibc"
265 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
266 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
267 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
268 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
269 fi
270
271 # strip all binaries
272 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
273
274 # strip all libraries
275 # want to be safe here; --strip-unneeded seems to cause pthread problems
276 # strip all but libpthread
277 install -d ${BUILDDIR}/thread-backup || die
278 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
279
280 # now strip but only debuging symbols
281 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
282 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
283 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
284 # remove stale directory
285 rm -rf ${BUILDDIR}/thread-backup || die
286
287 # prepare glibc for installation; slackware method
288 minstalldir /incoming || die
289 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
290 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
291 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
292 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
293 }
294
295 fix_db_files()
296 {
297 local i
298 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
299
300 for i in .files .symlinks .dirs
301 do
302 [ ! -f ${DB_ENTRY}/${i} ] && continue
303 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
304
305 echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
306
307 # /usr/lib/incoming -> empty line; sed2 removes all empty lines
308 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
309 # do not simply emtpy the line, but change it the the correct path,
310 # so no stale libs are around if the package gets updated!
311 sed -i \
312 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
313 -e "s:/usr/$(mlibdir)/incoming.*::g" \
314 -e '/^$/d' ${DB_ENTRY}/${i}
315 done
316 }
317
318 postinstall()
319 {
320 # first save the old libpthread.so.0;
321 # it will later used to determinate that there are no stale
322 # libpthreads that breaks ldconfig
323 local OLD_PTHREAD
324 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
325
326 # slackware install method
327
328 # we cannot easily install the glibc libs,
329 # because our tools for cp etc needs them to run
330
331 local file
332
333 echo " Switching to new glibc ..."
334 # swap libraries on the fly:
335 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
336 then
337 # first create copies of the incoming libraries:
338 cd /usr/$(mlibdir)/incoming
339 for file in $(find /usr/$(mlibdir)/incoming -type f)
340 do
341 if [ ! -r "../$(basename ${file}).incoming" ]
342 then
343 cp -a ${file} ../$(basename ${file}).incoming
344 fi
345 done
346
347 # then switch to them all at once:
348 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
349
350 # finally, rename them and clean up:
351 cd /usr/$(mlibdir)
352 for file in *.incoming
353 do
354 rm -f $(basename ${file} .incoming)
355 cp -a ${file} $(basename ${file} .incoming)
356 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
357 rm -f ${file}
358 done
359
360 # no ldconfig?
361 # good, it's safe to just jam it on home (and make links below):
362 else
363 (
364 cd ${MROOT}/usr/$(mlibdir)/incoming
365 for file in *
366 do
367 cp -a ${file} ..
368 done
369
370 local my_sym
371 local my_dest
372
373 # rebuild symlinks
374 echo " Recreating Symlinks:"
375 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
376 do
377 my_sym="$(readlink ${i})"
378 my_dest="$(basename ${i})"
379
380 echo " ${my_dest} -> ${my_dest}"
381
382 # assure to remove the old ones;
383 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
384 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
385
386 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
387 done
388 )
389 fi
390
391 # now, get rid of the temporary directory:
392 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
393
394 # remove stale nptl libpthread-2.?.?.so,
395 # fix only needed for glibc with linuxthreads;
396 # prevent reloc errors such as:
397 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
398
399 # get our new libpthread.so.0
400 local NEW_PTHREAD
401 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
402
403 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
404 then
405 echo " Removing stale libpthread libraries ..."
406 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
407 do
408 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
409 then
410 rm -f ${file}
411 fi
412 done
413
414 #rm -f /lib/${OLD_PTHREAD}
415
416 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
417 fi
418
419 if [ -x /usr/sbin/iconvconfig ]
420 then
421 # generate fastloading iconv module configuration file.
422 echo " Generate iconv module config ..."
423 /usr/sbin/iconvconfig --prefix=${MROOT}/
424 fi
425
426 # not working with busybox
427 if ! need_busybox_support /sbin/telinit
428 then
429 # reloading init
430 echo " Reloading init ..."
431 [[ -z ${MROOT} ]] && /sbin/telinit U &> /dev/null
432 fi
433
434 # generating user def locales
435 echo " Generating user defined locales ..."
436 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
437
438 # now we must fix the mage db files
439 # to stop the annoying errors messages
440 fix_db_files
441 }