Magellan Linux

Contents of /trunk/core/glibc/glibc-2.18-r1.smage2

Parent Directory Parent Directory | Revision Log Revision Log


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