Magellan Linux

Contents of /branches/R11-stable/core/glibc/glibc-2.17-r7.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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