Magellan Linux

Contents of /trunk/core/glibc/glibc-2.17-r2.smage2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16179 - (show annotations) (download)
Mon Jan 28 12:57:57 2013 UTC (11 years, 4 months ago) by niro
File size: 11483 byte(s)
-fixed whitepace
1 # $Id$
2
3 PNAME="glibc"
4 PVER="2.17"
5 PBUILD="r2"
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.1"
13
14 # we force headers to one specific version
15 SDEPEND="== sys-kernel/linux-libc-headers-3.7.5"
16 PROVIDE="virtual/glibc"
17
18 # functions to include in the mage file
19 SPECIAL_FUNCTIONS="fix_db_files"
20
21 SRCFILE="glibc-${PVER}.tar.xz"
22 SRCDIR="${BUILDDIR}/glibc-${PVER}"
23
24 ENVD_REV="1.2"
25
26 sminclude mtools
27
28 SRC_URI=(
29 ftp://sources.redhat.com/pub/glibc/releases/${SRCFILE}
30 ftp://sources.redhat.com/pub/glibc/snapshots/${SRCFILE}
31 gnu://${PNAME}/${SRCFILE}
32 mirror://${PNAME}/${SRCFILE}
33 mirror://${PNAME}/glibc.envd-${ENVD_REV}
34 mirror://${PNAME}/locale.gen-header
35 mirror://${PNAME}/locale-gen
36 mirror://${PNAME}/${PNAME}-${PVER}-add-new-netinet-tcp-defines-for-linux37.patch
37 mirror://${PNAME}/${PNAME}-${PVER}-sync-netinet-tcp-with-linux37.patch
38 mirror://${PNAME}/${PNAME}-${PVER}-add-msg-fastopen-sync-linux37.patch
39 )
40
41 # sed line: on 2 digits add an zero: 2.7 -> 2.7.0
42 UP2DATE="updatecmd_gnu ${PNAME/-nptl/} | sed 's/^\([0-9]\.[0-9]\$\)/\1.0/'"
43
44 # glibc don't like strong CFLAGS
45 export CFLAGS="${CFLAGS//-O?} -O2"
46 # glibc -> nptl thread don't like striping
47 msetfeature "!strip"
48 # gcc 3.0 - 3.3 needs this:
49 export CFLAGS="${CFLAGS} -finline-limit=2000"
50 export CXXFLAGS="${CFLAGS}"
51 export LDFLAGS="${LDFLAGS//-Wl,--relax}"
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 # scripts/test-installation.pl sometime fails
93 #
94 # CC="gcc" /usr/bin/perl scripts/test-installation.pl
95 # /usr/src/glibc-2.16.0.bld/
96 # 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>
97 # line 1
98 sed -i 's:CC="$(CC)" $(PERL) scripts/test-installation.pl $(common-objpfx)::' Makefile || die
99
100 # binutils patch needs reconf
101 # autoconf --force || die
102
103 # fix permissions on some of the scripts
104 chmod u+x ${SRCDIR}/scripts/*.sh || die
105
106 install -d ${SRCDIR}/build || die
107 cd ${SRCDIR}/build
108
109 if [ ! -f /etc/ld.so.conf ]
110 then
111 touch /etc/ld.so.conf || die
112 fi
113 }
114
115 src_compile()
116 {
117 local myopts
118
119 # generic pathes
120 myopts="--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info"
121 # disable profiling
122 myopts+=" --disable-profile"
123 # enable addons
124 myopts+=" --enable-add-ons=nptl,libidn"
125 # enable tls
126 myopts+=" --with-tls --with-__thread"
127 # supported kernel-release
128 myopts+=" --enable-kernel=${ENABLE_KERNEL}"
129 # disable cvs and gd support
130 myopts+=" --without-cvs --without-gd"
131 # enable bindnow
132 myopts+=" --enable-bind-now"
133 # enable obsolete rpc implementation
134 myopts+=" --enable-obsolete-rpc"
135
136 # support multilib lib64 dir (x86_64 only)
137 if [[ ${ARCH} = x86_64 ]]
138 then
139 # first build a -m32 version
140 install -d ${SRCDIR}/build-m32
141 cd ${SRCDIR}/build-m32
142
143 CC="gcc -m32" CXX="g++ -m32" \
144 CFLAGS="${CFLAGS//-march=${ARCH}} -march=i686" \
145 CXXFLAGS="${CXXFLAGS//-march=${ARCH}} -march=i686" \
146 ../configure \
147 --build=${CHOST} \
148 --host=i686-pc-linux-gnu \
149 --libdir=/usr/lib \
150 --libexecdir=/usr/lib/glibc \
151 ${myopts} \
152 || die
153
154 make PARALLELMFLAGS="${MAKEOPTS}" || die
155 fi
156
157 cd ${SRCDIR}/build
158
159 if [[ ${ARCH} = x86_64 ]]; then
160 # make sure the -m64 libs goes really to /lib64
161 echo "slibdir=/$(mlibdir)" >> ${SRCDIR}/build/configparms || die
162 fi
163
164 # kernel-2.6 with nptl needs this
165 ../configure \
166 --build=${CHOST} \
167 --host=${CHOST} \
168 --libdir=/usr/$(mlibdir) \
169 --libexecdir=/usr/$(mlibdir)/glibc \
170 ${myopts} \
171 || die
172
173 make PARALLELMFLAGS="${MAKEOPTS}" || die
174 }
175
176 src_install()
177 {
178 if [[ ${ARCH} = x86_64 ]]
179 then
180 # install -m32 libs
181 cd ${SRCDIR}/build-m32
182 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/lib rootsbindir=/usr/sbin install || die
183 fi
184
185 cd ${SRCDIR}/build
186 make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} slibdir=/usr/$(mlibdir) rootsbindir=/usr/sbin install || die
187
188 # do not generate the locales here, let it the user do with the locale-gen tool
189 # make PARALLELMFLAGS="${MAKEOPTS}" install_root=${BINDIR} localedata/install-locales || die
190
191 # install locales list and generate tools
192 # generate locale.gen file from localedata/SUPPORTED file
193 minstalletc locale.gen-header locale.gen || die
194 sed \
195 -e 's:/: :g' \
196 -e 's:\\: :g' \
197 -e 's:SUPPORTED-LOCALES=::' \
198 -e 's:\ \ $::g' \
199 -e '/^#/d' \
200 -e 's:^:#:g' \
201 ${SRCDIR}/localedata/SUPPORTED \
202 >> ${BINDIR}/etc/locale.gen || die
203 minstalldir /usr/sbin || die
204 minstallexec -s locale-gen /usr/sbin || die
205
206 # nsswitch configuration file
207 minstalletc ${SRCDIR}/nss/nsswitch.conf || die
208
209 # nscd configuration file
210 minstalletc ${SRCDIR}/nscd/nscd.conf || die
211
212 # gai configuration file
213 minstalletc ${SRCDIR}/posix/gai.conf || die
214
215 # now in tzdata
216 ## we use Berlin as default
217 ## busybox compat
218 #local args
219 #if need_busybox_support /bin/cp
220 #then
221 # args="-f"
222 #else
223 # args="--remove-destination"
224 #fi
225 #cp ${args} ${BINDIR}/usr/share/zoneinfo/Europe/Berlin ${BINDIR}/etc/localtime || die
226 [ -f ${BINDIR}/etc/ld.so.conf ] && { rm -f ${BINDIR}/etc/ld.so.conf || die; }
227 [ -e ${BINDIR}/etc/ld.so.cache ] && { rm -rf ${BINDIR}/etc/ld.so.cache || die; }
228
229 # base environment
230 minstallenv glibc.envd-${ENVD_REV} 00glibc || die
231 if [[ ${ARCH} = x86_64 ]]
232 then
233 MCONFIG="/etc/env.d/00glibc"
234 maddconfig "LDPATH=\"/$(mlibdir)\"" || die
235 maddconfig "LDPATH=\"/usr/$(mlibdir)\"" || die
236 maddconfig "LDPATH=\"/usr/local/$(mlibdir)\"" || die
237 maddconfig "LDPATH=\"/opt/$(mlibdir)\"" || die
238 fi
239
240 # strip all binaries
241 find ${BINDIR} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
242
243 # strip all libraries
244 # want to be safe here; --strip-unneeded seems to cause pthread problems
245 # strip all but libpthread
246 install -d ${BUILDDIR}/thread-backup || die
247 mv ${BINDIR}/usr/$(mlibdir)/lib{pthread,thread_db}* ${BUILDDIR}/thread-backup/ || die
248
249 # now strip
250 find ${BINDIR} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded || die
251 mv -f ${BUILDDIR}/thread-backup/* ${BINDIR}/usr/$(mlibdir)/ || die
252 # remove stale directory
253 rm -rf ${BUILDDIR}/thread-backup || die
254
255 # prepare glibc for installation; slackware method
256 minstalldir /incoming || die
257 mv ${BINDIR}/usr/$(mlibdir)/*.so ${BINDIR}/incoming || die
258 mv ${BINDIR}/usr/$(mlibdir)/*.so.* ${BINDIR}/incoming || die
259 mv ${BINDIR}/incoming ${BINDIR}/usr/$(mlibdir)/incoming || die
260 mv ${BINDIR}/usr/$(mlibdir)/incoming/libSegFault.so ${BINDIR}/usr/$(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 /usr/$(mlibdir)/incoming from db-entry '${i}' ..."
274
275 # /usr/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 \
280 -e "s:/usr/$(mlibdir)/incoming:/usr/$(mlibdir):g" \
281 -e "s:/usr/$(mlibdir)/incoming.*::g" \
282 -e '/^$/d' ${DB_ENTRY}/${i}
283 done
284 }
285
286 postinstall()
287 {
288 # first save the old libpthread.so.0;
289 # it will later used to determinate that there are no stale
290 # libpthreads that breaks ldconfig
291 local OLD_PTHREAD
292 OLD_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
293
294 # slackware install method
295
296 # we cannot easily install the glibc libs,
297 # because our tools for cp etc needs them to run
298
299 local file
300
301 echo " Switching to new glibc ..."
302 # swap libraries on the fly:
303 if [ -x /usr/sbin/ldconfig -a -d /usr/$(mlibdir)/incoming ] && [[ -z ${MROOT} ]]
304 then
305 # first create copies of the incoming libraries:
306 cd /usr/$(mlibdir)/incoming
307 for file in $(find /usr/$(mlibdir)/incoming -type f)
308 do
309 if [ ! -r "../$(basename ${file}).incoming" ]
310 then
311 cp -a ${file} ../$(basename ${file}).incoming
312 fi
313 done
314
315 # then switch to them all at once:
316 /usr/sbin/ldconfig -l /usr/$(mlibdir)/*.incoming 2> /dev/null
317
318 # finally, rename them and clean up:
319 cd /usr/$(mlibdir)
320 for file in *.incoming
321 do
322 rm -f $(basename ${file} .incoming)
323 cp -a ${file} $(basename ${file} .incoming)
324 /usr/sbin/ldconfig -l $(basename ${file} .incoming)
325 rm -f ${file}
326 done
327
328 # no ldconfig?
329 # good, it's safe to just jam it on home (and make links below):
330 else
331 (
332 cd ${MROOT}/usr/$(mlibdir)/incoming
333 for file in *
334 do
335 cp -a ${file} ..
336 done
337
338 local my_sym
339 local my_dest
340
341 # rebuild symlinks
342 echo " Recreating Symlinks:"
343 for i in $(find ${MROOT}/usr/$(mlibdir)/incoming -type l)
344 do
345 my_sym="$(readlink ${i})"
346 my_dest="$(basename ${i})"
347
348 echo " ${my_dest} -> ${my_dest}"
349
350 # assure to remove the old ones;
351 [ -L ${MROOT}/usr/$(mlibdir)/"${my_dest}" ] && \
352 rm ${MROOT}/usr/$(mlibdir)/"${my_dest}"
353
354 ln -snf "${my_sym}" ${MROOT}/usr/$(mlibdir)/"${my_dest}"
355 done
356 )
357 fi
358
359 # now, get rid of the temporary directory:
360 rm -rf ${MROOT}/usr/$(mlibdir)/incoming
361
362 # remove stale nptl libpthread-2.?.?.so,
363 # fix only needed for glibc with linuxthreads;
364 # prevent reloc errors such as:
365 # ls: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
366
367 # get our new libpthread.so.0
368 local NEW_PTHREAD
369 NEW_PTHREAD="$(readlink ${MROOT}/usr/$(mlibdir)/libpthread.so.0)"
370
371 if [ "${NEW_PTHREAD}" != "${OLD_PTHREAD}" ]
372 then
373 echo " Removing stale libpthread libraries ..."
374 for file in ${MROOT}/usr/$(mlibdir)/libpthread-*
375 do
376 if [ "$(basename ${file})" != "${NEW_PTHREAD}" ]
377 then
378 rm -f ${file}
379 fi
380 done
381
382 #rm -f /lib/${OLD_PTHREAD}
383
384 ln -snf ${NEW_PTHREAD} ${MROOT}/usr/$(mlibdir)/libpthread.so.0
385 fi
386
387 if [ -x /usr/sbin/iconvconfig ]
388 then
389 # generate fastloading iconv module configuration file.
390 echo " Generate iconv module config ..."
391 /usr/sbin/iconvconfig --prefix=${MROOT}/
392 fi
393
394 # not working with busybox
395 if ! need_busybox_support /sbin/init
396 then
397 # reloading init
398 echo " Reloading init ..."
399 [[ -z ${MROOT} ]] && /sbin/init U &> /dev/null
400 fi
401
402 # generating user def locales
403 echo " Generating user defined locales ..."
404 [[ -z ${MROOT} ]] && /usr/sbin/locale-gen
405
406 # now we must fix the mage db files
407 # to stop the annoying errors messages
408 fix_db_files
409 }