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