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