From ec2d4c07b31f82942feb5ad3bb39b6c6f822952e Mon Sep 17 00:00:00 2001 From: Olivier Cessenat Date: Fri, 25 Jun 2021 09:25:18 +0200 Subject: [PATCH] texlive: add support for external find (#24460) --- .../repos/builtin/packages/texlive/package.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/var/spack/repos/builtin/packages/texlive/package.py b/var/spack/repos/builtin/packages/texlive/package.py index a5fd6b8261..6bb46dc75c 100644 --- a/var/spack/repos/builtin/packages/texlive/package.py +++ b/var/spack/repos/builtin/packages/texlive/package.py @@ -7,6 +7,7 @@ import os import platform import tempfile +import re class Texlive(AutotoolsPackage): @@ -221,3 +222,39 @@ def install(self, spec, prefix): '-portable', '-profile', tmp_profile.name) tmp_profile.close() + + executables = [r'^tex$'] + + @classmethod + def determine_version(cls, exe): + # https://askubuntu.com/questions/100406/finding-the-tex-live-version + # Thanks to @michaelkuhn that told how to reuse the package releases + # variable. + # Added 3 older releases: 2018 (CentOS-8), 2017 (Ubuntu-18.04), 2013 (CentOS-7). + releases = cls.releases + releases.extend([ + { + 'version': '20180414', + 'year': '2018', + }, + { + 'version': '20170524', + 'year': '2017', + }, + { + 'version': '20130530', + 'year': '2013', + }, + ]) + # tex indicates the year only + output = Executable(exe)('--version', output=str, error=str) + match = re.search(r'TeX Live (\d+)', output) + ver = match.group(1) if match else None + # We search for the repo actual release + if ver is not None: + for release in releases: + year = release['year'] + if year == ver: + ver = release['version'] + break + return ver