summaryrefslogtreecommitdiffstats
path: root/source/t/tetex/tetex.SlackBuild
blob: f1927332378aeff6c0dc00ec39a37775978532bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/sh

# Copyright 2008, 2009  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
ARCH=${ARCH:-x86_64}
NUMJOBS=${NUMJOBS:-" -j7 "}
BUILD=${BUILD:-6}

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"
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 {} \;
)
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

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