texlive: fix postinst, prerm, preinst scripts (#1648)
[termux-packages] / packages / texlive / build.sh
CommitLineData
cb2a32e4 1TERMUX_PKG_HOMEPAGE=https://www.tug.org/texlive/
2TERMUX_PKG_DESCRIPTION="TeX Live is a distribution of the TeX typesetting system."
e85171f5
HG
3TERMUX_PKG_MAINTAINER="Henrik Grimler @Grimler91"
4_MAJOR_VERSION=20170524
5_MINOR_VERSION=
d415b125 6TERMUX_PKG_VERSION=${_MAJOR_VERSION}${_MINOR_VERSION}
5ceb2e0e 7TERMUX_PKG_REVISION=4
dce832a2
HG
8TERMUX_PKG_SRCURL=("ftp://ftp.tug.org/texlive/historic/${TERMUX_PKG_VERSION:0:4}/"\
9{"texlive-$_MAJOR_VERSION-texmf.tar.xz",\
10"texlive-$_MAJOR_VERSION-extra.tar.xz",\
11"install-tl-unx.tar.gz"})
12TERMUX_PKG_SHA256=("3f63708b77f8615ec6f2f7c93259c5f584d1b89dd335a28f2362aef9e6f0c9ec"
13"afe49758c26fb51c2fae2e958d3f0c447b5cc22342ba4a4278119d39f5176d7f"
14"d4e07ed15dace1ea7fabe6d225ca45ba51f1cb7783e17850bc9fe3b890239d6d")
15TERMUX_PKG_DEPENDS="wget, perl, xz-utils, gnupg2, texlive-bin (>= 20170524)"
16TERMUX_PKG_FOLDERNAME=("texlive-$_MAJOR_VERSION-texmf"
17"texlive-$_MAJOR_VERSION-extra"
18"install-tl-$_MAJOR_VERSION")
19TL_FILE_LISTS=("texlive-texmf.list"
20"texlive-extra.list"
21"install-tl.list")
22TERMUX_PKG_PLATFORM_INDEPENDENT=yes
d415b125 23
e85171f5 24TL_ROOT=$TERMUX_PREFIX/opt/texlive/${TERMUX_PKG_VERSION:0:4}
dce832a2 25TL_BINDIR=$TL_ROOT/bin/custom
e85171f5 26
dce832a2
HG
27termux_step_extract_package() {
28 mkdir -p "$TERMUX_PKG_SRCDIR"
29
30 cd "$TERMUX_PKG_TMPDIR"
31 for index in $(seq 0 2); do
32 local filename
33 filename=$(basename "${TERMUX_PKG_SRCURL[$index]}")
34 local file="$TERMUX_PKG_CACHEDIR/$filename"
35 termux_download "${TERMUX_PKG_SRCURL[$index]}" "$file" "${TERMUX_PKG_SHA256[$index]}"
36
37 folder=${TERMUX_PKG_FOLDERNAME[$index]}
38
39 rm -Rf $folder
40 echo "Extracting files listed in ${TL_FILE_LISTS[$index]} from $folder"
41 tar xf "$file" $(paste -d'\0' <(for i in $(seq 1 $( wc -l < $TERMUX_PKG_BUILDER_DIR/${TL_FILE_LISTS[$index]} )); do echo ${TERMUX_PKG_FOLDERNAME[$index]}/; done ) $TERMUX_PKG_BUILDER_DIR/${TL_FILE_LISTS[$index]} )
42 done
43 cp -r ${TERMUX_PKG_FOLDERNAME[@]} "$TERMUX_PKG_SRCDIR"
cb2a32e4 44}
45
dce832a2
HG
46termux_step_make() {
47 for index in $( seq 0 2 ); do
48 cp -r $TERMUX_PKG_SRCDIR/${TERMUX_PKG_FOLDERNAME[$index]}/* $TL_ROOT/
49 done
50
51 mkdir -p $TL_ROOT/{tlpkg/{backups,tlpobj},texmf-var/web2c}
52 cp $TERMUX_PKG_BUILDER_DIR/texlive.tlpdb $TL_ROOT/tlpkg/
53
54 perl -I$TL_ROOT/tlpkg/ $TL_ROOT/texmf-dist/scripts/texlive/mktexlsr.pl $TL_ROOT/texmf-dist
cb2a32e4 55}
56
57termux_step_create_debscripts () {
dce832a2 58 # Clean texlive's folder if needed (run on upgrade)
5ceb2e0e 59 echo "#!$TERMUX_PREFIX/bin/bash" > preinst
aa605e89 60 echo "if [ ! -f $TERMUX_PREFIX/opt/texlive/2016/install-tl -a ! -f $TERMUX_PREFIX/opt/texlive/2017/install-tl ]; then exit 0; else echo 'Removing residual files from old version of TeX Live for Termux'; fi" >> preinst
dce832a2
HG
61 echo "rm -rf $TERMUX_PREFIX/etc/profile.d/texlive.sh" >> preinst
62 echo "rm -rf $TERMUX_PREFIX/opt/texlive/2016" >> preinst
63 # Let's not delete the previous texmf-dist so that people who have installed a full distribution won't need to download everything again
104ad022 64 echo "shopt -s extglob" >> preinst # !(texmf-dist) is an extended glob which is turned off in scripts
dce832a2 65 echo "rm -rf $TERMUX_PREFIX/opt/texlive/2017/!(texmf-dist)" >> preinst
104ad022 66 echo "shopt -u extglob" >> preinst # disable extglob again just in case
e85171f5
HG
67 echo "exit 0" >> preinst
68 chmod 0755 preinst
aa605e89 69
5ceb2e0e 70 echo "#!$TERMUX_PREFIX/bin/bash" > postinst
aa605e89 71 echo "mkdir -p $TL_ROOT/{tlpkg/{backups,tlpobj},texmf-var/{web2c,tex/generic/config}}" >> postinst
dce832a2 72 echo "export PATH=\$PATH:$TL_BINDIR" >> postinst
5ceb2e0e 73 echo "export TMPDIR=$TERMUX_PREFIX/tmp" >> postinst
dce832a2
HG
74 echo "echo Updating tlmgr" >> postinst
75 echo "tlmgr update --self" >> postinst
76 echo "echo Generating language files and setting up symlinks" >> postinst
77 echo "tlmgr -q generate language" >> postinst
78 echo "mktexlsr $TL_ROOT/texmf-var" >> postinst
79 echo "texlinks" >> postinst
80 echo "echo ''" >> postinst
81 echo "echo Welcome to TeX Live!" >> postinst
82 echo "echo ''" >> postinst
83 echo "echo 'TeX Live is a joint project of the TeX user groups around the world;'" >> postinst
84 echo "echo 'please consider supporting it by joining the group best for you.'" >> postinst
85 echo "echo 'The list of groups is available on the web at http://tug.org/usergroups.html.'" >> postinst
86 echo "echo ''" >> postinst
87 echo "echo 'Please run \"source $PREFIX/etc/profile.d/texlive.sh\" to add texlive'\''s binaries to your current shell'\''s PATH.'" >> postinst
88 echo "exit 0" >> postinst
89 chmod 0755 postinst
90
91 # Remove all files installed through tlmgr on removal
5ceb2e0e 92 echo "#!$TERMUX_PREFIX/bin/bash" > prerm
aa605e89 93 echo 'if [ $1 != "remove" ]; then exit 0; fi' >> prerm
e85171f5
HG
94 echo "echo Running texlinks --unlink" >> prerm
95 echo "texlinks --unlink" >> prerm
dce832a2
HG
96 echo "echo Removing texmf-dist" >> prerm
97 echo "rm -rf $TL_ROOT/texmf-dist" >> prerm
98 echo "echo Removing texmf-var and tlpkg" >> prerm
99 echo "rm -rf $TL_ROOT/{texmf-var,tlpkg/{texlive.tlpdb.*,tlpobj,backups}}" >> prerm
e85171f5
HG
100 echo "exit 0" >> prerm
101 chmod 0755 prerm
cb2a32e4 102}