Magellan Linux

Contents of /branches/R11-stable/core/glibc/glibc-2.18-r3.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19580 - (show annotations) (download)
Mon Oct 7 08:21:00 2013 UTC (10 years, 7 months ago) by niro
File size: 11878 byte(s)
-release branches/R11-stable
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.18"
5 PBUILD="r3"
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.11.1"
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}-2.17-syscalld-infinite-loop.patch
38 mirror://${PNAME}/${PNAME}-2.18-readdir_r-CVE-2013-4237.patch
39 mirror://${PNAME}/${PNAME}-2.18-malloc-corrupt-CVE-2013-4332.patch
40 mirror://${PNAME}/${PNAME}-2.18-strcoll-CVE-2012-4412+4424.patch
41 mirror://${PNAME}/${PNAME}-2.18-strstr-hackfix.patch
42 )
43
44 # sed line: on 2 digits add an zero: 2.7 -> 2.7.0
45 UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'"
46
47 # glibc don't like strong CFLAGS
48 export CFLAGS="${CFLAGS//-O?} -O2"
49 # glibc -> nptl thread don't like striping
50 msetfeature "!strip"
51
52 # hack to fix NPTL issues with xen, only required on 32bit arches
53 if [[ ${ARCH} = i*86 ]]
54 then
55 export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
56 fi
57
58 # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
59 # first filter -mtune and -march from flags
60 for flag in ${CFLAGS}
61 do
62 case ${flag} in
63 -mtune=*) continue ;;
64 -march=*) continue ;;
65 esac
66 newflags="${newflags} ${flag}"
67 done
68 export CFLAGS="${newflags}"
69
70 # than add our defaults for glibc
71 [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
72 export CFLAGS="${CFLAGS} -mtune=generic" # all arches
73 export CXXFLAGS="${CFLAGS}"
74
75 # use other linux-headers
76 [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
77
78 # kernel support
79 export ENABLE_KERNEL=2.6.32
80
81 src_prepare()
82 {
83 munpack ${SRCFILE} || die
84 cd ${SRCDIR}
85
86 # security fixes
87 mpatch ${PNAME}-2.18-readdir_r-CVE-2013-4237.patch || die
88 mpatch ${PNAME}-2.18-malloc-corrupt-CVE-2013-4332.patch || die
89 mpatch ${PNAME}-2.18-strcoll-CVE-2012-4412+4424.patch || die
90
91 # hack fix for strstr issues on x86
92 mpatch ${PNAME}-2.18-strstr-hackfix.patch || die
93
94 # fixes an infinite loop while syscall.d creation
95 # see: http://sourceware.org/bugzilla/show_bug.cgi?id=15711
96 mpatch ${PNAME}-2.17-syscalld-infinite-loop.patch || die
97 # use 1.0 second instead of 0.5 (required by arch i686 builds on 64bit machines)
98 sed -i 's:0.5 seconds ago:1.0 seconds ago:' ${SRCDIR}/Makerules || die
99
100 # scripts/test-installation.pl sometime fails
101 #
102 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
103 # /usr/src/glibc-2.16.0.bld/
104 # 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>
105 # line 1
106 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
107
108 # binutils patch needs reconf
109 # autoconf --force || die
110
111 # fix permissions on some of the scripts
112 chmod u+x ${SRCDIR}/scripts/*.sh || die
113
114 install -d ${SRCDIR}/build || die
115 cd ${SRCDIR}/build
116
117 if [ ! -f /etc/ld.so.conf ]
118 then
119 touch /etc/ld.so.conf || die
120 fi
121 }
122
123 src_compile()
124 {
125 local myopts
126
127 # generic pathes
128 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
129 # disable profiling
130 myopts+=" --disable-profile"
131 # enable addons
132 myopts+=" --enable-add-ons=nptl,libidn"
133 # enable tls
134 myopts+=" --with-tls --with-__thread"
135 # supported kernel-release
136 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
137 # disable cvs and gd support
138 myopts+=" --without-cvs --without-gd"
139 # enable bindnow
140 myopts+=" --enable-bind-now"
141 # enable obsolete rpc implementation
142 myopts+=" --enable-obsolete-rpc"
143 # enable lock elesion
144 myopts+=" --enable-lock-elision"
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 }