From 78f9e08b8a507e807d054ac3b2df3512a6f2d2a1 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Thu, 16 Jun 2022 16:31:18 +0900 Subject: [PATCH 01/14] Add symlink --- install_texlive/__main__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 37bb128..4399ca6 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -14,7 +14,7 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger('install_texlive') -timeout = 30 +timeout = 60 def main(): @@ -107,6 +107,13 @@ def main(): version = re.findall(r'20[0-9][0-9]', bindir)[0] env = os.environ env['PATH'] = os.path.abspath(bindir) + ':' + env['PATH'] + linkpath = '{}'.format(args.prefix or '/usr/local/texlive') + '/bin' + try: + os.symlink(bindir, linkpath) + except FileExistsError: + os.remove(linkpath) + os.symlink(bindir, linkpath) + if args.version is not None and not is_current(args.version): repo = OLDURL.format(v=version) From 8e4d7c4fde88cd0026fb9dec41165010ee51b393 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Thu, 16 Jun 2022 16:52:48 +0900 Subject: [PATCH 02/14] Add --link option --- install_texlive/__main__.py | 15 ++++++++------- install_texlive/parser.py | 4 ++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 4399ca6..d0f9abe 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -107,13 +107,6 @@ def main(): version = re.findall(r'20[0-9][0-9]', bindir)[0] env = os.environ env['PATH'] = os.path.abspath(bindir) + ':' + env['PATH'] - linkpath = '{}'.format(args.prefix or '/usr/local/texlive') + '/bin' - try: - os.symlink(bindir, linkpath) - except FileExistsError: - os.remove(linkpath) - os.symlink(bindir, linkpath) - if args.version is not None and not is_current(args.version): repo = OLDURL.format(v=version) @@ -149,6 +142,14 @@ def main(): sp.run(['tlmgr', 'install', *additional_packages], env=env, check=True) log.info('Finished') + if args.link: + linkpath = '{}'.format(args.prefix or '/usr/local/texlive') + '/bin' + try: + os.symlink(bindir, linkpath) + except FileExistsError: + os.remove(linkpath) + os.symlink(bindir, linkpath) + if __name__ == '__main__': main() diff --git a/install_texlive/parser.py b/install_texlive/parser.py index d388096..d5afcdf 100644 --- a/install_texlive/parser.py +++ b/install_texlive/parser.py @@ -66,3 +66,7 @@ '--docs', action='store_true', help='Install the docs tree', ) +parser.add_argument( + '--link', action='store_true', + help='Add symbolic link: args.prefix/bin', +) From 4f817278d7b5f11844657449843154f851125634 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Wed, 29 Jun 2022 16:56:10 +0900 Subject: [PATCH 03/14] Update timeout parameter --- install_texlive/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index d0f9abe..99bf6c0 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -14,7 +14,7 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger('install_texlive') -timeout = 60 +timeout = 120 def main(): From 47def37bcc02baec8b5bff3e411a922825b9621c Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Mon, 18 Jul 2022 17:43:50 +0900 Subject: [PATCH 04/14] Update timeout values --- install_texlive/__main__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 99bf6c0..1527b0a 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -50,12 +50,13 @@ def main(): tl = pexpect.spawn(cmd, timeout=timeout) try: - command(tl, 'installation.profile', 'N', timeout=5) + command(tl, 'installation.profile', 'N', timeout=timeout) except pexpect.TIMEOUT: pass try: - command(tl, 'Import settings', 'y' if args.keep_config else 'n', timeout=5) + command(tl, 'Import settings', 'y' if args.keep_config else 'n', + timeout=timeout) except pexpect.TIMEOUT: log.info('No previous installation found') From 9d73cdf2832d7df18221f06f26c6a3b9f213e0d4 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 07:34:44 +0900 Subject: [PATCH 05/14] Fix EOF error --- install_texlive/__main__.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 1527b0a..11db18e 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -9,6 +9,7 @@ from . import command, download, URL, OLDURL, get_size, is_current from .parser import parser +from pudb import set_trace logging.basicConfig(level=logging.INFO) @@ -47,12 +48,19 @@ def main(): log.info(cmd) - tl = pexpect.spawn(cmd, timeout=timeout) + set_trace() + while True: + tl = pexpect.spawn(cmd, timeout=timeout) - try: - command(tl, 'installation.profile', 'N', timeout=timeout) - except pexpect.TIMEOUT: - pass + try: + command(tl, 'installation.profile', 'N', timeout=timeout) + except pexpect.TIMEOUT: + pass + except pexpect.exceptions.EOF: + print('Wrong URL, restart installation') + continue + else: + break try: command(tl, 'Import settings', 'y' if args.keep_config else 'n', From e4d7d26f707623ab941ee8b818eb07ac34d4b068 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 10:37:57 +0900 Subject: [PATCH 06/14] Update __main__.py repeat installation when error occured --- install_texlive/__main__.py | 212 ++++++++++++++++++++---------------- 1 file changed, 117 insertions(+), 95 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 11db18e..651597a 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -15,7 +15,7 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger('install_texlive') -timeout = 120 +timeout = 30 def main(): @@ -48,116 +48,138 @@ def main(): log.info(cmd) - set_trace() while True: + log.info('Install texlive') tl = pexpect.spawn(cmd, timeout=timeout) try: command(tl, 'installation.profile', 'N', timeout=timeout) except pexpect.TIMEOUT: - pass + log.info('No installation profile') except pexpect.exceptions.EOF: - print('Wrong URL, restart installation') + log.error('Wrong URL, restart installation') + tl.close() continue + + try: + command(tl, 'Import settings', 'y' if args.keep_config else 'n', + timeout=timeout) + except pexpect.TIMEOUT: + log.info('No previous installation found') + except pexpect.exceptions.EOF: + log.error('Wrong URL, restart installation') + tl.close() + continue + + try: + if args.scheme: + command(tl, 'Enter command:', 'S', timeout=timeout) + command(tl, 'Enter letter', args.scheme, timeout=timeout) + command(tl, 'Enter letter', 'R', timeout=timeout) + + if args.collections: + command(tl, 'Enter command:', 'C', timeout=timeout) + command(tl, 'Enter letter', args.collections, timeout=timeout) + command(tl, 'Enter letter', 'R', timeout=timeout) + + if not args.docs: + command(tl, 'Enter command:', 'O', timeout=timeout) + command(tl, 'Enter command:', 'D', timeout=timeout) + command(tl, 'Enter command:', 'R', timeout=timeout) + + if not args.source: + command(tl, 'Enter command:', 'O', timeout=timeout) + command(tl, 'Enter command:', 'S', timeout=timeout) + command(tl, 'Enter command:', 'R', timeout=timeout) + + log.info('Installation size will be {}'.format(get_size(tl))) + log.info('Starting installation') + command(tl, 'Enter command:', 'I', timeout=timeout) + except pexpect.TIMEOUT: + log.error('Something went wrong, install time out') + tl.close() + continue + except pexpect.exceptions.EOF: + log.error('Wrong URL, restart installation') + tl.close() + continue + + lines = '' + try: + while not tl.terminated: + line = tl.readline().decode() + log.debug(line.strip()) + lines += line + except pexpect.EOF: + log.error('line EOF') + tl.close() + continue + except pexpect.TIMEOUT: + log.error('Something went wrong, readline time out') + tl.close() + continue + except pexpect.exceptions.EOF: + log.error('line EOF') + tl.close() + continue + + tl.close() + if tl.exitstatus == 0: + log.info('Installation installed succesfully') else: - break - - try: - command(tl, 'Import settings', 'y' if args.keep_config else 'n', - timeout=timeout) - except pexpect.TIMEOUT: - log.info('No previous installation found') - - try: - if args.scheme: - command(tl, 'Enter command:', 'S', timeout=timeout) - command(tl, 'Enter letter', args.scheme, timeout=timeout) - command(tl, 'Enter letter', 'R', timeout=timeout) - - if args.collections: - command(tl, 'Enter command:', 'C', timeout=timeout) - command(tl, 'Enter letter', args.collections, timeout=timeout) - command(tl, 'Enter letter', 'R', timeout=timeout) - - if not args.docs: - command(tl, 'Enter command:', 'O', timeout=timeout) - command(tl, 'Enter command:', 'D', timeout=timeout) - command(tl, 'Enter command:', 'R', timeout=timeout) - - if not args.source: - command(tl, 'Enter command:', 'O', timeout=timeout) - command(tl, 'Enter command:', 'S', timeout=timeout) - command(tl, 'Enter command:', 'R', timeout=timeout) - - log.info('Installation size will be {}'.format(get_size(tl))) - log.info('Starting installation') - command(tl, 'Enter command:', 'I', timeout=timeout) - except pexpect.TIMEOUT: - log.error('Something went wrong') - sys.exit(1) - - lines = '' - try: - while not tl.terminated: - line = tl.readline().decode() - log.debug(line.strip()) - lines += line - except pexpect.EOF: - log.error('EOF') - - tl.close() - if tl.exitstatus == 0: - log.info('Installation installed succesfully') - else: - log.error('Installation did not finish succesfully') - sys.exit(tl.exitstatus) + log.error('Installation did not finish succesfully') + tl.close() + continue - bindir = re.findall(r'Most importantly, add\s+(.*)\s+to your PATH', lines)[0].strip() - version = re.findall(r'20[0-9][0-9]', bindir)[0] - env = os.environ - env['PATH'] = os.path.abspath(bindir) + ':' + env['PATH'] + bindir = re.findall(r'Most importantly, add\s+(.*)\s+to your PATH', lines)[0].strip() + version = re.findall(r'20[0-9][0-9]', bindir)[0] + env = os.environ + env['PATH'] = os.path.abspath(bindir) + ':' + env['PATH'] - if args.version is not None and not is_current(args.version): - repo = OLDURL.format(v=version) - else: - repo = URL - sp.run( - ['tlmgr', 'option', 'repository', repo], - env=env, - check=True, - ) - - if args.update: - log.info('Start updating') + if args.version is not None and not is_current(args.version): + repo = OLDURL.format(v=version) + else: + repo = URL sp.run( - ['tlmgr', 'update', '--self', '--all', '--reinstall-forcibly-removed'], + ['tlmgr', 'option', 'repository', repo], env=env, check=True, ) - log.info('Finished') - - additional_packages = [] - if args.install: - additional_packages.extend(args.install.split(',')) - if args.package_file: - with open(args.package_file, 'r') as f: - additional_packages.extend(f.read().splitlines()) - - if additional_packages: - log.info('Start installing addtional packages') - # tlmgr must always be up to date to install packages - sp.run(['tlmgr', 'update', '--self'], env=env, check=True) - sp.run(['tlmgr', 'install', *additional_packages], env=env, check=True) - log.info('Finished') - - if args.link: - linkpath = '{}'.format(args.prefix or '/usr/local/texlive') + '/bin' - try: - os.symlink(bindir, linkpath) - except FileExistsError: - os.remove(linkpath) - os.symlink(bindir, linkpath) + if args.update: + log.info('Start updating') + sp.run( + ['tlmgr', 'update', '--self', '--all', '--reinstall-forcibly-removed'], + env=env, + check=True, + ) + log.info('Finished') + + additional_packages = [] + if args.install: + additional_packages.extend(args.install.split(',')) + + if args.package_file: + with open(args.package_file, 'r') as f: + additional_packages.extend(f.read().splitlines()) + + if additional_packages: + log.info('Start installing addtional packages') + # tlmgr must always be up to date to install packages + sp.run(['tlmgr', 'update', '--self'], env=env, check=True) + sp.run(['tlmgr', 'install', *additional_packages], env=env, check=True) + log.info('Finished') + + if args.link: + linkpath = '{}'.format(args.prefix or '/usr/local/texlive') + '/bin' + try: + os.symlink(bindir, linkpath) + except FileExistsError: + os.remove(linkpath) + os.symlink(bindir, linkpath) + finally: + log.info('Link finished') + break if __name__ == '__main__': From dfe173102e9f2a776e7d7a43feda893d94a2ff85 Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 11:06:58 +0900 Subject: [PATCH 07/14] Remove pudb dependency --- install_texlive/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 651597a..95e617e 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -9,7 +9,6 @@ from . import command, download, URL, OLDURL, get_size, is_current from .parser import parser -from pudb import set_trace logging.basicConfig(level=logging.INFO) From b624164ba9b83e5e614837562942bd4fba3e6cdf Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 11:43:17 +0900 Subject: [PATCH 08/14] Add prefix dir deletion code Update timeout value --- install_texlive/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 95e617e..6f0e517 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -14,7 +14,7 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger('install_texlive') -timeout = 30 +timeout = 60 def main(): @@ -97,10 +97,12 @@ def main(): except pexpect.TIMEOUT: log.error('Something went wrong, install time out') tl.close() + shutil.rmtree(args.prefix) continue except pexpect.exceptions.EOF: log.error('Wrong URL, restart installation') tl.close() + shutil.rmtree(args.prefix) continue lines = '' @@ -112,14 +114,17 @@ def main(): except pexpect.EOF: log.error('line EOF') tl.close() + shutil.rmtree(args.prefix) continue except pexpect.TIMEOUT: log.error('Something went wrong, readline time out') tl.close() + shutil.rmtree(args.prefix) continue except pexpect.exceptions.EOF: log.error('line EOF') tl.close() + shutil.rmtree(args.prefix) continue tl.close() @@ -128,6 +133,7 @@ def main(): else: log.error('Installation did not finish succesfully') tl.close() + shutil.rmtree(args.prefix) continue bindir = re.findall(r'Most importantly, add\s+(.*)\s+to your PATH', lines)[0].strip() From 05ae8b8e4e98983d46accd1e8bc2ef07dd382f8b Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 12:23:35 +0900 Subject: [PATCH 09/14] Fix make prefix directory codes --- install_texlive/__main__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 6f0e517..ffd4b35 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -23,13 +23,6 @@ def main(): if args.verbose: log.level = logging.DEBUG - if args.prefix: - args.prefix = os.path.abspath(args.prefix) - os.environ['TEXLIVE_INSTALL_PREFIX'] = args.prefix - os.makedirs(args.prefix, exist_ok=True) - - log.info('Installing texlive to {}'.format(args.prefix or '/usr/local/texlive')) - if args.install_tl: install_script = args.install_tl cmd = install_script @@ -45,12 +38,19 @@ def main(): else: cmd = install_script + ' --repository=' + OLDURL.format(v=args.version) - log.info(cmd) - while True: log.info('Install texlive') + tl = pexpect.spawn(cmd, timeout=timeout) + if args.prefix: + args.prefix = os.path.abspath(args.prefix) + os.environ['TEXLIVE_INSTALL_PREFIX'] = args.prefix + os.makedirs(args.prefix, exist_ok=True) + + log.info('Installing texlive to {}'.format(args.prefix or '/usr/local/texlive')) + log.info(cmd) + try: command(tl, 'installation.profile', 'N', timeout=timeout) except pexpect.TIMEOUT: From 2a4698f839174807a0685640a4d32e19b8c1ad9e Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 12:30:44 +0900 Subject: [PATCH 10/14] Fix import error for shutil Add "import shutil" code line --- install_texlive/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index ffd4b35..fc1582c 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -4,6 +4,7 @@ import sys import logging import tempfile +import shutil import re import subprocess as sp From 6ac9436cf1c64214ff21784bfa9586eff194a2ca Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Tue, 19 Jul 2022 13:02:03 +0900 Subject: [PATCH 11/14] Update timeout for configure check Change from timeout to 5 --- install_texlive/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index fc1582c..7d010da 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -53,7 +53,7 @@ def main(): log.info(cmd) try: - command(tl, 'installation.profile', 'N', timeout=timeout) + command(tl, 'installation.profile', 'N', timeout=5) except pexpect.TIMEOUT: log.info('No installation profile') except pexpect.exceptions.EOF: @@ -63,7 +63,7 @@ def main(): try: command(tl, 'Import settings', 'y' if args.keep_config else 'n', - timeout=timeout) + timeout=5) except pexpect.TIMEOUT: log.info('No previous installation found') except pexpect.exceptions.EOF: From 02dfbca7d98114b58c8838b813b3ca4627e9ca2a Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Wed, 14 Sep 2022 10:38:35 +0900 Subject: [PATCH 12/14] Add timeout+=100 before every loop --- install_texlive/__main__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 7d010da..d45c064 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -59,6 +59,7 @@ def main(): except pexpect.exceptions.EOF: log.error('Wrong URL, restart installation') tl.close() + timeout += 100 continue try: @@ -69,6 +70,7 @@ def main(): except pexpect.exceptions.EOF: log.error('Wrong URL, restart installation') tl.close() + timeout += 100 continue try: @@ -99,11 +101,13 @@ def main(): log.error('Something went wrong, install time out') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue except pexpect.exceptions.EOF: log.error('Wrong URL, restart installation') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue lines = '' @@ -116,16 +120,19 @@ def main(): log.error('line EOF') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue except pexpect.TIMEOUT: log.error('Something went wrong, readline time out') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue except pexpect.exceptions.EOF: log.error('line EOF') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue tl.close() @@ -135,6 +142,7 @@ def main(): log.error('Installation did not finish succesfully') tl.close() shutil.rmtree(args.prefix) + timeout += 100 continue bindir = re.findall(r'Most importantly, add\s+(.*)\s+to your PATH', lines)[0].strip() From 073739ed0a66c39b2e6496ab947455ac0111dbcf Mon Sep 17 00:00:00 2001 From: Jeunghun Kim Date: Sat, 17 Sep 2022 00:24:21 +0900 Subject: [PATCH 13/14] Refactor timeout as local variable --- install_texlive/__main__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index d45c064..4e018d9 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -15,10 +15,8 @@ logging.basicConfig(level=logging.INFO) log = logging.getLogger('install_texlive') -timeout = 60 - -def main(): +def main(timeout=60): args = parser.parse_args() if args.verbose: From 2ef0e89c9fbe3b72a6e45192631b797b6a5bed0a Mon Sep 17 00:00:00 2001 From: JeunghunKim Date: Sat, 6 May 2023 17:36:39 +0900 Subject: [PATCH 14/14] Update __main__.py Update timeout --- install_texlive/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_texlive/__main__.py b/install_texlive/__main__.py index 4e018d9..298209a 100644 --- a/install_texlive/__main__.py +++ b/install_texlive/__main__.py @@ -16,7 +16,7 @@ log = logging.getLogger('install_texlive') -def main(timeout=60): +def main(timeout=3600): args = parser.parse_args() if args.verbose: