Magellan Linux

Contents of /trunk/core/glibc/glibc-2.22-r4.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27229 - (show annotations) (download)
Mon Dec 7 15:16:35 2015 UTC (8 years, 5 months ago) by niro
File size: 12695 byte(s)
-linux-4.3.0, glibc-2.22, gcc-5.3.0 with c++11 abi enabled toolchain - stage2
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.22"
5 PBUILD="r4"
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-2015"
14
15 # we force headers to one specific version
16 SDEPEND="== sys-kernel/linux-libc-headers-4.3.0"
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.22-roundup.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 # serveral fixes:
84 # - fix a regression in the package that affects 32-bit architectures (fix position of jump label)
85 # - fix a potential security issue identified upstream (CVE-2015-1781)
86 mpatch ${PNAME}-2.22-roundup.patch || die
87
88 # fix a test case that fails when built using gcc-5.x
89 sed -i '/tst-audit2-ENV/i CFLAGS-tst-audit2.c += -fno-builtin' elf/Makefile || die
90
91 # fixes an infinite loop while syscall.d creation
92 # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711
93 mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die
94 # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines)
95 sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die
96
97 # scripts/test-installation.pl sometime fails
98 #
99 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
100 # /usr/src/glibc-2.16.0.bld/
101 # 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>
102 # line 1
103 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
104
105 # binutils patch needs reconf
106 # autoconf --force || die
107
108 # fix permissions on some of the scripts
109 chmod u+x ${SRCDIR}/scripts/*.sh || die
110
111 install -d ${SRCDIR}/build || die
112 cd ${SRCDIR}/build
113
114 if [ ! -f /etc/ld.so.conf ]
115 then
116 touch /etc/ld.so.conf || die
117 fi
118 }
119
120 src_compile()
121 {
122 local myopts
123
124 # generic pathes
125 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
126 myopts+=" --with-headers=/usr/include"
127 # bugurl
128 myopts+=" --with-bugurl=http://bugs.magellan-linux.de/"
129 # disable profiling
130 myopts+=" --disable-profile"
131 # enable addons
132 myopts+=" --enable-add-ons"
133 # supported kernel-release
134 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
135 # disable cvs and gd support
136 myopts+=" --without-cvs --without-gd"
137 # enable bindnow
138 myopts+=" --enable-bind-now"
139 # enable obsolete rpc implementation
140 myopts+=" --enable-obsolete-rpc"
141 # enable lock elesion
142 myopts+=" --enable-lock-elision"
143 # disable -werror
144 myopts+=" --disable-werror"
145 # enable multi-arch
146 myopts+=" --enable-multi-arch"
147 # enable stackguard randomization
148 myopts+=" --enable-stackguard-randomization"
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/configparms || die
161 echo "rtlddir=/usr/lib" >> ${SRCDIR}/build/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} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs 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
271 install -d ${BUILDDIR}/thread-backup || die
272 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
273
274 # now strip but only debuging symbols
275 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug || die
276 find ${BINDIR} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip --strip-debug || die
277 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
278 # remove stale directory
279 rm -rf ${BUILDDIR}/thread-backup || die
280
281 # prepare glibc for installation; slackware method
282 minstalldir /incoming || die
283 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
284 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
285 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
286 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(mlibdir) || die
287 }
288
289 fix_db_files()
290 {
291 local i
292 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
293
294 for i in .files .symlinks .dirs
295 do
296 [ ! -f ${DB_ENTRY}/${i} ] && continue
297 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
298
299 echo " fixing /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
300
301 # /usr/lib/incoming -> empty line; sed2 removes all empty lines
302 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
303 # do not simply emtpy the line, but change it the the correct path,
304 # so no stale libs are around if the package gets updated!
305 sed -i \
306 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
307 -e "s:/usr/$(mlibdir)/incoming.*::g" \
308 -e '/^$/d' ${DB_ENTRY}/${i}
309 done
310 }
311
312 postinstall()
313 {
314 # first save the old libpthread.so.0;
315 # it will later used to determinate that there are no stale
316 # libpthreads that breaks ldconfig
317 local OLD_PTHREAD
318 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
319
320 # slackware install method
321
322 # we cannot easily install the glibc libs,
323 # because our tools for cp etc needs them to run
324
325 local file
326
327 echo " Switching to new glibc ..."
328 # swap libraries on the fly:
329 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
330 then
331 # first create copies of the incoming libraries:
332 cd /usr/$(mlibdir)/incoming
333 for file in $(find /usr/$(mlibdir)/incoming -type f)
334 do
335 if [ ! -r "../$(basename ${file}).incoming" ]
336 then
337 cp -a ${file} ../$(basename ${file}).incoming
338 fi
339 done
340
341 # then switch to them all at once:
342 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
343
344 # finally, rename them and clean up:
345 cd /usr/$(mlibdir)
346 for file in *.incoming
347 do
348 rm -f $(basename ${file} .incoming)
349 cp -a ${file} $(basename ${file} .incoming)
350 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
351 rm -f ${file}
352 done
353
354 # no ldconfig?
355 # good, it's safe to just jam it on home (and make links below):
356 else
357 (
358 cd ${MROOT}/usr/$(mlibdir)/incoming
359 for file in *
360 do
361 cp -a ${file} ..
362 done
363
364 local my_sym
365 local my_dest
366
367 # rebuild symlinks
368 echo " Recreating Symlinks:"
369 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
370 do
371 my_sym="$(readlink ${i})"
372 my_dest="$(basename ${i})"
373
374 echo " ${my_dest} -> ${my_dest}"
375
376 # assure to remove the old ones;
377 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
378 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
379
380 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
381 done
382 )
383 fi
384
385 # now, get rid of the temporary directory:
386 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
387
388 # remove stale nptl libpthread-2.?.?.so,
389 # fix only needed for glibc with linuxthreads;
390 # prevent reloc errors such as:
391 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
392
393 # get our new libpthread.so.0
394 local NEW_PTHREAD
395 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
396
397 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
398 then
399 echo " Removing stale libpthread libraries ..."
400 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
401 do
402 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
403 then
404 rm -f ${file}
405 fi
406 done
407
408 #rm -f /lib/${OLD_PTHREAD}
409
410 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
411 fi
412
413 if [ -x /usr/sbin/iconvconfig ]
414 then
415 # generate fastloading iconv module configuration file.
416 echo " Generate iconv module config ..."
417 /usr/sbin/iconvconfig --prefix=${MROOT}/
418 fi
419
420 # not working with busybox
421 if ! need_busybox_support /sbin/init
422 then
423 # reloading init
424 echo " Reloading init ..."
425 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
426 fi
427
428 # generating user def locales
429 echo " Generating user defined locales ..."
430 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
431
432 # now we must fix the mage db files
433 # to stop the annoying errors messages
434 fix_db_files
435 }