Magellan Linux

Contents of /branches/magellan-next/core/glibc-nptl/glibc-nptl-2.12.2-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7345 - (show annotations) (download)
Tue Jan 11 10:57:09 2011 UTC (13 years, 4 months ago) by niro
File size: 11883 byte(s)
-added a security fix for CVE-2010-3847
-set minimal supported kernel version to 2.6.27, which is the smallest version supported by upstream
1 # $Id: glibc-nptl-2.10.1-r1.smage2 3009 2009-10-06 19:20:40Z niro $
2
3 PNAME="glibc-nptl"
4 PVER="2.12.2"
5 PBUILD="r1"
6
7 PCATEGORIE="sys-libs"
8 STATE="unstable"
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-libs/libstdc++-4.5
14 >= sys-apps/base-files-0.1"
15
16 # we force headers to one specific version
17 # (for x86_64 2.6.12.0-r2 bi-arch headers are needed!)
18 SDEPEND="== sys-kernel/linux-libc-headers-2.6.35"
19 PROVIDE="virtual/glibc"
20
21 # functions to include in the mage file
22 SPECIAL_FUNCTIONS="fix_db_files"
23
24 SRCFILE="glibc-${PVER/.0/}.tar.bz2"
25 SRCDIR="${BUILDDIR}/glibc-${PVER/.0/}"
26
27 # locale.gen CVS revision
28 LOCALEGEN_CVS_REV=1.3
29
30 sminclude mtools
31
32 SRC_URI=(
33 ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
34 ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
35 gnu://glibc/${SRCFILE}
36 mirror://glibc/${SRCFILE}
37 mirror://glibc/nsswitch.conf
38 mirror://glibc/nscd.conf
39 mirror://glibc/glibc.envd
40 mirror://glibc/locale-gen
41 mirror://glibc/locale.gen-${LOCALEGEN_CVS_REV}
42 mirror://glibc/glibc-2.3.5-localedef_segfault-1.patch
43 mirror://glibc/glibc-2.12.1-bz4781.patch
44 mirror://glibc/glibc-2.12.1-i686.patch
45 mirror://glibc/glibc-2.12.1-static-shared-getpagesize.patch
46 mirror://glibc/glibc-2.12.1-but-I-am-an-i686.patch
47 mirror://glibc/glibc-2.12.2-ignore-origin-of-privileged-program.patch
48 )
49
50 # sed line: on 2 digits add an zero: 2.7 -> 2.7.0
51 UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'"
52
53 # glibc don't like strong CFLAGS
54 export CFLAGS="${CFLAGS//-O?} -O2"
55 # glibc -> nptl thread don't like striping
56 NOSTRIP=true
57 # gcc 3.0 - 3.3 needs this:
58 export CFLAGS="${CFLAGS} -finline-limit=2000"
59 export CXXFLAGS="${CFLAGS}"
60 export LDFLAGS="${LDFLAGS//-Wl,--relax}"
61
62 # hack to fix NPTL issues with xen, only required on 32bit arches
63 if [[ ${ARCH} = i*86 ]]
64 then
65 export CFLAGS="${CFLAGS} -mno-tls-direct-seg-refs"
66 fi
67
68 # glibc-2.6.1 and above needs march CFLAGS: -march=${ARCH} -mtune=generic
69 # first filter -mtune and -march from flags
70 for flag in ${CFLAGS}
71 do
72 case ${flag} in
73 -mtune=*) continue ;;
74 -march=*) continue ;;
75 esac
76 newflags="${newflags} ${flag}"
77 done
78 # than add our defaults for glibc
79 [[ ${ARCH} = i*86 ]] && export CFLAGS="${CFLAGS} -march=${ARCH}" # only i*86
80 export CFLAGS="${CFLAGS} -mtune=generic" # all arches
81 export CXXFLAGS="${CFLAGS}"
82
83 # use other linux-headers
84 [[ -z ${ALT_HEADERS} ]] && export ALT_HEADERS="/usr/include"
85
86 # kernel support
87 export ENABLE_KERNEL=2.6.27
88
89 src_prepare()
90 {
91 munpack ${SRCFILE} || die
92 cd ${SRCDIR}
93
94 # disable binutils -as-needed
95 sed -i 's/^have-as-needed.*/have-as-needed = no/' ${SRCDIR}/config.make.in || die
96
97 # fix segfault of localdef on arches beside x86-32
98 mpatch glibc-2.3.5-localedef_segfault-1.patch || die
99
100 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=4781
101 mpatch glibc-2.12.1-bz4781.patch || die
102
103 # http://sources.redhat.com/bugzilla/show_bug.cgi?id=411
104 # http://sourceware.org/ml/libc-alpha/2009-07/msg00072.html
105 mpatch glibc-2.12.1-i686.patch || die
106
107 # fixes static link issues
108 # http://bugs.gentoo.org/332927
109 mpatch glibc-2.12.1-static-shared-getpagesize.patch || die
110
111 # fix for excess linker optimization on i686, maybe fixed with binutils-2.21
112 mpatch glibc-2.12.1-but-I-am-an-i686.patch || die
113
114 # security fix, fixes CVE-2010-3847
115 # see: http://www.exploit-db.com/exploits/15274/
116 mpatch glibc-2.12.2-ignore-origin-of-privileged-program.patch || die
117
118 # fix permissions on some of the scripts
119 chmod u+x ${SRCDIR}/scripts/*.sh || die
120
121 install -d ${SRCDIR}/build || die
122 cd ${SRCDIR}/build
123
124 if [ ! -f /etc/ld.so.conf ]
125 then
126 touch /etc/ld.so.conf || die
127 fi
128 }
129
130 src_compile()
131 {
132 # support multilib lib64 dir (x86_64 only)
133 if [[ ${ARCH} = x86_64 ]]
134 then
135 # first build a -m32 version
136 install -d ${SRCDIR}/build-m32
137 cd ${SRCDIR}/build-m32
138
139 CC="gcc -m32" CXX="g++ -m32" \
140 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
141 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
142 ../configure \
143 --build=${CHOST} \
144 --host=i686-pc-linux-gnu \
145 --prefix=/usr \
146 --mandir=/usr/share/man \
147 --infodir=/usr/share/info \
148 --disable-profile \
149 --enable-add-ons=nptl,libidn \
150 --with-tls \
151 --with-__thread \
152 --enable-kernel=${ENABLE_KERNEL} \
153 --without-cvs \
154 --without-gd \
155 --libdir=/usr/lib \
156 --libexecdir=/usr/lib/glibc \
157 --with-headers=${ALT_HEADERS} \
158 --enable-bind-now \
159 || die
160
161 make PARALLELMFLAGS="${MAKEOPTS}" || die
162 fi
163
164 cd ${SRCDIR}/build
165
166 if [[ ${ARCH} = x86_64 ]]; then
167 # make sure the -m64 libs goes really to /lib64
168 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
169 fi
170
171 # kernel-2.6 with nptl needs this
172 ../configure \
173 --build=${CHOST} \
174 --host=${CHOST} \
175 --prefix=/usr \
176 --mandir=/usr/share/man \
177 --infodir=/usr/share/info \
178 --disable-profile \
179 --enable-add-ons=nptl,libidn \
180 --with-tls \
181 --with-__thread \
182 --enable-kernel=${ENABLE_KERNEL} \
183 --without-cvs \
184 --without-gd \
185 --libdir=/usr/$(mlibdir) \
186 --libexecdir=/usr/$(mlibdir)/glibc \
187 --with-headers=${ALT_HEADERS} \
188 --enable-bind-now \
189 || die
190
191 make PARALLELMFLAGS="${MAKEOPTS}" || die
192 }
193
194 src_install()
195 {
196 if [[ ${ARCH} = x86_64 ]]
197 then
198 # install -m32 libs
199 cd ${SRCDIR}/build-m32
200 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
201 fi
202
203 cd ${SRCDIR}/build
204 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} install || die
205
206 # do not generate the locales here, let it the user do with the locale-gen tool
207 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
208
209 # install locales list and generate tools
210 # to generate this listing see the glibc-2.5/localedata/SUPPORTED file
211 minstalletc locale.gen-${LOCALEGEN_CVS_REV} locale.gen || die
212 minstalldir /usr/sbin || die
213 minstallexec -s locale-gen /usr/sbin || die
214
215 # nsswitch configuration file
216 minstalletc nsswitch.conf || die
217
218 # nscd configuration file
219 minstalletc nscd.conf || die
220
221 # we use Berlin as default
222 cp --remove-destination ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
223 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
224 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
225
226 # base environment
227 minstallenv glibc.envd 00glibc || die
228 if [[ ${ARCH} = x86_64 ]]
229 then
230 echo "LDPATH=\"/usr/local/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
231 echo "LDPATH=\"/opt/$(mlibdir)\"" >> ${BINDIR}/etc/env.d/00glibc || die
232 fi
233
234 # move some libs and tools to proper locations
235 # will suppress some ldconfig errors too
236 mv ${BINDIR}/$(mlibdir)/libmemusage.so ${BINDIR}/usr/$(mlibdir) || die
237 mv ${BINDIR}/$(mlibdir)/libpcprofile.so ${BINDIR}/usr/$(mlibdir) || die
238 mlink ../usr/$(mlibdir)/libmemusage.so /$(mlibdir)/libmemusage.so || die
239 mlink ../usr/$(mlibdir)/libpcprofile.so /$(mlibdir)/libpcprofile.so || die
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}/$(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}/$(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}/$(mlibdir)/* ${BINDIR}/incoming || die
259 mv ${BINDIR}/incoming ${BINDIR}/$(mlibdir)/incoming || die
260 mv ${BINDIR}/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/$(mlibdir) || die
261 }
262
263 fix_db_files()
264 {
265 local i
266 local DB_ENTRY="${BUILDDIR}/${PKGNAME}"
267
268 for i in .files .symlinks .dirs
269 do
270 [ ! -f ${DB_ENTRY}/${i} ] && continue
271 [[ -z $(< ${DB_ENTRY}/${i}) ]] && continue
272
273 echo " fixing /$(mlibdir)/incoming from db-entry '${i}' ..."
274
275 # /lib/incoming -> empty line; sed2 removes all empty lines
276 #sed -i -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
277 # do not simply emtpy the line, but change it the the correct path,
278 # so no stale libs are around if the package gets updated!
279 sed -i -e "s:/$(mlibdir)/incoming:/$(mlibdir):g" \
280 -e "s:/$(mlibdir)/incoming.*::g" -e '/^$/d' ${DB_ENTRY}/${i}
281 done
282 }
283
284 preinstall()
285 {
286 # remove libmemusage and libpcprofile as these libs now
287 # resides in /usr/lib and are symlinked to /lib
288 if [[ -f ${MROOT}/$(mlibdir)/libmemusage.so ]]
289 then
290 rm ${MROOT}/$(mlibdir)/libmemusage.so
291 fi
292
293 if [[ -f ${MROOT}/$(mlibdir)/libpcprofile.so ]]
294 then
295 rm ${MROOT}/$(mlibdir)/libpcprofile.so
296 fi
297 }
298
299 postinstall()
300 {
301 # first save the old libpthread.so.0;
302 # it will later used to determinate that there are no stale
303 # libpthreads that breaks ldconfig
304 local OLD_PTHREAD
305 OLD_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
306
307 # slackware install method
308
309 # we cannot easily install the glibc libs,
310 # because our tools for cp etc needs them to run
311
312 local file
313
314 echo " Switching to new glibc ..."
315 # swap libraries on the fly:
316 if [ -x /sbin/ldconfig -a -d /$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
317 then
318 # first create copies of the incoming libraries:
319 cd /$(mlibdir)/incoming
320 for file in $(find /$(mlibdir)/incoming -type f)
321 do
322 if [ ! -r "../$(basename ${file}).incoming" ]
323 then
324 cp -a ${file} ../$(basename ${file}).incoming
325 fi
326 done
327
328 # then switch to them all at once:
329 /sbin/ldconfig -l /$(mlibdir)/*.incoming 2> /dev/null
330
331 # finally, rename them and clean up:
332 cd /$(mlibdir)
333 for file in *.incoming
334 do
335 rm -f $(basename ${file} .incoming)
336 cp -a ${file} $(basename ${file} .incoming)
337 /sbin/ldconfig -l $(basename ${file} .incoming)
338 rm -f ${file}
339 done
340
341 # no ldconfig?
342 # good, it's safe to just jam it on home (and make links below):
343 else
344 (
345 cd ${MROOT}/$(mlibdir)/incoming
346 for file in *
347 do
348 cp -a ${file} ..
349 done
350
351 local my_sym
352 local my_dest
353
354 # rebuild symlinks
355 echo " Recreating Symlinks:"
356 for i in $(find ${MROOT}/$(mlibdir)/incoming -type l)
357 do
358 my_sym="$(readlink ${i})"
359 my_dest="$(basename ${i})"
360
361 echo " ${my_dest} -> ${my_dest}"
362
363 # assure to remove the old ones;
364 [ -L ${MROOT}/$(mlibdir)/"${my_dest}" ] && \
365 rm ${MROOT}/$(mlibdir)/"${my_dest}"
366
367 ln -snf "${my_sym}" ${MROOT}/$(mlibdir)/"${my_dest}"
368 done
369 )
370 fi
371
372 # now, get rid of the temporary directory:
373 rm -rf ${MROOT}/$(mlibdir)/incoming
374
375 # remove stale nptl libpthread-2.?.?.so,
376 # fix only needed for glibc with linuxthreads;
377 # prevent reloc errors such as:
378 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
379
380 # get our new libpthread.so.0
381 local NEW_PTHREAD
382 NEW_PTHREAD="$(readlink ${MROOT}/$(mlibdir)/libpthread.so.0)"
383
384 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
385 then
386 echo " Removing stale libpthread libraries ..."
387 for file in ${MROOT}/$(mlibdir)/libpthread-*
388 do
389 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
390 then
391 rm -f ${file}
392 fi
393 done
394
395 #rm -f /lib/${OLD_PTHREAD}
396
397 ln -snf ${NEW_PTHREAD} ${MROOT}/$(mlibdir)/libpthread.so.0
398 fi
399
400 if [ -x /usr/sbin/iconvconfig ]
401 then
402 # generate fastloading iconv module configuration file.
403 echo " Generate iconv module config ..."
404 /usr/sbin/iconvconfig --prefix=${MROOT}/
405 fi
406
407 # reloading init
408 echo " Reloading init ..."
409 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
410
411 # generating user def locales
412 echo " Generating user defined locales ..."
413 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
414
415 # now we must fix the mage db files
416 # to stop the annoying errors messages
417 fix_db_files
418 }