Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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