diff --git a/.drone.yml b/.drone.yml index 4dd6ca9..374f5d9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -63,9 +63,9 @@ steps: image: ubuntu commands: - apt update && apt install -y curl perl - - echo $PATH - export PATH=$HOME/texlive/bin/x86_64-linux:$HOME/texlive/bin/aarch64-linux:$PATH - ./ci/install-texlive + - xargs tlmgr install < texlive-2023.deps - latexmk sbabook - latexmk sbabook.bod - latexmk sbabook.spiral @@ -92,9 +92,9 @@ steps: image: ubuntu commands: - apt update && apt install -y curl perl - - echo $PATH - export PATH=$HOME/texlive/bin/x86_64-linux:$HOME/texlive/bin/aarch64-linux:$PATH - ./ci/install-texlive + - xargs tlmgr install < texlive.deps - latexmk sbabook - latexmk sbabook.bod - latexmk sbabook.spiral diff --git a/ci/install-texlive b/ci/install-texlive index 65dfc02..eca7fca 100755 --- a/ci/install-texlive +++ b/ci/install-texlive @@ -4,6 +4,8 @@ trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR IFS=$'\n\t' # preamble from https://disconnected.systems/blog/another-bash-strict-mode/ +: "${TEXLIVE_TARBALL:=install-tl-unx.tar.gz}" + function die() { echo "$@" >&2 exit 1 @@ -11,42 +13,27 @@ function die() { function texlive-repo() { [[ $# -eq 1 ]] || die "${FUNCNAME[0]}: No release specified (YYYY or rolling)" - local release="$1" + local release="$1" url if [[ "$release" = rolling ]]; then - echo 'http://mirror.ctan.org/systems/texlive/tlnet' + url='http://mirror.ctan.org/systems/texlive/tlnet' else [[ "$release" = [0-9][0-9][0-9][0-9] ]] || die "${FUNCNAME[0]}: incorrect release '$release'" - echo "https://ftp.tu-chemnitz.de/pub/tug/historic/systems/texlive/${release}/tlnet-final/" + url="https://ftp.tu-chemnitz.de/pub/tug/historic/systems/texlive/${release}/tlnet-final/" # the rolling release is missing the shasum, and the tlnet directory # US mirror: http://ftp.math.utah.edu/pub/tex/historic/systems/texlive/${release}/ fi -} - -function deps-file() { - if [[ "$1" = [0-9][0-9][0-9][0-9] ]]; then - echo "texlive-$1.deps" - else - echo texlive.deps - fi -} -function texlive-release() { - tlmgr --version \ - | grep 'TeX Live .*version' \ - | grep --only-matching '\d\d\d\d' + # resolve possible mirror to fixed URL + curl -LIs -o /dev/null -w '%{url_effective}' "$url" } -# Ensure meaningful default values for required environment variables. -# Override the full repository URL or set TEXLIVE_RELEASE to pick that year's frozen release. -# Defaults to the current rolling release. -: "${TEXLIVE_RELEASE:=rolling}" -: "${TEXLIVE_REPOSITORY:="$(texlive-repo "$TEXLIVE_RELEASE")"}" -: "${TEXLIVE_TARBALL:=install-tl-unx.tar.gz}" - function get-texlive-installer() { + [[ $# -eq 1 ]] || die "Usage: ${FUNCNAME[0]} texlive-repo-url" + local repo="$1" + # download, checksum, extract - curl --silent --location --remote-name-all "${TEXLIVE_REPOSITORY}/${TEXLIVE_TARBALL}"{,.sha512} + curl --silent --location --remote-name-all "${repo}/${TEXLIVE_TARBALL}"{,.sha512} sha512sum --check "${TEXLIVE_TARBALL}.sha512" tar --extract --gzip --file "${TEXLIVE_TARBALL}" } @@ -83,11 +70,14 @@ EOF } function install-texlive() { + [[ $# -eq 2 ]] || die "Usage: ${FUNCNAME[0]} (YYYY | rolling) texlive-repository-url" + local release="$1" repo="$2" + echo "Downloading TeXlive..." - echo " release $TEXLIVE_RELEASE" - echo " from $TEXLIVE_REPOSITORY" + echo " release ${release}" + echo " from ${repo}" - get-texlive-installer + get-texlive-installer "$repo" # find installer path from archive listing, sanity check local installer @@ -95,18 +85,20 @@ function install-texlive() { [[ -x "$installer" ]] || die "can not find TeXlive installer at ${installer}"; texlive-profile >> texlive.profile - "$installer" --repository "$TEXLIVE_REPOSITORY" --profile texlive.profile -} + "$installer" --repository "$repo" --profile texlive.profile + tlmgr option repository "$repo" -function install-deps() { tlmgr update --self --all tlmgr install latex-bin latexmk - xargs tlmgr install < "$(deps-file "$TEXLIVE_RELEASE")" } # Only call the main function if this script was called as a command. This makes # it possible to source this script as a library. if [[ ${BASH_SOURCE[0]} == "$0" ]]; then - install-texlive - install-deps + # Override the full repository URL or set TEXLIVE_RELEASE to pick that year's frozen release. + # Defaults to the current rolling release. + release="${1:-${TEXLIVE_RELEASE:-rolling}}" + repo="${2:-${TEXLIVE_REPOSITORY:-$(texlive-repo "$release")}}" + + install-texlive "$release" "$repo" fi diff --git a/ci/list-deps b/ci/list-deps index 58072d2..25dd1b8 100755 --- a/ci/list-deps +++ b/ci/list-deps @@ -30,6 +30,11 @@ function info { printf "\n" 1>&2 } +function texlive-release() { + tlmgr --version \ + | sed '/^tlmgr/d ; s/.*version //' +} + function filter-inputs { sed -e '\#^INPUT '"$PREFIX"'/texmf-dist#!d' \ -e 's#^INPUT '"$PREFIX"'/##' \