source: npl/system/glibc/glibc.SlackBuild.orig @ 1a19ecd

perl-5.22
Last change on this file since 1a19ecd was 1a19ecd, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

upgrade glibc/gcc to gcc 5.4.0 and glibc 2.24

  • Property mode set to 100755
File size: 13.6 KB
Line 
1#!/bin/sh
2
3# Copyright 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016  Patrick J. Volkerding, Sebeka, MN, USA
4# All rights reserved.
5#
6# Redistribution and use of this script, with or without modification, is
7# permitted provided that the following conditions are met:
8#
9# 1. Redistributions of this script must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11#
12#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
13#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
15#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
18#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23## build glibc-$VERSION for Slackware
24
25VERSION=${VERSION:-$(echo glibc-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
26CHECKOUT=${CHECKOUT:-""}
27BUILD=${BUILD:-2}
28
29# I was considering disabling NSCD, but MoZes talked me out of it.  :)
30#DISABLE_NSCD=" --disable-nscd "
31
32# $ARCH may be preset, otherwise i586 compatibility with i686 binary
33# structuring is the Slackware default.
34if [ -z "$ARCH" ]; then
35  case "$( uname -m )" in
36    i?86) export ARCH=i586 ;;
37    arm*) export ARCH=arm ;;
38    # Unless $ARCH is already set, use uname -m for all other archs:
39       *) export ARCH=$( uname -m ) ;;
40  esac
41fi
42
43# I'll break this out as an option for fun  :-)
44case $ARCH  in
45  i386)
46    OPTIMIZ="-O3 -march=i386 -mcpu=i686"
47    LIBDIRSUFFIX=""
48    ;;
49  i486)
50    OPTIMIZ="-O3 -march=i486 -mtune=i686"
51    LIBDIRSUFFIX=""
52    ;;
53  i586)
54    OPTIMIZ="-O3 -march=i586 -mtune=i686"
55    LIBDIRSUFFIX=""
56    ;;
57  i686)
58    OPTIMIZ="-O3 -march=i686"
59    LIBDIRSUFFIX=""
60    ;;
61  athlon)
62    OPTIMIZ="-O3 -march=athlon"
63    LIBDIRSUFFIX=""
64    ;;
65  s390)
66    OPTIMIZ="-O3"
67    LIBDIRSUFFIX=""
68    ;;
69  x86_64)
70    OPTIMIZ="-O3 -fPIC"
71    LIBDIRSUFFIX="64"
72    ;;
73  *)
74    OPTIMIZ="-O3"
75    LIBDIRSUFFIX=""
76    ;;
77esac
78
79case $ARCH in
80  x86_64)
81    TARGET=${TARGET:-x86_64}
82    ;;
83  i586)
84    # This should be i586 for all 32-bit x86 arch:
85    TARGET=${TARGET:-i586}
86    ;;
87esac
88
89# Hand off the $ARCH variable to $SLACKWARE_ARCH to avoid confusing glibc:
90SLACKWARE_ARCH=$ARCH
91unset ARCH
92
93CVSVER=${VERSION}${CHECKOUT}
94
95# NOTE!!!  glibc needs to be built against the sanitized kernel headers,
96# which will be installed under /usr/include by the kernel-headers package.
97# Be sure the correct version of the headers package is installed BEFORE
98# building glibc!
99
100CWD=$(pwd)
101# Temporary build location.  This should not be a directory
102# path a non-root user could create later...
103TMP=${TMP:-/glibc-tmp-$(mcookie)}
104mkdir -p $TMP
105
106NUMJOBS=${NUMJOBS:-" -j7 "}
107
108# This function fixes a doinst.sh file for x86_64.
109# With thanks to Fred Emmott.
110fix_doinst() {
111  if [ "x$LIBDIRSUFFIX" = "x" ]; then
112    return;
113  fi;
114  # Fix "( cd usr/lib ;" occurrences
115  sed -i "s#lib ;#lib${LIBDIRSUFFIX} ;#" install/doinst.sh
116  # Fix "lib/" occurrences
117  sed -i "s#lib/#lib${LIBDIRSUFFIX}/#g" install/doinst.sh
118  # Fix "( cd lib" occurrences
119  sed -i "s#( cd lib\$#( cd lib${LIBDIRSUFFIX}#" install/doinst.sh
120
121  if [ "$SLACKWARE_ARCH" = "x86_64" ]; then
122    sed -i 's#ld-linux.so.2#ld-linux-x86-64.so.2#' install/doinst.sh
123  fi
124}
125
126# This is a patch function to put all glibc patches in the build script
127# up near the top.
128apply_patches() {
129  # Use old-style locale directories rather than a single (and strangely
130  # formatted) /usr/lib/locale/locale-archive file:
131  zcat $CWD/glibc.locale.no-archive.diff.gz | patch -p1 --verbose || exit 1
132  # The is_IS locale is causing a strange error about the "echn" command
133  # not existing.  This patch reverts is_IS to the version shipped in
134  # glibc-2.5:
135  zcat $CWD/is_IS.diff.gz | patch -p1 --verbose || exit 1
136  # Support ru_RU.CP1251 locale:
137  zcat $CWD/glibc.ru_RU.CP1251.diff.gz | patch -p1 --verbose || exit 1
138  # This reverts a patch that was made to glibc to fix "namespace leakage",
139  # which seems to cause some build failures (e.g. with conntrack):
140  zcat $CWD/glibc.revert.to.fix.build.breakages.diff.gz | patch -p1 -l --verbose || exit 1
141  # Make it harder for people to trick ldd into running code:
142  zcat $CWD/glibc.ldd.trace.through.dynamic.linker.diff.gz | patch -p1 --verbose || exit 1
143  # Add a C.UTF-8 locale:
144  zcat $CWD/glibc-c-utf8-locale.patch.gz | patch -p1 --verbose || exit 1
145}
146
147# This is going to be the initial $DESTDIR:
148export PKG=$TMP/package-glibc-incoming-tree
149PGLIBC=$TMP/package-glibc
150PSOLIBS=$TMP/package-glibc-solibs
151PI18N=$TMP/package-glibc-i18n
152PPROFILE=$TMP/package-glibc-profile
153PDEBUG=$TMP/package-glibc-debug
154
155# Empty these locations first:
156for dir in $PKG $PGLIBC $PSOLIBS $PZONE $PI18N $PPROFILE $PDEBUG ; do
157  if [ -d $dir ]; then
158    rm -rf $dir
159  fi
160  mkdir -p $dir
161done
162if [ -d $TMP/glibc-$VERSION ]; then
163  rm -rf $TMP/glibc-$VERSION
164fi
165
166# Create an incoming directory structure for glibc to be built into:
167mkdir -p $PKG/lib${LIBDIRSUFFIX}
168mkdir -p $PKG/sbin
169mkdir -p $PKG/usr/bin
170mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
171mkdir -p $PKG/usr/sbin
172mkdir -p $PKG/usr/include
173mkdir -p $PKG/usr/doc
174mkdir -p $PKG/usr/man
175mkdir -p $PKG/usr/share
176mkdir -p $PKG/var/db/nscd
177mkdir -p $PKG/var/run/nscd
178
179# Begin extract/compile:
180cd $TMP
181rm -rf glibc-$CVSVER
182tar xvf $CWD/glibc-$CVSVER.tar.xz \
183  || tar xvf $CWD/glibc-$CVSVER.tar.bz2 \
184  || tar xvf $CWD/glibc-$CVSVER.tar.gz
185cd glibc-$CVSVER
186
187chown -R root:root .
188find . -perm 666 -exec chmod 644 {} \;
189find . -perm 664 -exec chmod 644 {} \;
190find . -perm 600 -exec chmod 644 {} \;
191find . -perm 444 -exec chmod 644 {} \;
192find . -perm 400 -exec chmod 644 {} \;
193find . -perm 440 -exec chmod 644 {} \;
194find . -perm 777 -exec chmod 755 {} \;
195find . -perm 775 -exec chmod 755 {} \;
196find . -perm 511 -exec chmod 755 {} \;
197find . -perm 711 -exec chmod 755 {} \;
198find . -perm 555 -exec chmod 755 {} \;
199
200# Clean up leftover CVS directories:
201find . -type d -name CVS -exec rm -r {} \; 2> /dev/null
202
203# Apply patches; exit if any fail.
204apply_patches
205if [ ! $? = 0 ]; then
206  exit 1
207fi
208
209# Make build directory:
210mkdir build-glibc-$VERSION
211cd build-glibc-$VERSION || exit 1
212
213echo "BUILDING DAS NPTL GLIBC"
214CFLAGS="-g $OPTIMIZ" \
215../configure \
216  --prefix=/usr \
217  --libdir=/usr/lib${LIBDIRSUFFIX} \
218  --enable-kernel=2.6.32 \
219  --with-headers=/usr/include \
220  --enable-add-ons \
221  --enable-obsolete-rpc \
222  --enable-profile \
223  $DISABLE_NSCD \
224  --infodir=/usr/info \
225  --mandir=/usr/man \
226  --with-tls \
227  --with-__thread \
228  --without-cvs \
229  $TARGET-slackware-linux
230
231make $NUMJOBS || make || exit 1
232make install install_root=$PKG || exit 1
233make localedata/install-locales install_root=$PKG || exit 1
234
235# The prevailing standard seems to be putting unstripped libraries in
236# /usr/lib/debug/ and stripping the debugging symbols from all the other
237# libraries.
238mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/debug
239cp -a $PKG/lib${LIBDIRSUFFIX}/l*.so* $PKG/usr/lib${LIBDIRSUFFIX}/debug
240cp -a $PKG/usr/lib${LIBDIRSUFFIX}/*.a $PKG/usr/lib${LIBDIRSUFFIX}/debug
241# Don't need debug+profile:
242( cd $PKG/usr/lib${LIBDIRSUFFIX}/debug ; rm -f *_p.* )
243# NOTE:  Is there really a reason for the glibc-debug package?
244# If you're debugging glibc, you can also compile it, right?
245
246## COMMENTED OUT:  There's no reason for profile libs to include -g information.
247## Put back unstripped profiling libraries:
248#mv $PKG/usr/lib${LIBDIRSUFFIX}/debug/*_p.a $PKG/usr/lib${LIBDIRSUFFIX}
249# It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile.
250
251# I don't think "strip -g" causes the pthread problems.  It's --strip-unneeded that does.
252strip -g $PKG/lib${LIBDIRSUFFIX}/l*.so*
253strip -g $PKG/usr/lib${LIBDIRSUFFIX}/l*.so* || true
254strip -g $PKG/usr/lib${LIBDIRSUFFIX}/lib*.a || true
255
256# Remove the rquota.x and rquota.h include files, as they are provided by
257# the quota package:
258rm -f $PKG/usr/include/rpcsvc/rquota.{h,x}
259
260# Back to the sources dir to add some files/docs:
261cd $TMP/glibc-$CVSVER
262
263# We'll automatically install the config file for the Name Server Cache Daemon.
264# Perhaps this should also have some commented-out startup code in rc.inet2...
265mkdir -p $PKG/etc
266cat nscd/nscd.conf > $PKG/etc/nscd.conf.new
267
268# Install docs:
269( mkdir -p $PKG/usr/doc/glibc-$VERSION
270  cp -a \
271    BUGS CONFORMANCE COPYING* INSTALL LICENSES NAMESPACE \
272    NEWS PROJECTS README* \
273    $PKG/usr/doc/glibc-$VERSION
274)
275
276# Trim the NEWS file to omit ancient history:
277if [ -r NEWS ]; then
278  DOCSDIR=$(echo $PKG/usr/doc/glibc-$VERSION)
279  cat NEWS | head -n 1000 > $DOCSDIR/NEWS
280  touch -r NEWS $DOCSDIR/NEWS
281fi
282
283# OK, there are some very old Linux standards that say that any binaries in a /bin or
284# /sbin directory (and the directories themselves) should be group bin rather than
285# group root, unless a specific group is really needed for some reason.
286#
287# I can't find any mention of this in more recent standards docs, and always thought
288# that it was pretty cosmetic anyway (hey, if there's a reason -- fill me in!), so
289# it's possible that this ownership change won't be followed in the near future
290# (it's a PITA, and causes many bug reports when the perms change is occasionally
291# forgotten).
292#
293# But, it's hard to get me to break old habits, so we'll continue the tradition here:
294#
295# No, no we won't.  You know how we love to break traditions.
296
297# Strip most binaries:
298( cd $PKG
299  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
300  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null
301)
302
303# Fix info dir:
304rm $PKG/usr/info/dir
305gzip -9 $PKG/usr/info/*
306
307# This is junk
308rm $PKG/etc/ld.so.cache
309( cd $PKG
310  find . -name "*.orig" -exec rm {} \;
311)
312
313##################################
314# OK, time to make some packages #
315##################################
316
317# glibc-profile:
318cd $PPROFILE
319mkdir -p usr/lib${LIBDIRSUFFIX}
320# Might as well just grab these with 'mv' to simplify things later:
321mv $PKG/usr/lib${LIBDIRSUFFIX}/lib*_p.a usr/lib${LIBDIRSUFFIX}
322# Profile libs should be stripped.  Use the debug libs to debug...
323( cd usr/lib${LIBDIRSUFFIX} ; strip -g *.a )
324mkdir install
325cp -a $CWD/slack-desc.glibc-profile install/slack-desc
326makepkg -l y -c n $TMP/glibc-profile-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
327
328# THIS IS NO LONGER PACKAGED (or is it?  might be better to let it be made, and then ship it or not...)
329# glibc-debug:
330cd $PDEBUG
331mkdir -p usr/lib${LIBDIRSUFFIX}
332# Might as well just grab these with 'mv' to simplify things later:
333mv $PKG/usr/lib${LIBDIRSUFFIX}/debug usr/lib${LIBDIRSUFFIX}
334mkdir install
335cp -a $CWD/slack-desc.glibc-debug install/slack-desc
336makepkg -l y -c n $TMP/glibc-debug-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
337## INSTEAD, NUKE THESE LIBS
338#rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/debug
339
340# glibc-i18n:
341cd $PI18N
342mkdir -p usr/lib${LIBDIRSUFFIX}/locale
343mv $PKG/usr/lib${LIBDIRSUFFIX}/locale/* usr/lib${LIBDIRSUFFIX}/locale
344mkdir -p usr/share/{i18n,locale}
345mv $PKG/usr/share/i18n/* usr/share/i18n
346mv $PKG/usr/share/locale/* usr/share/locale
347# Leave copies of the C, POSIX, and en_US locales in the main glibc package:
348cp -a usr/lib${LIBDIRSUFFIX}/locale/{C,en_US}* $PKG/usr/lib${LIBDIRSUFFIX}/locale
349mkdir -p $PKG/usr/share/i18n/locales
350cp -a usr/share/i18n/locales/{C,POSIX,en_US} $PKG/usr/share/i18n/locales
351mkdir install
352cp -a $CWD/slack-desc.glibc-i18n install/slack-desc
353makepkg -l y -c n $TMP/glibc-i18n-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
354
355# glibc-solibs:
356cd $PSOLIBS
357mkdir -p etc/profile.d
358cp -a $CWD/profile.d/* etc/profile.d
359chown -R root:root etc
360chmod 755 etc/profile.d/*
361mkdir -p lib${LIBDIRSUFFIX}
362cp -a $PKG/lib${LIBDIRSUFFIX}/* lib${LIBDIRSUFFIX}
363( cd lib${LIBDIRSUFFIX}
364  mkdir incoming
365  mv *so* incoming
366  mv incoming/libSegFault.so .
367)
368mkdir -p usr
369cp -a $PKG/usr/bin usr
370mv usr/bin/ldd .
371rm usr/bin/*
372mv ldd usr/bin
373mkdir -p usr/lib${LIBDIRSUFFIX}
374# The gconv directory has a lot of stuff, but including it here will save some problems.
375# Seems standard elsewhere.
376cp -a $PKG/usr/lib${LIBDIRSUFFIX}/gconv usr/lib${LIBDIRSUFFIX}
377# Another manpage abandoned by GNU...
378#mkdir -p usr/man/man1
379#cp -a $PKG/usr/man/man1/ldd.1.gz usr/man/man1
380mkdir -p usr/libexec
381#cp -a $PKG/usr/libexec/pt_chown usr/libexec
382# Same usr.bin deal:
383cp -a $PKG/sbin .
384mv sbin/ldconfig .
385rm sbin/*
386mv ldconfig sbin
387mkdir install
388cp -a $CWD/slack-desc.glibc-solibs install/slack-desc
389cp -a $CWD/doinst.sh-glibc-solibs install/doinst.sh
390fix_doinst
391sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
392# Ditch links:
393find . -type l -exec rm {} \;
394# Build the package:
395makepkg -l y -c n $TMP/glibc-solibs-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
396
397# And finally, the complete "all-in-one" glibc package is created
398# from whatever was leftover:
399cd $PGLIBC
400mv $PKG/* .
401mkdir -p etc/profile.d
402cp -a $CWD/profile.d/* etc/profile.d
403chown -R root:root etc
404chmod 755 etc/profile.d/*
405# Ditch links (these are in doinst.sh-glibc):
406find . -type l -exec rm {} \;
407# libm.so is *not* a linker script on all $ARCH.
408# If it's missing now, replace the symlink:
409if [ ! -r usr/lib${LIBDIRSUFFIX}/libm.so ]; then
410  ( cd usr/lib${LIBDIRSUFFIX} ; ln -sf ../../lib${LIBDIRSUFFIX}/libm.so.6 libm.so )
411fi
412mkdir install
413cp -a $CWD/slack-desc.glibc install/slack-desc
414cp -a $CWD/doinst.sh-glibc install/doinst.sh
415fix_doinst
416sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
417( cd lib${LIBDIRSUFFIX}
418  mkdir incoming
419  mv *so* incoming
420  mv incoming/libSegFault.so .
421)
422# Build the package:
423/sbin/makepkg -l y -c n $TMP/glibc-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
424
425# Done!
426echo
427echo "glibc packages built in $TMP!"
428
Note: See TracBrowser for help on using the repository browser.