#!/bin/sh ## build glibc-$VERSION for AlphaSlack ############################### ### compiled with gcc-4.3.2 ### ### and binutils-2.18 ### ############################### CWD=`pwd` TMP=/tmp VERSION=2.7 CVSVER=2.7 HEADERSTWOSIX=2.6.26.5 KERNEL=2.6.16 ARCH=alpha BUILD=6 TARGET=$ARCH-alphaslack-linux # We need another tmp initial $DESTDIR for the NPTL version now, too: export PKG=$TMP/package-glibc-incoming-tree # Then we'll compile the following packages from it: PGLIBC=$TMP/package-glibc PSOLIBS=$TMP/package-glibc-solibs PZONE=$TMP/package-glibc-zoneinfo PI18N=$TMP/package-glibc-i18n PDEBUG=$TMP/package-glibc-debug # Empty these locations first: for dir in $PKG $PGLIBC $PSOLIBS $PZONE $PI18N $PDEBUG ; do if [ -d $dir ]; then rm -rf $dir fi mkdir -p $dir done if [ -d $TMP/glibc-$VERSION ]; then rm -rf $TMP/glibc-$VERSION fi apply_patches() { zcat $CWD/glibc.locale.no-archive.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/alpha-gcc-ioperm.c.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/glibc.nis-netgroups.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/glibc.kernelversion.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/glibc.getcwd.max.macro.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/alpha-PTR_MANGLE.diff.gz | patch -p1 --verbose || exit 1 zcat $CWD/alpha-glibc-2.7-page.h.patch.gz | patch -p1 --verbose || exit 1 } # Create an incoming directory structure for glibc to be built into: mkdir -p $PKG/lib mkdir -p $PKG/sbin mkdir -p $PKG/usr/{bin,lib,sbin,include,doc,man,share} ( cd $TMP tar xjf $CWD/glibc-$CVSVER.tar.bz2 cd glibc-$CVSVER tar xjf $CWD/glibc-libidn-$VERSION.tar.bz2 ln -sf glibc-libidn-$VERSION libidn chown -R root.root . # Clean up leftover CVS directories: find . -type d -name CVS -exec rm -r {} \; # Apply patches; exit if any fail. apply_patches if [ ! $? = 0 ]; then exit 1 fi # Make build directory: mkdir build-glibc-$VERSION cd build-glibc-$VERSION CFLAGS="-g -O3" \ ../configure \ --prefix=/usr \ --infodir=/usr/info \ --enable-kernel=$KERNEL \ --with-headers=/usr/src/linux-$HEADERSTWOSIX/include \ --enable-add-ons=libidn,nptl \ --enable-profile \ --with-tls \ --with-__thread \ --without-cvs \ --build=$TARGET make -s || exit 1 make -s install install_root=$PKG || exit 1 make -s localedata/install-locales install_root=$PKG || exit 1 # The prevailing standard seems to be putting unstripped libraries in # /usr/lib/debug/ and stripping the debugging symbols from all the other # libraries. Only linuxthreads versions are provided. mkdir -p $PKG/usr/lib/debug cp -a $PKG/lib/l*.so* $PKG/usr/lib/debug cp -a $PKG/usr/lib/*.a $PKG/usr/lib/debug # Don't need debug+profile: ( cd $PKG/usr/lib/debug ; rm -f *_p.* ) # NOTE: Is there really a reason for the glibc-debug package? # If you're debugging glibc, you can also compile it, right? ## COMMENTED OUT: There's no reason for profile libs to include -g information. ## Put back unstripped profiling libraries: #mv $PKG/usr/lib/debug/*_p.a $PKG/usr/lib # It might be best to put the unstripped and profiling libraries in glibc-debug and glibc-profile. # I don't think "strip -g" causes the pthread problems. It's --strip-unneeded that does. strip -g $PKG/lib/l*.so* strip -g $PKG/usr/lib/l*.so* strip -g $PKG/usr/lib/lib*.a # Back to the sources dir to add some files/docs: cd $TMP/glibc-$CVSVER # We'll automatically install the config file for the Name Server Cache Daemon. # Perhaps this should also have some commented-out startup code in rc.inet2... mkdir -p $PKG/etc cat nscd/nscd.conf > $PKG/etc/nscd.conf.new # Not a bad idea to have this here as well: ( cd $PKG ; tar xzf $CWD/timezone.tar.gz ) ## Install docs: ( mkdir -p $PKG/usr/doc/glibc-$VERSION cp -a BUGS C* F* I* L* N* P* R* V* W* $PKG/usr/doc/glibc-$VERSION find $PKG/usr/doc/glibc-$VERSION -type d | xargs chmod 755 find $PKG/usr/doc/glibc-$VERSION -type f | xargs chmod 644 ) # Don't forget to add the /usr/share/zoneinfo/localtime -> /etc/localtime symlink! :) if [ ! -r $PKG/usr/share/zoneinfo/localtime ]; then ( cd $PKG/usr/share/zoneinfo ; ln -sf /etc/localtime . ) fi # But, it's hard to get me to break old habits, so we'll continue the tradition here: chown -R root.bin $PKG/sbin $PKG/usr/bin $PKG/usr/sbin # Strip most binaries: ( cd $PKG find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip -g 2> /dev/null ) # Fix info dir: rm $PKG/usr/info/dir gzip -9 $PKG/usr/info/* # This is junk rm -rf $PKG/etc/ld.so.cache rm -rf $PKG/sbin/sln ( cd $PKG find . -name "*.orig" -exec rm {} \; ) ################################## # OK, time to make some packages # ################################## # glibc-zoneinfo. We will start with an easy one to avoid breaking a sweat. ;-) cd $PZONE explodepkg $CWD/timezone.tar.gz mkdir $PZONE/install cat $CWD/doinst.sh-glibc-zoneinfo > $PZONE/install/doinst.sh cat $CWD/slack-desc.glibc-zoneinfo > $PZONE/install/slack-desc cd $PZONE/usr/share mv $PKG/usr/share/zoneinfo . cd $PZONE # This is already hard-coded into doinst.sh: rm -f etc/localtime # Build the package: makepkg -l y -c n $TMP/glibc-zoneinfo-$VERSION-$ARCH-$BUILD.tgz # glibc-debug: cd $PDEBUG mkdir -p usr/lib # Might as well just grab these with 'mv' to simplify things later: mv $PKG/usr/lib/debug usr/lib mkdir install cp -a $CWD/slack-desc.glibc-debug install/slack-desc # Build the package: makepkg -l y -c n $TMP/glibc-debug-$VERSION-$ARCH-$BUILD.tgz ## INSTEAD, NUKE THESE LIBS #rm -rf $PKG/usr/lib/debug # glibc-i18n: cd $PI18N mkdir -p usr/lib rm -rf usr/lib/locale mv $PKG/usr/lib/locale usr/lib mkdir -p usr/share mv $PKG/usr/share/i18n usr/share mv $PKG/usr/share/locale usr/share mkdir install cp -a $CWD/slack-desc.glibc-i18n install/slack-desc # Build the package: makepkg -l y -c n $TMP/glibc-i18n-$VERSION-$ARCH-$BUILD.tgz # glibc-solibs: cd $PSOLIBS mkdir -p etc/profile.d cp -a $CWD/profile.d/* etc/profile.d chown -R root:root etc chmod 755 etc/profile.d/* mkdir -p lib cp -a $PKG/lib/* lib ( cd lib mkdir incoming mv *so* incoming mv incoming/libSegFault.so . ) mkdir -p usr # This skirts the root.bin issue. cp -a $PKG/usr/bin usr mv usr/bin/ldd . rm usr/bin/* mv ldd usr/bin mkdir -p usr/lib # The gconv directory has a lot of stuff, but including it here will save some problems. # Seems standard elsewhere. cp -a $PKG/usr/lib/gconv usr/lib mkdir -p usr/libexec cp -a $PKG/usr/libexec/pt_chown usr/libexec # Same usr.bin deal: cp -a $PKG/sbin . mv sbin/ldconfig . rm sbin/* mv ldconfig sbin mkdir install cp -a $CWD/slack-desc.glibc-solibs install/slack-desc cp -a $CWD/doinst.sh-glibc-solibs install/doinst.sh # Ditch links: find . -type l -exec rm {} \; # Build the package: makepkg -l y -c n $TMP/glibc-solibs-$VERSION-$ARCH-$BUILD.tgz # And finally, the complete "all-in-one" glibc package is created # from whatever was leftover: cd $PGLIBC mv $PKG/* . mkdir -p etc/profile.d cp -a $CWD/profile.d/* etc/profile.d chown -R root:root etc chmod 755 etc/profile.d/* # Ditch links (these are in doinst.sh-glibc): find . -type l -exec rm {} \; mkdir install cp -a $CWD/slack-desc.glibc install/slack-desc cp -a $CWD/doinst.sh-glibc install/doinst.sh ( cd lib mkdir incoming mv *so* incoming mv incoming/libSegFault.so . ) # Build the package: makepkg -l y -c n $TMP/glibc-$VERSION-$ARCH-$BUILD.tgz # Done! echo echo "glibc packages built in $TMP!" ) 2>&1 | tee /tmp/glibc.build.log