Magellan Linux

Contents of /trunk/core/glibc/glibc-2.17-r6.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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