% ConTeXt Packaging Scripts
% https://github.com/gucci-on-fleek/context-packaging
% SPDX-License-Identifier: CC0-1.0+
% SPDX-FileCopyrightText: 2025 Max Chernoff

% This TeX Live-specific file updates the ConTeXt LMTX filename cache if the
% system ls-R files are modified (typically by mktexlsr). It also sets the
% default paper size from the context-papersize.tex file which TeX Live
% creates/updates (in tlpkg/TLPaper.pm).

% Hans has moved the filename cache updating code into his upstream, so we only
% need to include the module here.
\usemodule[texlive]

% But if we've recently updated, then ConTeXt won't have m-texlive.mkxl in its
% filename cache!
\doifnotfile{m-texlive.mkxl}{
    \ctxlua{resolvers.renewcache() resolvers.load()}
}

% MkIV won't load MkXL files, but we need m-texlive.mkxl for the filename cache
% code to be loaded. Until a MkIV file is added, let's load the MkXL file and
% hope for no errors.
\doifnotmode{lmtx}{
    \doifnotfile{m-texlive.mkiv}{
        \input{sys:///m-texlive.mkxl}
    }
}

% Set the default paper size
\readsysfile{context-papersize.tex}{}{}
