Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tools/install-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,26 @@ TLINST="install-tl-unx.tar.gz"
TLURL=$TLREPO/$TLINST
PRNAME="tinytex.profile"
PRURL="https://tinytex.yihui.org"

# download a URL and save to its basename; pick curl or wget by availability
download_file() {
if command -v curl > /dev/null 2>&1; then
curl -L -f --retry 10 --retry-delay 30 -O "$1"
else
wget --tries=11 --waitretry=30 "$1"
fi
}

if [ $(uname) = 'Darwin' ]; then
alias sedi="sed -i ''"
[ -e $TLINST ] || curl -LO $TLURL
[ -e $PRNAME ] || curl -LO $PRURL/$PRNAME
else
alias sedi="sed -i"
[ -e $TLINST ] || wget $TLURL
[ -e $PRNAME ] || wget $PRURL/$PRNAME
fi

[ -e "$TLINST" ] || download_file "$TLURL"
[ -e "$PRNAME" ] || download_file "$PRURL/$PRNAME"

if [ $(uname) != 'Darwin' ]; then
# ask `tlmgr path add` to add binaries to ~/bin instead of the default
# /usr/local/bin unless this script is invoked with the argument '--admin'
# (e.g., users want to make LaTeX binaries available system-wide), in which
Expand Down
19 changes: 12 additions & 7 deletions tools/install-bin-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ is_musl() {
fi
}

# download URL to output file; pick curl or wget by availability
# $1 = URL, $2 = output file
download_file() {
if command -v curl > /dev/null 2>&1; then
curl -L -f --retry 10 --retry-delay 30 "$1" -o "$2"
else
wget --retry-connrefused --tries=11 --waitretry=30 --progress=dot:giga -O "$2" "$1"
fi
}

if [ $OSNAME = 'Darwin' ]; then
TEXDIR=${TINYTEX_DIR:-~/Library}/TinyTeX
else
Expand Down Expand Up @@ -94,19 +104,14 @@ fi

INSTALLER_FILE="${TINYTEX_INSTALLER}${OS_ARCH}.${EXT}"

download_file "${TINYTEX_URL}" "${INSTALLER_FILE}"
if [ "${TINYTEX_INSTALLER#"TinyTeX"}" != "$TINYTEX_INSTALLER" ]; then
# prebuilt TinyTeX bundle: download with platform-appropriate tool
if [ $OSNAME = 'Darwin' ]; then
curl -L -f --retry 10 --retry-delay 30 ${TINYTEX_URL} -o "${INSTALLER_FILE}"
else
wget --retry-connrefused --progress=dot:giga -O "${INSTALLER_FILE}" ${TINYTEX_URL}
fi
# prebuilt TinyTeX bundle
tar xf "${INSTALLER_FILE}" -C $(dirname $TEXDIR)
if [ -n "$1" ]; then mv "${INSTALLER_FILE}" "$1/"; else rm "${INSTALLER_FILE}"; fi
else
echo "We do not have a prebuilt TinyTeX package for this operating system ($(uname -s) $(uname -m))."
echo "I will try to install from source for you instead."
wget --retry-connrefused -O "${INSTALLER_FILE}" ${TINYTEX_URL}
tar xf "${INSTALLER_FILE}"
./install.sh
mkdir -p $TEXDIR
Expand Down
8 changes: 1 addition & 7 deletions tools/install-bin-windows.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
where /q powershell || echo PowerShell not found && exit /b

cd /d "%TEMP%"

powershell -ExecutionPolicy Bypass -Command "Invoke-WebRequest 'https://tinytex.yihui.org/install-bin-windows.ps1' -OutFile 'install-bin-windows.ps1'"
powershell -ExecutionPolicy Bypass -File "install-bin-windows.ps1" %*
del "install-bin-windows.ps1"
powershell -ExecutionPolicy Bypass -Command "irm 'https://tinytex.yihui.org/install-bin-windows.ps1' | iex"
16 changes: 15 additions & 1 deletion tools/install-bin-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
$ErrorActionPreference = 'Stop'

function Invoke-DownloadWithRetry {
param([string]$Uri, [string]$OutFile, [int]$MaxRetries = 10, [int]$RetryDelay = 30)
for ($i = 1; $i -le ($MaxRetries + 1); $i++) {
try {
Invoke-WebRequest $Uri -OutFile $OutFile
return
} catch {
if ($i -gt $MaxRetries) { throw }
Write-Host "Download failed (attempt $i of $($MaxRetries + 1)), retrying in $RetryDelay seconds..."
Start-Sleep -Seconds $RetryDelay
}
}
}

# switch to a temp directory
cd $env:TEMP
[Environment]::CurrentDirectory = $PWD.Path
Expand Down Expand Up @@ -39,7 +53,7 @@ $DownloadedFile = "$TinyTeXFilename.$BundleExt"

# download the bundle
Write-Host "Download $BundleExt file..."
Invoke-WebRequest $TinyTeXURL -OutFile $DownloadedFile
Invoke-DownloadWithRetry $TinyTeXURL $DownloadedFile

# unzip the downloaded file
Write-Host 'Unbundle TinyTeX'
Expand Down
8 changes: 6 additions & 2 deletions tools/install-unx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ cd ${TMPDIR:-/tmp}

if [ $(uname) = 'Darwin' ]; then
TEXDIR=${TINYTEX_DIR:-~/Library/TinyTeX}
alias download='curl -sL'
else
TEXDIR=${TINYTEX_DIR:-~/.TinyTeX}
alias download='wget -qO-'
fi

if command -v curl > /dev/null 2>&1; then
download() { curl -sL --retry 10 --retry-delay 30 "$1"; }
else
download() { wget -qO- --tries=11 --waitretry=30 "$1"; }
fi

rm -f install-tl-unx.tar.gz tinytex.profile
Expand Down
20 changes: 17 additions & 3 deletions tools/install-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
$ErrorActionPreference = 'Stop'

function Invoke-DownloadWithRetry {
param([string]$Uri, [string]$OutFile, [int]$MaxRetries = 10, [int]$RetryDelay = 30)
for ($i = 1; $i -le ($MaxRetries + 1); $i++) {
try {
Invoke-WebRequest $Uri -OutFile $OutFile
return
} catch {
if ($i -gt $MaxRetries) { throw }
Write-Host "Download failed (attempt $i of $($MaxRetries + 1)), retrying in $RetryDelay seconds..."
Start-Sleep -Seconds $RetryDelay
}
}
}

# switch to a temp directory
cd $env:TEMP
[Environment]::CurrentDirectory = $PWD.Path
Expand All @@ -11,18 +25,18 @@ $TLREPO = if ($env:CTAN_REPO) { $env:CTAN_REPO } else { 'https://tlnet.yihui.org
$TLURL = "$TLREPO/install-tl.zip"

# download install-tl.zip and unzip it
Invoke-WebRequest $TLURL -OutFile install-tl.zip
Invoke-DownloadWithRetry $TLURL install-tl.zip
Add-Type -A 'System.IO.Compression.FileSystem'
[IO.Compression.ZipFile]::ExtractToDirectory('install-tl.zip', '.')
del install-tl.zip

# download tinytex.profile and modify it (set texdir to ./TinyTeX)
Invoke-WebRequest 'https://tinytex.yihui.org/tinytex.profile' -OutFile tinytex.profile
Invoke-DownloadWithRetry 'https://tinytex.yihui.org/tinytex.profile' tinytex.profile
Add-Content tinytex.profile 'TEXMFCONFIG $TEXMFSYSCONFIG'
Add-Content tinytex.profile 'TEXMFVAR $TEXMFSYSVAR'

# download the custom package list
Invoke-WebRequest 'https://tinytex.yihui.org/pkgs-custom.txt' -OutFile pkgs-custom.txt
Invoke-DownloadWithRetry 'https://tinytex.yihui.org/pkgs-custom.txt' pkgs-custom.txt

# an automated installation of TeX Live (infrastructure only)
cd install-tl-*
Expand Down
Loading