summaryrefslogtreecommitdiff
path: root/portsToCome/texlive/Pkgfile
blob: 3ba7d547302f78ca5ed493253d3c53710f4756b5 (plain)
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
# Description: TeX distribution for UNIX compatible systems.
# URL:         http://www.tug.org/tetex/
# Maintainer:
# Depends on:  clisp icu libgd poppler t1lib util-linux xorg-libxi zziplib ghostscript

# a more opt friendly approach
# you still need to install contrib/zziplib

name=texlive
version=20190410
release=10
source=(ftp://tug.org/historic/systems/texlive/${version:0:4}/$name-$version-texmf.tar.xz
        ftp://tug.org/historic/systems/texlive/${version:0:4}/$name-$version-source.tar.xz
        http://download.savannah.gnu.org/releases/texi2html/texi2html-5.0.tar.bz2
        support-system-poppler-0.79.patch
        reinstate-setting-HAVE_LIBGS-for-non-TL-builds.patch
        tabu.sty.diff)

build() {
  # remove broken symlinks
  # -exec rm '{}' \+ was a tip I got from romster, it will batch to rm and perform better on large quantities
  find $SRC -type l -xtype l -exec rm '{}' \+

  cd $name-$version-source

  chmod -R a-s $SRC

  find $SRC \
    \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
    -exec chmod 755 {} \; -o \
    \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
    -exec chmod 644 {} \;

  # fix build with poppler >= 0.76 (upstream patch, cherry-picked from git-svn)
  patch -Np1 -i $SRC/support-system-poppler-0.79.patch
  cp -pv texk/web2c/pdftexdir/pdftoepdf{-poppler0.79.0,}.cc
  cp -pv texk/web2c/pdftexdir/pdftosrc{-poppler0.79.0,}.cc
  # fix libgs linking issue with dvisvgm (upstream patch, cherry-picked from git-svn)
  patch -Np1 -i $SRC/reinstate-setting-HAVE_LIBGS-for-non-TL-builds.patch

  # Fix some paths
  sed -i 's/SELFAUTOPARENT/TEXMFROOT/' texk/tex4htk/t4ht.c
  sed -i 's|TEXMFROOT = .*|TEXMFROOT = $SELFAUTODIR/share|g' texk/kpathsea/texmf.cnf
  sed -i 's|TEXMFLOCAL = .*|TEXMFLOCAL = $TEXMFROOT/texmf-local|g' texk/kpathsea/texmf.cnf

  export TEXMFCNF=""
  export KPATHSEA_WARNING=0

  # prevent compiling Xdvi with libXp
  sed -i 's|-lXp ||' texk/xdvik/configure

  mkdir build
  cd build

  ../configure \
    --prefix=/usr \
    --with-banner-add=" $(crux)" \
    --with-clisp-runtime=system \
    --enable-{gc=system,libtool-hack,luatex,pdftex,shared,tex,texlive,tex-synctex,web2c,xindy} \
    --with-system-{gd,gmp,mpfr,ncurses,pixman,poppler,t1lib,xpdf,zlib,zziplib} \
    --with-x \
    --with-xdvi-x-toolkit=xaw \
    --disable-{aleph,luajit,mflua,native-texlive-build,xetex,xindy-docs,xindy-rules}

  make
  # taken from archs texlive-bin PKGBUILD
  # https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/texlive-bin
  # line 116
  # doesn't work
  #find utils/xindy -name Makefile -exec sed -i -e "s|^prefix =.\+$|prefix = $PKG/usr|" \
  #  -e "s|^mandir =.\+$|mandir = \${prefix}/share/man|" -e "s|^datadir =.\+$|datadir = \${datarootdir}/texmf-dist|" \
  #  -e "s|^docdir =.\+$|docdir = \${datadir}/doc/xindy|" '{}' \;

  make DESTDIR=$PKG install-strip
  cd ..

  perl_sitelib=$(perl -V:sitelib | sed -e "s|sitelib=[']\(.*\)['].*$|\1|")
  install -d $PKG/$perl_sitelib/TeXLive
  install texk/tests/TeXLive/TL{Config,Utils}.pm $PKG/$perl_sitelib/TeXLive

  # configure fmtutil
  sed \
    -e 's/^aleph/#! aleph/g' \
    -e 's/^lamed/#! lamed/g' \
    -e 's/^amstex/#! amstex/g' \
    -e 's/^cont-en xetex/#! cont-en xetex/g' \
    -e 's/^pdfcs/#! pdfcs/g' \
    -e 's/^luacs/#! luacs/g' \
    -e 's/^pdfcs/#! pdfcs/g' \
    -e 's/^csplain/#! csplain/g' \
    -e 's/^eplain/#! eplain/g' \
    -e 's/^pdfjadetex/#! pdfjadetex/g' \
    -e 's/^jadetex/#! jadetex/g' \
    -e 's/^luajittex/#! luajittex/g' \
    -e 's/^mf/#! mf/g' \
    -e 's/^pdfmex/#! pdfmex/g' \
    -e 's/^utf8mex/#! utf8mex/g' \
    -e 's/^mex/#! mex/g' \
    -e 's/^mllatex/#! mllatex/g' \
    -e 's/^mltex/#! mltex/g' \
    -e 's/^mptopdf/#! mptopdf/g' \
    -e 's/^platex/#! platex/g' \
    -e 's/^eptex/#! eptex/g' \
    -e 's/^ptex/#! ptex/g' \
    -e 's/^texsis/#! texsis/g' \
    -e 's/^euptex/#! euptex/g' \
    -e 's/^uplatex/#! uplatex/g' \
    -e 's/^uptex/#! uptex/g' \
    -e 's/^xelatex/#! xelatex/g' \
    -e 's/^xetex/#! xetex/g' \
    -e 's/^cslatex/#! cslatex/g' \
    -e 's/^lollipop/#! lollipop/g' \
    -i $PKG/usr/share/texmf-dist/web2c/fmtutil.cnf

  # Create symlinks
  PATH="$PKG/usr/bin:$PATH" LD_LIBRARY_PATH+="$PKG/usr/lib:$LD_LIBRARY_PATH" \
    texlinks -f $PKG/usr/share/texmf-dist/web2c/fmtutil.cnf $PKG/usr/bin

  cd $SRC/$name-$version-texmf

  # Fix some paths
  sed -i \
    -e 's|TEXMFROOT = .*|TEXMFROOT = $SELFAUTODIR/share|g' \
    -e 's|TEXMFLOCAL = .*|TEXMFLOCAL = $TEXMFROOT/texmf-local|g' \
    -e 's|^OSFONTDIR.*|OSFONTDIR = ~/.fonts:/usr/share/fonts|' \
    texmf-dist/web2c/texmf.cnf

  # maybe this can be worked around by unpacking texmf-dist directly to $PKG/usr/share?
  # although this works fine and doesn't draw much performance on my end
  mv $PKG/usr/share/texmf-dist $PKG/usr/share/texmf-dist.tmp
  mv texmf-dist $PKG/usr/share

  ## sub-optimal but better than copying texmf-dist!
  cp -a $PKG/usr/share/texmf-dist.tmp/* $PKG/usr/share/texmf-dist
  rm -r $PKG/usr/share/texmf-dist.tmp

  # taken from slackwares SlackBuild
  # http://slackbuilds.org/slackbuilds/14.2/office/texlive/texlive.SlackBuild
  # line 175
  # disable obsolete aleph/lamed/cslatex/pdfcslatex
  #sed -i \
  #  -e 's|^aleph|#! aleph|' \
  #  -e 's|^lamed|#! lamed|' \
  #  -e 's|^cslatex|#! cslatex|' \
  #  -e 's|^pdfcslatex|#! pdfcslatex|' \
  #  $PKG/usr/share/texmf-dist/web2c/fmtutil.cnf

  # make ConTeXt work, and remove unused settings
  sed -i \
    -e 's|selfautoparent:|/usr/share/|g' \
    -e 's|\(TEXMFLOCAL[ ]*=[ ]*\)[^,]*|\1"/usr/share/texmf-local"|' \
    -e '/selfautodir/d' \
    -e '/texmflocal/d' \
    $PKG/usr/share/texmf-dist/web2c/texmfcnf.lua

  cd $SRC/texi2html-*
  ./configure --prefix=/usr
  make
  make install DESTDIR=$PKG

  # final clean up
  rm -r $PKG/usr/share/{info,locale,texmf-dist/doc}
  rm -r $PKG/usr/bin/tlmgr
  rm -r $PKG/usr/share/texmf-dist/scripts/texlive/tlmgr{,gui}.pl
  find  $PKG/usr/share/texmf-dist \
    -regex '.*/\(COPYING\|README\|AUTHORS\|INSTALL\|ChangeLog\|NEWS\|TODO\).*' \
    -exec rm '{}' \+
  # strip .la files
  rm -f $PKG/usr/lib/*.la
  # patch tabu.sty from https://github.com/tabu-fixed/tabu to fix
  # breakage when compiling doxygen:
  ( cd $PKG/usr/share/texmf-dist/tex/latex/tabu
  cat $SRC/tabu.sty.diff | patch -p1 --verbose || exit 1
  )
}