From cb7a85a3a887ca6101f36ac5d2a863f830673363 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Wed, 26 Nov 2025 15:40:26 +0100 Subject: [PATCH] Try LuaTeX when initializing config.texmf_dirs --- .github/workflows/test.yml | 4 ++- bin/digestif.texlua | 5 ++-- digestif/config.lua | 50 ++++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d079c72..4d87fe7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ env: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 strategy: matrix: lua-version: ["5.3", "5.4"] @@ -18,6 +18,8 @@ jobs: uses: actions/setup-python@v3 with: python-version: "3.10" + - name: Install readline + run: sudo apt-get update && sudo apt-get install -y libreadline-dev - name: Install dependencies run: | pip install hererocks==0.25.1 -r spec/requirements.txt diff --git a/bin/digestif.texlua b/bin/digestif.texlua index f0f6c9e..784c2ab 100755 --- a/bin/digestif.texlua +++ b/bin/digestif.texlua @@ -5,10 +5,9 @@ package.cpath = package.cpath:gsub("%f[^\0;]%.[^;]*", ""):gsub(";+", ";"):gsub(" -- Use an invalid directory name in order not to allow kpse to search -- in the current directory. os.setenv("TEXMFDOTDIR", package.config:find("^\\") and "NUL" or "/dev/null") -kpse.set_program_name("luatex") -local zip = require "zip" -local archive = kpse.find_file("digestif.zip", "texmfscripts") +local archive = kpse.new("texlua"):find_file("digestif.zip", "texmfscripts") or error("Can't find 'digestif.zip' archive") +local zip = require "zip" local function digestif_searcher(modname) local submod = modname:match("^digestif%.(.+)") if not submod then return end diff --git a/digestif/config.lua b/digestif/config.lua index edad15b..fbfa6d2 100644 --- a/digestif/config.lua +++ b/digestif/config.lua @@ -9,28 +9,9 @@ if pre_version then config.version = config.version .. "-" .. pre_version end -if util.is_command("kpsewhich") then - local pipe = io.popen("kpsewhich -var-brace-value=TEXMF") - local output = pipe:read("l") - local ok, exitt, exitc = pipe:close() - if ok and exitt == "exit" and exitc == 0 then - config.texmf_dirs = util.imap( - function (s) return s:gsub("^!!", "") end, - util.path_list_split(output) - ) - elseif config.verbose then - util.log("Error running kpsewhich (%s %d)", exitt, exitc) - end -else -- TODO: What should be the default? - config.texmf_dirs = { - "/usr/local/share/texmf", - "/usr/share/texmf", - "/usr/share/texlive/texmf-local", - "/usr/share/texlive/texmf-dist", - } -end - -config.data_dirs = {} -- TODO: What should be the default? +-- TODO: What should be the default? +config.texmf_dirs = {} +config.data_dirs = {} -- Location of a complete texmf distribution, used for instance to -- find documentation not installed locally. Passed to format with @@ -129,15 +110,38 @@ function config.load_from_env() config.data_dirs = util.path_list_split(DIGESTIF_DATA) end + local ok, kpse = pcall(function() return _G.kpse.new("texlua") end) + kpse = ok and kpse or nil local DIGESTIF_TEXMF = os.getenv("DIGESTIF_TEXMF") if DIGESTIF_TEXMF then config.texmf_dirs = util.path_list_split(DIGESTIF_TEXMF) + elseif kpse then + local paths = kpse:expand_braces(kpse:var_value("TEXMF")) + config.texmf_dirs = util.imap( + function(s) return s:gsub("^!!", "") end, + util.path_list_split(paths) + ) + elseif util.is_command("kpsewhich") then + local pipe = io.popen("kpsewhich -var-brace-value=TEXMF") + local paths = pipe:read("l") + local ok, exitt, exitc = pipe:close() + if ok and exitt == "exit" and exitc == 0 then + config.texmf_dirs = util.imap( + function(s) return s:gsub("^!!", "") end, + util.path_list_split(paths) + ) + elseif config.verbose then + util.log("Error running kpsewhich (%s %d)", exitt, exitc) + end + end + if #config.texmf_dirs == 0 then + util.log("Couldn't initialize DIGESTIF_TEXMF") end local DIGESTIF_TLPDB = os.getenv("DIGESTIF_TLPDB") if DIGESTIF_TLPDB then config.tlpdb_path = util.path_list_split(DIGESTIF_TLPDB) - end + end -- TODO: copy rest of init from data.lua end function config.check_data(dir)