/
install-texlive.sh
executable file
·113 lines (97 loc) · 3.16 KB
/
install-texlive.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
# NOTE TO MAINTAINERS: this must be updated each time a new texlive is
# released!
default_version=2024
tlversion=${1:-"$default_version"}
installer_archive=install-tl-unx.tar.gz
usage ()
{
printf 'Install TeXLive\n'
printf 'Usage: %s [OPTIONS]\n\n' "$0"
printf 'Options:\n'
printf ' -t: TeXLive version (default %s)\n' "$default_version"
printf ' -m: mirror URL\n'
}
if ! args=$(getopt 't:m:' "$@"); then
usage && exit 1
fi
# The variable is intentionally left unquoted.
# shellcheck disable=SC2086
set -- $args
tlversion=
mirror_url=
while true; do
case "$1" in
(-t)
tlversion="${2}"
shift 2
;;
(-m)
mirror_url="${2}"
shift 2
;;
(--)
shift
break
;;
(*)
printf 'Unknown option: %s\n' "$1"
usage
exit 1
;;
esac
done
[ -n "$tlversion" ] || tlversion="$default_version"
if [ -z "$mirror_url" ] && [ "$tlversion" != "$default_version" ]; then
# Default mirror for historic releases
mirror_url="ftp://tug.org/historic/"
fi
if [ -z "$mirror_url" ]; then
# Get the mirror URL from the redirect. Otherwise, if we were to
# always use the mirror URL, we'd run into problems whenever we get
# installer and signatures from different mirrors that are not 100%
# in sync.
mirror_url=$(wget -4 --quiet --output-document=/dev/null \
--server-response \
http://mirror.ctan.org/ \
2>&1 | \
sed -ne 's/.*Location: \(.*\)$/\1/p' | head -n 1)
fi
# Trim trailing slash(es)
mirror_url=$(echo "$mirror_url" | sed -e 's/\/*$//')
if [ "$tlversion" = "$default_version" ]; then
installer_url="$mirror_url/systems/texlive/tlnet/"
repository=
else
installer_url="$mirror_url/systems/texlive/$tlversion/tlnet-final/"
repository=$installer_url
fi
# Log the installer and repository url
printf 'installer URL: %s\n' "${installer_url}"
printf 'repository: %s\n' "${repository}"
# Download the install-tl perl script. The archive integrity and signature is
# verified later, so it's ok if we use an insecure connection.
wget -4 --no-verbose --no-check-certificate \
"$installer_url/$installer_archive" \
"$installer_url/$installer_archive".sha512 \
"$installer_url/$installer_archive".sha512.asc \
|| exit 1
## Verifiy installer integrity
# get current signing key
gpg --keyserver keyserver.ubuntu.com \
--receive-key 0xC78B82D8C79512F79CC0D7C80D5E5D9106BAB6BC || exit 5
gpg --verify "$installer_archive".sha512.asc || exit 5
sha512sum "$installer_archive".sha512 || exit 5
## Proceed with installation
# Extract installer
mkdir -p ./install-tl
tar --strip-components 1 -zvxf "$installer_archive" -C "$PWD/install-tl" \
|| exit 1
# Run the default installation with the specified profile.
./install-tl/install-tl ${repository:+-repository "$repository"} \
--profile=/root/texlive.profile
# Cleanup installation artifacts.
rm -rf ./install-tl \
"$installer_archive" \
"$installer_archive.sha512" \
"$installer_archive.sha512.asc"