source: npl/system/glibc/glibc.SlackBuild @ d2a077a

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

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 16.5 KB
Line 
1#!/bin/sh
2
3# Copyright 2006, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015  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:-1}
28
29## Included in glibc now:
30## glibc-libidn version
31#LIBIDNVER=2.10.1
32
33# I was considering disabling NSCD, but MoZes talked me out of it.  :)
34#DISABLE_NSCD=" --disable-nscd "
35
36# $ARCH may be preset, otherwise i486 compatibility with i686 binary
37# structuring is the Slackware default, since this is what gcc-3.2+
38# requires for binary compatibility with previous releases.
39#ARCH=i486
40if [ -z "$ARCH" ]; then
41  case "$( uname -m )" in
42    i?86) export ARCH=i486 ;;
43    arm*) export ARCH=arm ;;
44    # Unless $ARCH is already set, use uname -m for all other archs:
45       *) export ARCH=$( uname -m ) ;;
46  esac
47fi
48
49# I'll break this out as an option for fun  :-)
50case $ARCH  in
51  i386)
52    OPTIMIZ="-O3 -march=i386 -mcpu=i686"
53    LIBDIRSUFFIX=""
54    ;;
55  i486)
56    OPTIMIZ="-O3 -march=i486 -mtune=i686"
57    LIBDIRSUFFIX=""
58    ;;
59  i586)
60    OPTIMIZ="-O3 -march=i586"
61    LIBDIRSUFFIX=""
62    ;;
63  i686)
64    OPTIMIZ="-O3 -march=i686"
65    LIBDIRSUFFIX=""
66    ;;
67  athlon)
68    OPTIMIZ="-O3 -march=athlon"
69    LIBDIRSUFFIX=""
70    ;;
71  s390)
72    OPTIMIZ="-O3"
73    LIBDIRSUFFIX=""
74    ;;
75  x86_64)
76    OPTIMIZ="-O3 -fPIC"
77    LIBDIRSUFFIX="64"
78    ;;
79  *)
80    OPTIMIZ="-O3"
81    LIBDIRSUFFIX=""
82    ;;
83esac
84
85case $ARCH in
86  x86_64)
87    TARGET=${TARGET:-x86_64}
88    ;;
89  i486)
90    # This should be i486 for all 32-bit x86 arch:
91    TARGET=${TARGET:-i486}
92    ;;
93esac
94
95# Hand off the $ARCH variable to $SLACKWARE_ARCH to avoid confusing glibc:
96SLACKWARE_ARCH=$ARCH
97unset ARCH
98
99CVSVER=${VERSION}${CHECKOUT}
100
101# NOTE!!!  glibc needs to be built against the sanitized kernel headers,
102# which will be installed under /usr/include by the kernel-headers package.
103# Be sure the correct version of the headers package is installed BEFORE
104# building glibc!
105
106CWD=$(pwd)
107# Temporary build location.  This should not be a directory
108# path a non-root user could create later...
109TMP=${TMP:-/glibc-tmp-$(mcookie)}
110mkdir -p $TMP
111
112NUMJOBS=${NUMJOBS:-" -j7 "}
113
114# This function fixes a doinst.sh file for x86_64.
115# With thanks to Fred Emmott.
116fix_doinst() {
117  if [ "x$LIBDIRSUFFIX" = "x" ]; then
118    return;
119  fi;
120  # Fix "( cd usr/lib ;" occurrences
121  sed -i "s#lib ;#lib${LIBDIRSUFFIX} ;#" install/doinst.sh
122  # Fix "lib/" occurrences
123  sed -i "s#lib/#lib${LIBDIRSUFFIX}/#g" install/doinst.sh
124  # Fix "( cd lib" occurrences
125  sed -i "s#( cd lib\$#( cd lib${LIBDIRSUFFIX}#" install/doinst.sh
126
127  if [ "$SLACKWARE_ARCH" = "x86_64" ]; then
128    sed -i 's#ld-linux.so.2#ld-linux-x86-64.so.2#' install/doinst.sh
129  fi
130}
131
132# This is a patch function to put all glibc patches in the build script
133# up near the top.
134apply_patches() {
135  # Use old-style locale directories rather than a single (and strangely
136  # formatted) /usr/lib/locale/locale-archive file:
137  zcat $CWD/glibc.locale.no-archive.diff.gz | patch -p1 --verbose || exit 1
138  # The is_IS locale is causing a strange error about the "echn" command
139  # not existing.  This patch reverts is_IS to the version shipped in
140  # glibc-2.5:
141  zcat $CWD/is_IS.diff.gz | patch -p1 --verbose || exit 1
142  # Fix NIS netgroups:
143  zcat $CWD/glibc.nis-netgroups.diff.gz | patch -p1 --verbose || exit 1
144  # Support ru_RU.CP1251 locale:
145  zcat $CWD/glibc.ru_RU.CP1251.diff.gz | patch -p1 --verbose || exit 1
146  # Fix resolver problem with glibc-2.9:
147  zcat $CWD/glibc-2.10-dns-no-gethostbyname4.diff.gz | patch -p0 --verbose || exit 1
148  # This reverts a patch that was made to glibc to fix "namespace leakage",
149  # which seems to cause some build failures (e.g. with conntrack):
150  zcat $CWD/glibc.revert.to.fix.build.breakages.diff.gz | patch -p1 -l --verbose || exit 1
151  # Make it harder for people to trick ldd into running code:
152  zcat $CWD/glibc.ldd.trace.through.dynamic.linker.diff.gz | patch -p1 --verbose || exit 1
153  # Make glibc compile with binutils using --enable-initfini-array.
154  # At this time, we do not recommend this due to probable ABI breakage.
155  # The also patch needs work before it would apply.
156  # ***NOT READY***
157  #zcat $CWD/glibc.git-4a531bb0b3b582cb693de9f76d2d97d970f9a5d5.patch.gz | patch -p1 --verbose || exit 1
158  #
159  # 2014-05:  We'll try building with the stock asm...
160  ## Avoid the Intel optimized asm routines for now because they break
161  ## the flash player.  We'll phase this in when it's safer to do so.
162  #zcat $CWD/glibc.disable.broken.optimized.memcpy.diff.gz | patch -p1 --verbose || exit 1
163}
164
165# This is going to be the initial $DESTDIR:
166export PKG=$TMP/package-glibc-incoming-tree
167PGLIBC=$TMP/package-glibc
168PSOLIBS=$TMP/package-glibc-solibs
169PZONE=$TMP/package-glibc-zoneinfo
170PI18N=$TMP/package-glibc-i18n
171PPROFILE=$TMP/package-glibc-profile
172PDEBUG=$TMP/package-glibc-debug
173
174# Empty these locations first:
175for dir in $PKG $PGLIBC $PSOLIBS $PZONE $PI18N $PPROFILE $PDEBUG ; do
176  if [ -d $dir ]; then
177    rm -rf $dir
178  fi
179  mkdir -p $dir
180done
181if [ -d $TMP/glibc-$VERSION ]; then
182  rm -rf $TMP/glibc-$VERSION
183fi
184
185# Create an incoming directory structure for glibc to be built into:
186mkdir -p $PKG/lib${LIBDIRSUFFIX}
187mkdir -p $PKG/sbin
188mkdir -p $PKG/usr/bin
189mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
190mkdir -p $PKG/usr/sbin
191mkdir -p $PKG/usr/include
192mkdir -p $PKG/usr/doc
193mkdir -p $PKG/usr/man
194mkdir -p $PKG/usr/share
195mkdir -p $PKG/var/db/nscd
196mkdir -p $PKG/var/run/nscd
197
198# Begin extract/compile:
199cd $TMP
200rm -rf glibc-$CVSVER
201tar xvf $CWD/glibc-$CVSVER.tar.xz \
202  || tar xvf $CWD/glibc-$CVSVER.tar.bz2 \
203  || tar xvf $CWD/glibc-$CVSVER.tar.gz
204cd glibc-$CVSVER
205
206#tar xvf $CWD/glibc-libidn-$LIBIDNVER.tar.?z*
207#mv glibc-libidn-$LIBIDNVER libidn
208
209chown -R root:root .
210find . -perm 666 -exec chmod 644 {} \;
211find . -perm 664 -exec chmod 644 {} \;
212find . -perm 600 -exec chmod 644 {} \;
213find . -perm 444 -exec chmod 644 {} \;
214find . -perm 400 -exec chmod 644 {} \;
215find . -perm 440 -exec chmod 644 {} \;
216find . -perm 777 -exec chmod 755 {} \;
217find . -perm 775 -exec chmod 755 {} \;
218find . -perm 511 -exec chmod 755 {} \;
219find . -perm 711 -exec chmod 755 {} \;
220find . -perm 555 -exec chmod 755 {} \;
221
222# Clean up leftover CVS directories:
223find . -type d -name CVS -exec rm -r {} \; 2> /dev/null
224
225# Apply patches; exit if any fail.
226apply_patches
227if [ ! $? = 0 ]; then
228  exit 1
229fi
230
231# Make build directory:
232mkdir build-glibc-$VERSION
233cd build-glibc-$VERSION || exit 1
234
235echo "BUILDING DAS NPTL GLIBC"
236CFLAGS="-g $OPTIMIZ" \
237../configure \
238  --prefix=/usr \
239  --libdir=/usr/lib${LIBDIRSUFFIX} \
240  --enable-kernel=2.6.32 \
241  --with-headers=/usr/include \
242  --enable-add-ons \
243  --enable-obsolete-rpc \
244  --enable-profile \
245  $DISABLE_NSCD \
246  --infodir=/usr/info \
247  --mandir=/usr/man \
248  --with-tls \
249  --with-__thread \
250  --without-cvs \
251  $TARGET-slackware-linux
252
253make $NUMJOBS || make || exit 1
254make install install_root=$PKG || exit 1
255make localedata/install-locales install_root=$PKG || exit 1
256
257# The prevailing standard seems to be putting unstripped libraries in
258# /usr/lib/debug/ and stripping the debugging symbols from all the other
259# libraries.
260mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/debug
261cp -a $PKG/lib${LIBDIRSUFFIX}/l*.so* $PKG/usr/lib${LIBDIRSUFFIX}/debug
262cp -a $PKG/usr/lib${LIBDIRSUFFIX}/*.a $PKG/usr/lib${LIBDIRSUFFIX}/debug
263# Don't need debug+profile:
264( cd $PKG/usr/lib${LIBDIRSUFFIX}/debug ; rm -f *_p.* )
265# NOTE:  Is there really a reason for the glibc-debug package?
266# If you're debugging glibc, you can also compile it, right?
267
268## COMMENTED OUT:  There's no reason for profile libs to include -g information.
269## Put back unstripped profiling libraries:
270#mv $PKG/usr/lib${LIBDIRSUFFIX}/debug/*_p.a $PKG/usr/lib${LIBDIRSUFFIX}
271# It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile.
272
273# I don't think "strip -g" causes the pthread problems.  It's --strip-unneeded that does.
274strip -g $PKG/lib${LIBDIRSUFFIX}/l*.so*
275strip -g $PKG/usr/lib${LIBDIRSUFFIX}/l*.so*
276strip -g $PKG/usr/lib${LIBDIRSUFFIX}/lib*.a
277
278# Build and install the zoneinfo database:
279cd $TMP
280rm -rf tzcodedata-build
281mkdir tzcodedata-build
282cd tzcodedata-build
283tar xzf $CWD/tzdata?????.tar.gz
284tar xzf $CWD/tzcode?????.tar.gz
285sed -i "s,/usr/local,$(pwd),g" Makefile
286sed -i "s,/etc/zoneinfo,/zoneinfo,g" Makefile
287make
288make install
289mkdir -p $PKG/usr/share/zoneinfo/{posix,right}
290cd etc
291cp -a zoneinfo/* $PKG/usr/share/zoneinfo
292cp -a zoneinfo-posix/* $PKG/usr/share/zoneinfo/posix
293cp -a zoneinfo-leaps/* $PKG/usr/share/zoneinfo/right
294# Remove $PKG/usr/share/zoneinfo/localtime -- the install script will
295# create it as a link to /etc/localtime.
296rm -f $PKG/usr/share/zoneinfo/localtime
297
298# Back to the sources dir to add some files/docs:
299cd $TMP/glibc-$CVSVER
300
301# We'll automatically install the config file for the Name Server Cache Daemon.
302# Perhaps this should also have some commented-out startup code in rc.inet2...
303mkdir -p $PKG/etc
304cat nscd/nscd.conf > $PKG/etc/nscd.conf.new
305
306# Install some scripts to help select a timezone:
307( cd $CWD/timezone-scripts
308  # Try to rebuild this:
309  sh output-updated-timeconfig.sh $PKG/usr/share/zoneinfo > timeconfig 2> /dev/null
310)
311mkdir -p $PKG/var/log/setup
312cp -a $CWD/timezone-scripts/setup.timeconfig $PKG/var/log/setup
313chown root:root $PKG/var/log/setup/setup.timeconfig
314chmod 755 $PKG/var/log/setup/setup.timeconfig
315mkdir -p $PKG/usr/sbin
316cp -a $CWD/timezone-scripts/timeconfig $PKG/usr/sbin
317chown root:root $PKG/usr/sbin/timeconfig
318chmod 755 $PKG/usr/sbin/timeconfig
319
320## Install docs:
321( mkdir -p $PKG/usr/doc/glibc-$VERSION
322  cp -a \
323    BUGS CONFORMANCE COPYING COPYING.LIB FAQ INSTALL LICENSES NAMESPACE \
324    NEWS NOTES PROJECTS README README.libm \
325    $PKG/usr/doc/glibc-$VERSION
326)
327
328# Don't forget to add the /usr/share/zoneinfo/localtime -> /etc/localtime symlink! :)
329if [ ! -r $PKG/usr/share/zoneinfo/localtime ]; then
330  ( cd $PKG/usr/share/zoneinfo ; ln -sf /etc/localtime . )
331fi
332
333# OK, there are some very old Linux standards that say that any binaries in a /bin or
334# /sbin directory (and the directories themselves) should be group bin rather than
335# group root, unless a specific group is really needed for some reason.
336#
337# I can't find any mention of this in more recent standards docs, and always thought
338# that it was pretty cosmetic anyway (hey, if there's a reason -- fill me in!), so
339# it's possible that this ownership change won't be followed in the near future
340# (it's a PITA, and causes many bug reports when the perms change is occasionally
341# forgotten).
342#
343# But, it's hard to get me to break old habits, so we'll continue the tradition here:
344#
345# No, no we won't.  You know how we love to break traditions.
346
347# Strip most binaries:
348( cd $PKG
349  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
350  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null
351)
352
353# Fix info dir:
354rm $PKG/usr/info/dir
355gzip -9 $PKG/usr/info/*
356
357# This is junk
358rm $PKG/etc/ld.so.cache
359( cd $PKG
360  find . -name "*.orig" -exec rm {} \;
361)
362
363##################################
364# OK, time to make some packages #
365##################################
366
367# glibc-zoneinfo.  We will start with an easy one to avoid breaking a sweat.  ;-)
368cd $CWD
369ZONE_VERSIONS="$(echo tzdata* | cut -f1 -d . | cut -b7-11)"
370echo $ZONE_VERSIONS
371cd $PZONE
372# Install some scripts to help select a timezone:
373mkdir -p $PZONE/var/log/setup
374cp -a $CWD/timezone-scripts/setup.timeconfig $PZONE/var/log/setup
375chown root:root $PZONE/var/log/setup/setup.timeconfig
376chmod 755 $PZONE/var/log/setup/setup.timeconfig
377mkdir -p $PZONE/usr/sbin
378cp -a $CWD/timezone-scripts/timeconfig $PZONE/usr/sbin
379chown root:root $PZONE/usr/sbin/timeconfig
380chmod 755 $PZONE/usr/sbin/timeconfig
381mkdir $PZONE/install
382cat $CWD/doinst.sh-glibc-zoneinfo > $PZONE/install/doinst.sh
383cat $CWD/slack-desc.glibc-zoneinfo > $PZONE/install/slack-desc
384mkdir -p $PZONE/usr/share
385cd $PZONE/usr/share
386cp -a --verbose $PKG/usr/share/zoneinfo .
387cd $PZONE
388mkdir -p $PZONE/etc
389# This is already hard-coded into doinst.sh (like it'll be there anyway ;-):
390rm -f etc/localtime
391# Wrap it up:
392makepkg -l y -c n $TMP/glibc-zoneinfo-$ZONE_VERSIONS-noarch-$BUILD.txz
393
394# glibc-profile:
395cd $PPROFILE
396mkdir -p usr/lib${LIBDIRSUFFIX}
397# Might as well just grab these with 'mv' to simplify things later:
398mv $PKG/usr/lib${LIBDIRSUFFIX}/lib*_p.a usr/lib${LIBDIRSUFFIX}
399# Profile libs should be stripped.  Use the debug libs to debug...
400( cd usr/lib${LIBDIRSUFFIX} ; strip -g *.a )
401mkdir install
402cp -a $CWD/slack-desc.glibc-profile install/slack-desc
403makepkg -l y -c n $TMP/glibc-profile-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
404
405# THIS IS NO LONGER PACKAGED (or is it?  might be better to let it be made, and then ship it or not...)
406# glibc-debug:
407cd $PDEBUG
408mkdir -p usr/lib${LIBDIRSUFFIX}
409# Might as well just grab these with 'mv' to simplify things later:
410mv $PKG/usr/lib${LIBDIRSUFFIX}/debug usr/lib${LIBDIRSUFFIX}
411mkdir install
412cp -a $CWD/slack-desc.glibc-debug install/slack-desc
413makepkg -l y -c n $TMP/glibc-debug-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
414## INSTEAD, NUKE THESE LIBS
415#rm -rf $PKG/usr/lib${LIBDIRSUFFIX}/debug
416
417# glibc-i18n:
418cd $PI18N
419mkdir -p usr/lib${LIBDIRSUFFIX}
420rm -rf usr/lib${LIBDIRSUFFIX}/locale
421cp -a $PKG/usr/lib${LIBDIRSUFFIX}/locale usr/lib${LIBDIRSUFFIX}
422mkdir -p usr/share
423cp -a $PKG/usr/share/i18n usr/share
424cp -a $PKG/usr/share/locale usr/share
425mkdir install
426cp -a $CWD/slack-desc.glibc-i18n install/slack-desc
427makepkg -l y -c n $TMP/glibc-i18n-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
428
429# glibc-solibs:
430cd $PSOLIBS
431mkdir -p etc/profile.d
432cp -a $CWD/profile.d/* etc/profile.d
433chown -R root:root etc
434chmod 755 etc/profile.d/*
435mkdir -p lib${LIBDIRSUFFIX}
436cp -a $PKG/lib${LIBDIRSUFFIX}/* lib${LIBDIRSUFFIX}
437( cd lib${LIBDIRSUFFIX}
438  mkdir incoming
439  mv *so* incoming
440  mv incoming/libSegFault.so .
441)
442mkdir -p usr
443cp -a $PKG/usr/bin usr
444mv usr/bin/ldd .
445rm usr/bin/*
446mv ldd usr/bin
447mkdir -p usr/lib${LIBDIRSUFFIX}
448# The gconv directory has a lot of stuff, but including it here will save some problems.
449# Seems standard elsewhere.
450cp -a $PKG/usr/lib${LIBDIRSUFFIX}/gconv usr/lib${LIBDIRSUFFIX}
451# Another manpage abandoned by GNU...
452#mkdir -p usr/man/man1
453#cp -a $PKG/usr/man/man1/ldd.1.gz usr/man/man1
454mkdir -p usr/libexec
455cp -a $PKG/usr/libexec/pt_chown usr/libexec
456# Same usr.bin deal:
457cp -a $PKG/sbin .
458mv sbin/ldconfig .
459rm sbin/*
460mv ldconfig sbin
461mkdir install
462cp -a $CWD/slack-desc.glibc-solibs install/slack-desc
463cp -a $CWD/doinst.sh-glibc-solibs install/doinst.sh
464fix_doinst
465sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
466# Ditch links:
467find . -type l -exec rm {} \;
468# Build the package:
469makepkg -l y -c n $TMP/glibc-solibs-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
470
471# And finally, the complete "all-in-one" glibc package is created
472# from whatever was leftover:
473cd $PGLIBC
474mv $PKG/* .
475mkdir -p etc/profile.d
476cp -a $CWD/profile.d/* etc/profile.d
477chown -R root:root etc
478chmod 755 etc/profile.d/*
479# Ditch links (these are in doinst.sh-glibc):
480find . -type l -exec rm {} \;
481mkdir install
482cp -a $CWD/slack-desc.glibc install/slack-desc
483cp -a $CWD/doinst.sh-glibc install/doinst.sh
484fix_doinst
485sed -i "s/@@VERSION@@/$VERSION/g" install/doinst.sh
486( cd lib${LIBDIRSUFFIX}
487  mkdir incoming
488  mv *so* incoming
489  mv incoming/libSegFault.so .
490)
491# Build the package:
492/sbin/makepkg -l y -c n $TMP/glibc-$VERSION-$SLACKWARE_ARCH-$BUILD.txz
493
494# Done!
495echo
496echo "glibc packages built in $TMP!"
497
498
499############ make syn3 packages
500cd $CWD
501ARCH=i486
502for PKG in /glibc-tmp-*/package-*; do
503        NAME=`echo $PKG| sed 's/.*package-//'| sed 's/-/_/'`
504
505        #seperate dev-package
506        syn3_move_dev $PKG $PKG""_dev
507        syn3_makepkg $PKG""_dev $NAME""_dev $VERSION $ARCH || exit 1
508
509        #make main package
510        syn3_makepkg $PKG $NAME $VERSION $ARCH || exit 1
511done
Note: See TracBrowser for help on using the repository browser.