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