# Clean texlive's folder if needed (run on fresh install)
echo"#!$TERMUX_PREFIX/bin/bash" > preinst
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
echo"shopt -u extglob" >> preinst # disable extglob again just in case
echo"if [ ! -d $PREFIX/opt/texlive ]; then echo 'Removing residual files from old version of TeX Live for Termux'; rm -rf $PREFIX/opt/texlive; fi" >> preinst
# Clean texlive's folder if needed (run on upgrade)
echo"#!$TERMUX_PREFIX/bin/bash" > preinst
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
echo"shopt -u extglob" >> preinst # disable extglob again just in case
echo"if [ -d $TERMUX_PREFIX/opt/texlive ]; then echo 'Removing residual files from old version of TeX Live for Termux'; rm -rf $PREFIX/opt/texlive; fi" >> preinst