Created
March 25, 2017 21:26
-
-
Save SHaTRO/94abc51bf4ec07bc421b347c0461b4b4 to your computer and use it in GitHub Desktop.
Bash script for auto-magical installation of TeXLive on Cygwin 64-bit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ### | |
| # This script downloads and installs TeXLive on Cygwin | |
| # In my environment, the full install takes about 3 hours. | |
| # | |
| # No effort is made here to check mirror speeds or properly select a mirror, so improvement there is welcome. | |
| ### | |
| ## PRIMARY CONFIGURATION ## | |
| # Note that TL_DISTRO is overwritten by the installation function | |
| TL_DISTRO=2016 | |
| TL_PROFILE_D_TARGET=/etc/profile.d/texlive.sh | |
| TL_INSTALL_PROFILE=/tmp/texlive.profile | |
| TL_SRC_DIR=/usr/local/src | |
| TL_SRC_FILENAME=install-tl-unx.tar.gz | |
| TL_SRC_URL=http://mirror.ctan.org/systems/texlive/tlnet/${TL_SRC_FILENAME} | |
| ## FUNCTION DECLARATIONS ## | |
| cw_tl_post_install() { | |
| local DISTRO=${1} | |
| local TARGET=${2} | |
| local TLBIN=$(find "/usr/local/texlive/${DISTRO}/bin/"* -type d) | |
| if [ ! -x ${PROFILE_FILE} ]; then | |
| echo "Adding the TeXLive bin/ to PATH in profile.d (${TARGET})." | |
| cat > "${TARGET}" << EOF | |
| TL_DISTRO="${DISTRO}" | |
| TL_BIN="${TLBIN}" | |
| if [ -d "\${TL_BIN}" ]; then | |
| PATH="\${TL_BIN}:\${PATH}" | |
| fi | |
| export PATH | |
| EOF | |
| chmod +x "${TARGET}" | |
| else | |
| echo "Not modifying (${TARGET}) in profile.d." | |
| echo "Be sure your PATH includes:" | |
| echo " ${TLBIN}" | |
| fi | |
| } | |
| cw_tl_pre_install() { | |
| local PROFILE_FILE=${1} | |
| if [ ! -x ${PROFILE_FILE} ]; then | |
| echo "Creating TeXLive installation profile (${PROFILE_FILE})." | |
| cat > "${PROFILE_FILE}" << EOF | |
| # texlive.profile written on Sat Mar 25 07:31:45 2017 UTC | |
| # It will NOT be updated and reflects only the | |
| # installation profile at installation time. | |
| selected_scheme scheme-full | |
| TEXDIR /usr/local/texlive/2016 | |
| TEXMFCONFIG ~/.texlive2016/texmf-config | |
| TEXMFHOME ~/texmf | |
| TEXMFLOCAL /usr/local/texlive/texmf-local | |
| TEXMFSYSCONFIG /usr/local/texlive/2016/texmf-config | |
| TEXMFSYSVAR /usr/local/texlive/2016/texmf-var | |
| TEXMFVAR ~/.texlive2016/texmf-var | |
| binary_x86_64-cygwin 1 | |
| collection-basic 1 | |
| collection-bibtexextra 1 | |
| collection-binextra 1 | |
| collection-context 1 | |
| collection-fontsextra 1 | |
| collection-fontsrecommended 1 | |
| collection-fontutils 1 | |
| collection-formatsextra 1 | |
| collection-games 1 | |
| collection-genericextra 1 | |
| collection-genericrecommended 1 | |
| collection-htmlxml 1 | |
| collection-humanities 1 | |
| collection-langafrican 1 | |
| collection-langarabic 1 | |
| collection-langchinese 1 | |
| collection-langcjk 1 | |
| collection-langcyrillic 1 | |
| collection-langczechslovak 1 | |
| collection-langenglish 1 | |
| collection-langeuropean 1 | |
| collection-langfrench 1 | |
| collection-langgerman 1 | |
| collection-langgreek 1 | |
| collection-langindic 1 | |
| collection-langitalian 1 | |
| collection-langjapanese 1 | |
| collection-langkorean 1 | |
| collection-langother 1 | |
| collection-langpolish 1 | |
| collection-langportuguese 1 | |
| collection-langspanish 1 | |
| collection-latex 1 | |
| collection-latexextra 1 | |
| collection-latexrecommended 1 | |
| collection-luatex 1 | |
| collection-mathscience 1 | |
| collection-metapost 1 | |
| collection-music 1 | |
| collection-omega 1 | |
| collection-pictures 1 | |
| collection-plainextra 1 | |
| collection-pstricks 1 | |
| collection-publishers 1 | |
| collection-texworks 1 | |
| collection-xetex 1 | |
| in_place 0 | |
| option_adjustrepo 1 | |
| option_autobackup 1 | |
| option_backupdir tlpkg/backups | |
| option_desktop_integration 1 | |
| option_doc 1 | |
| option_file_assocs 1 | |
| option_fmt 1 | |
| option_letter 1 | |
| option_menu_integration 1 | |
| option_path 0 | |
| option_post_code 1 | |
| option_src 1 | |
| option_sys_bin /usr/local/bin | |
| option_sys_info /usr/local/share/info | |
| option_sys_man /usr/local/share/man | |
| option_w32_multi_user 1 | |
| option_write18_restricted 1 | |
| portable 0 | |
| EOF | |
| else | |
| echo "Using existing TeXLive installation profile (${PROFILE_FILE})." | |
| fi | |
| } | |
| cw_tl_install() { | |
| local SRCLOC=${1} | |
| local SRCURL=${2} | |
| local SRCFN=${3} | |
| local PROFILE=${4} | |
| local INSTDIR=/usr/local/install-tl-20* | |
| mkdir -p "${SRCLOC}" | |
| cd "${SRCLOC}" | |
| echo "Downloading ${SRCURL}..." | |
| wget "${SRCURL}" | |
| if [ -f "${SRCFN}" ]; then | |
| echo "Unpacking ${SRCFN}..." | |
| tar zxvf "${SRCFN}" | |
| INSTDIR=$(find ./ -name "install-tl-*" -type d | sort -r | head -1) | |
| cd ${INSTDIR} | |
| TL_DISTRO=$(./install-tl --version | grep " version " | sed 's/.*version //') | |
| echo "Installing TeXLive version ${TL_DISTRO}..." | |
| ./install-tl --profile="${PROFILE}" | |
| else | |
| echo "Failed to download ${SRCFN} from ${SRCURL}" >&2 | |
| exit 3 | |
| fi | |
| } | |
| ## NOW MAIN EXECUTION ## | |
| echo "Pre-installation of TeXLive..." | |
| cw_tl_pre_install "${TL_INSTALL_PROFILE}" | |
| echo "Installation of TeXLive..." | |
| cw_tl_install "${TL_SRC_DIR}" "${TL_SRC_URL}" "${TL_SRC_FILENAME}" "${TL_INSTALL_PROFILE}" | |
| echo "Post-installation of TeXLive..." | |
| cw_tl_post_install "${TL_DISTRO}" "${TL_PROFILE_D_TARGET}" | |
| echo "Done installing TeXLive ${TL_DISTRO}." | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I know this says Cygwin, but it will work on pretty much any Linux distro that supports /etc/profile.d
Note that mirror selection is default, which isn't ideal. This could be modified for that.