#!/bin/sh # Copyright 2008, 2009, 2010 Patrick J. Volkerding, Sebeka, Minnesota, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. VERSION=3.0 BUILD=${BUILD:-8} # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) export ARCH=i486 ;; arm*) export ARCH=arm ;; # Unless $ARCH is already set, use uname -m for all other archs: *) export ARCH=$( uname -m ) ;; esac fi NUMJOBS=${NUMJOBS:-" -j7 "} CWD=$(pwd) TMP=${TMP:-/tmp} if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" elif [ "$ARCH" = "s390" ]; then SLKCFLAGS="-O2" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" else SLKCFLAGS="-O2" fi # There were so many local security problems with this shared fontcache # scheme that it's not worth trying to support. It was not enabled by # default, and newer versions of teTeX don't seem to recongnize it any # longer either. #export fontcache=/var/cache/fonts #export vartexfonts=$fontcache #mkdir -p /var/cache/fonts/pk /var/cache/fonts/source /var/cache/fonts/tfm #chmod 1777 /var/cache/fonts /var/cache/fonts/pk \ # /var/cache/fonts/source /var/cache/fonts/tfm # Safer to purge this first: rm -rf /usr/share/texmf rm -rf /usr/share/texmf-var rm -rf /usr/share/texi2html # Make a clean new directory: mkdir -p /usr/share/texmf ( cd /usr/share/texmf tar xvf $CWD/tetex-texmf-$VERSION.tar.xz chown -R root:root . find . -type f -perm 666 -exec chmod 644 {} \; # Change the sell-by date: zcat $CWD/tetex.leet.diff.gz | patch -p1 --verbose || exit 1 ) cd $TMP rm -rf tetex-src-$VERSION tar xvf $CWD/tetex-src-$VERSION.tar.xz cd tetex-src-$VERSION chown -R root:root . find . -type f -perm 666 -exec chmod 644 {} \; # Fix possible xpdf overflows: zcat $CWD/tetex.CVE-2005-3193.diff.gz | patch -p1 --verbose || exit 1 # /var/lib/texmf is a better font location than /var/tmp/texfonts: zcat $CWD/tetex.var.fonts.diff.gz | patch -p1 --verbose || exit 1 # Even better is something in your $HOME directory: zcat $CWD/tetex.fontcachedirinhome.diff.gz | patch -p1 --verbose || exit 1 # Use mkstemp() in dvipdfm: zcat $CWD/tetex.dvipdfm.mkstemp.diff.gz | patch -p1 --verbose || exit 1 # Use mktemp in scripts: zcat $CWD/tetex.scripts.mktemp.diff.gz | patch -p1 --verbose || exit 1 # Try to use more modern browsers. # Attempt to use them in this order: firefox, seamonkey, mozilla, links, lynx. zcat $CWD/tetex.browsers.diff.gz | patch -p1 --verbose || exit 1 # Add bplain and bamstex info to fmtutil.cnf: zcat $CWD/tetex.amstex.fmtutil.diff.gz | patch -p1 --verbose || exit 1 # Don't leave texconfig junk in $TMP: zcat $CWD/tetex.tmp.cleanup.diff.gz | patch -p1 --verbose || exit 1 # Fix the cpascal header so there's no conflict with getline() in the # generated C code: zcat $CWD/tetex.cpascal.getline.posix.2008.diff.gz | patch -p1 --verbose || exit 1 # Patch for libpng-1.4.0: zcat $CWD/tetex.png14.diff.gz | patch -p1 --verbose || exit 1 # Another problem caused by getline() in glibc: zcat $CWD/tetex.afm2tfm.getline.diff.gz | patch -p1 --verbose || exit 1 CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ ./configure --prefix=/usr/share/texmf \ --datadir=/usr/share \ --disable-multiplatform \ --disable-a4 \ --without-dialog \ --without-texinfo \ --with-system-ncurses \ --with-system-pnglib \ --with-system-t1lib \ --with-system-tifflib \ --with-system-zlib \ --with-ps=gs \ --enable-ipc \ --enable-freetype \ --with-etex # --without-texinfo # Really, it doesn't hurt to include these twice... # This was reported to fix a problem with newer GNU sources and "make dvi". # It does, in fact, fix a bug where the etex binary/engine really should be # used when etex and dvi output are requested, but the example given to me # (which was "make dvi" in GNU binutils) also has some problems that have to # be fixed. This confused me for a good long time. ;-) # BTW, the fix for the binutils docs is to edit bfd.texinfo and remove that # @tex through @end tex section near the top. Then build twice. Hit enter # if it "sticks". zcat $CWD/tetex.etex.diff.gz | patch -p1 --verbose || exit 1 make all $NUMJOBS || make all || exit 1 make install strip || exit 1 if ! echo $PATH | grep /usr/share/texmf/bin ; then PATH=$PATH:/usr/share/texmf/bin fi # ... [don't] make links to all binaries in /usr/bin for the final package. # [that would be really pointless... $PATH should work, period. ] # If latex isn't there, maybe we need to do this: if [ ! -r /usr/share/texmf/bin/latex ]; then texconfig init fi # Let's start with these defaults: texconfig confall texconfig dvips paper letter texconfig xdvi paper us # These *might* be useful... # Some are known to be not-so-useful, though, as they put the config files # into /root/.texmf-config, which we're simply going to throw away anyway # so it won't interfere with server testing. If you need these options, # you'll probably have to run texconfig yourself in your own user (or root) # account. texconfig mode ljfour #texconfig xdvi paper a4 texconfig dvips mode ljfour #texconfig dvips paper a4 texconfig dvips printcmd - texconfig dvips add bjc600 texconfig dvips add stcolor texconfig dvips add deskjet texconfig dvips add ljet4 texconfig dvips -P bjc600 mode canonbjc texconfig dvips -P stcolor mode epstylus texconfig dvips -P deskjet mode deskjet texconfig dvips -P ljet4 mode ljfour texconfig font ro texconfig rehash # Add jadetex to the package: . $CWD/jadetex.build # Toss redundant docs: ( cd /usr/share/texmf/doc for file in $(find . -name "*.dvi") ; do rm -f $(dirname $file)/$(basename $file .dvi).pdf done ) # Discard local configurations: if [ -e /root/.texmf-config ]; then mv /root/.texmf-config /root/.texmf-config-$(mcookie) echo "/root/.texmf-config moved out of the way... you may wish" echo "to purge any /root/.texmf-config-* directories if the" echo "cruft heap gets too large." fi # Now, package the /usr/share/texmf/ and /usr/share/texi2html trees. # Package tetex-doc.txz and tetex-bin.txz seperately. PKG1=$TMP/package-tetex PKG2=$TMP/package-tetex-doc rm -rf $PKG1 $PKG2 mkdir -p $PKG1 $PKG2 mkdir -p $PKG1/usr/share mv /usr/share/texmf $PKG1/usr/share mv /usr/share/texmf-var $PKG1/usr/share mv /usr/share/texi2html $PKG1/usr/share # The tetex.txz file will need an installation script to add # /usr/share/texmf/bin to the $PATH and /usr/share/texmf/man to the $MANPATH: mkdir -p $PKG1/etc/profile.d cp -a $CWD/profile.d/tetex.* $PKG1/etc/profile.d chown root:root $PKG1/etc/profile.d/tetex.* chmod 755 $PKG1/etc/profile.d/tetex.* mkdir -p $PKG1/install cp $CWD/slack-desc.tetex $PKG1/install/slack-desc mkdir -p $PKG2/install cp $CWD/slack-desc.tetex-doc $PKG2/install/slack-desc # Strip everything: find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null # Gzip man pages: gzip -9 $PKG1/usr/share/texmf/man/man?/*.? # Fix manpage symlinks: ( cd $PKG1/usr/share/texmf/man for dir in man? ; do ( cd $dir for file in *.? ; do if [ -L $file ]; then LINK=$(readlink $file) rm $file ln -sf ${LINK}.gz ${file}.gz fi done ) done ) # Move some of the files into the docs package: mkdir -p $PKG2/usr/share/texmf/doc mv $PKG1/usr/share/texmf/doc/* $PKG2/usr/share/texmf/doc mkdir -p $PKG2/usr/share/texinfo mv /usr/share/texinfo/html $PKG2/usr/share/texinfo mv $PKG1/usr/share/texmf/info $PKG2/usr ( cd $PKG1/usr/share/texmf ; ln -sf /usr/info . ) # Compress info pages and purge "dir" file from the package: if [ -d $PKG2/usr/info ]; then ( cd $PKG2/usr/info rm -f dir gzip -9 * ) fi # Make docs link in /usr/doc/: mkdir -p $PKG2/usr/doc ( cd $PKG2/usr/doc ; rm -rf tetex-$VERSION ) ( cd $PKG2/usr/doc ; ln -sf /usr/share/texmf/doc tetex-$VERSION ) # Build the packages: cd $PKG1 /sbin/makepkg -l y -c n $TMP/tetex-$VERSION-$ARCH-$BUILD.txz cd $PKG2 /sbin/makepkg -l y -c n $TMP/tetex-doc-$VERSION-$ARCH-$BUILD.txz