Skip to content

Commit

Permalink
Add option to set repository
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Dec 13, 2023
1 parent e902436 commit 0125025
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 3 additions & 2 deletions install_texlive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def is_current(version):
return current_version == version


def download(version=None, outdir='.'):
def download(version=None, outdir='.', url=None):
os.makedirs(outdir, exist_ok=True)

if version is None or is_current(version):
url = URL + 'install-tl-unx.tar.gz'
url = url or URL
url = url.rstrip("/") + '/install-tl-unx.tar.gz'
else:
url = OLDURL.format(v=version) + 'install-tl-unx.tar.gz'

Expand Down
8 changes: 6 additions & 2 deletions install_texlive/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
import subprocess as sp

from . import command, download, URL, OLDURL, get_size, is_current
from . import command, download, OLDURL, get_size, is_current
from .parser import parser


Expand All @@ -28,6 +28,7 @@ def main():
os.environ['TEXLIVE_INSTALL_PREFIX'] = args.prefix
os.makedirs(args.prefix, exist_ok=True)

os.environ["TEXLIVE_INSTALL_ENV_NOCHECK"] = "1"
log.info('Installing texlive to {}'.format(args.prefix or '/usr/local/texlive'))

if args.install_tl:
Expand All @@ -37,7 +38,7 @@ def main():
directory = os.path.join(
tempfile.gettempdir(), 'texlive-{}'.format(args.version or 'current')
)
download(version=args.version, outdir=directory)
download(version=args.version, outdir=directory, url=args.repository)
install_script = glob(os.path.join(directory, 'install-tl-*/install-tl'))[-1]

if args.version is None or is_current(args.version):
Expand Down Expand Up @@ -108,9 +109,12 @@ def main():
env = os.environ
env['PATH'] = os.path.abspath(bindir) + ':' + env['PATH']

repo = args.repository
if args.version is not None and not is_current(args.version):
repo = OLDURL.format(v=version)

if repo is not None:
log.info("Setting repository to %s", repo)
sp.run(
['tlmgr', 'option', 'repository', repo],
env=env,
Expand Down
5 changes: 5 additions & 0 deletions install_texlive/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@
'--docs', action='store_true',
help='Install the docs tree',
)

parser.add_argument(
"-r", "--repository",
help="If given, set ctan mirror to this URL.",
)

0 comments on commit 0125025

Please sign in to comment.