[latex3-commits] [git/LaTeX3-latex3-l3build] TDS: Basic support for a TDS map for file install (c41393a)
Joseph Wright
joseph.wright at morningstar2.co.uk
Thu Jul 25 20:01:40 CEST 2019
Repository : https://github.com/latex3/l3build
On branch : TDS
Link : https://github.com/latex3/l3build/commit/c41393aa9c19cef720811a80fb1d273f08a55cef
>---------------------------------------------------------------
commit c41393aa9c19cef720811a80fb1d273f08a55cef
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu Jul 25 18:58:40 2019 +0100
Basic support for a TDS map for file install
>---------------------------------------------------------------
c41393aa9c19cef720811a80fb1d273f08a55cef
l3build-file-functions.lua | 4 ++--
l3build-install.lua | 42 ++++++++++++++++++++++++++++++++++--------
l3build-variables.lua | 5 ++++-
l3build.dtx | 9 +++++++++
4 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/l3build-file-functions.lua b/l3build-file-functions.lua
index cc1bef6..9c7ac1f 100644
--- a/l3build-file-functions.lua
+++ b/l3build-file-functions.lua
@@ -1,6 +1,6 @@
--[[
-File l3build-file-functions.lua Copyright (C) 2018 The LaTeX3 Project
+File l3build-file-functions.lua Copyright (C) 2018,2019 The LaTeX3 Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -80,7 +80,7 @@ local insert = table.insert
(end license)
--]]
-local function glob_to_pattern(glob)
+function glob_to_pattern(glob)
local pattern = "^" -- pattern being built
local i = 0 -- index in glob
diff --git a/l3build-install.lua b/l3build-install.lua
index a97a24e..cba3c72 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -1,6 +1,6 @@
--[[
-File l3build-install.lua Copyright (C) 2018 The LaTeX3 Project
+File l3build-install.lua Copyright (C) 2018,2019 The LaTeX3 Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -93,6 +93,13 @@ function uninstall()
end
function install_files(target,full,dry_run)
+ -- Create a map for non-standard installation locations
+ local tdsmap = { }
+ for _,location in pairs(tdslocations) do
+ path,glob = splitpath(location)
+ tdsmap[glob] = path
+ end
+
local function install_files(source,dir,files,subdir)
subdir = subdir or moduledir
-- For material associated with secondary tools (BibTeX, MakeIndex)
@@ -103,28 +110,47 @@ function install_files(target,full,dry_run)
end
dir = dir .. (subdir and ("/" .. subdir) or "")
local filenames = { }
+ local paths = { }
+ -- Generate a file list and include the directory
for _,glob_table in pairs(files) do
for _,glob in pairs(glob_table) do
for file,_ in pairs(tree(source,glob)) do
- insert(filenames,file)
+ -- Just want the name
+ local file = gsub(file,"^%./","")
+ local matched = false
+ for glob,path in pairs(tdsmap) do
+ local pattern = glob_to_pattern(glob)
+ if match(file,pattern) then
+ insert(paths,path)
+ insert(filenames,path .. "/" .. file)
+ break
+ end
+ end
+ if not matched then
+ insert(paths,dir)
+ insert(filenames,dir .. "/" .. file)
+ end
end
end
end
+ for f,p in pairs(filenames) do print(f,p) end
local errorlevel = 0
-- The target is only created if there are actual files to install
if next(filenames) then
- local installdir = target .. "/" .. dir
if dry_run then
- print("\n" .. "For installation in " .. installdir .. ":")
+ print("For installation inside" .. target .. ":")
else
- errorlevel = cleandir(installdir)
- if errorlevel ~= 0 then return errorlevel end
+ for _,path in pairs(paths) do
+ errorlevel = cleandir(target .. "/" .. path)
+ if errorlevel ~= 0 then return errorlevel end
+ end
end
for _,file in ipairs(filenames) do
if dry_run then
- print("- " .. select(2,splitpath(file)))
+ print("- " .. file)
else
- errorlevel = cp(file,source,installdir)
+ local path,file = splitpath(file)
+ errorlevel = cp(file,source,target .. "/" .. path)
if errorlevel ~= 0 then return errorlevel end
end
end
diff --git a/l3build-variables.lua b/l3build-variables.lua
index 1288a6b..0b3c9a2 100644
--- a/l3build-variables.lua
+++ b/l3build-variables.lua
@@ -1,6 +1,6 @@
--[[
-File l3build-variables.lua Copyright (C) 2018 The LaTeX3 Project
+File l3build-variables.lua Copyright (C) 2018,2019 The LaTeX3 Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -197,6 +197,9 @@ tpfext = tpfext or ".tpf"
-- Manifest options
manifestfile = manifestfile or "MANIFEST.md"
+-- Non-standard installation locations
+tdslocations = tdslocations or { }
+
-- Upload settings
curlexe = curlexe or "curl"
uploadconfig = uploadconfig or {}
diff --git a/l3build.dtx b/l3build.dtx
index 4ca8409..18962e9 100644
--- a/l3build.dtx
+++ b/l3build.dtx
@@ -153,6 +153,8 @@
\luavarset{recordstatus}{false} {Switch to include error level from test runs in \texttt{.tlg} files}
\luavarset{manifestfile} {"MANIFEST.md"} {Filename to use for the manifest file}
\luavarseparator
+\luavarset{tdslocations}{\{ \}}{Map for non-standard file installations}
+\luavarseparator
\luavarset{uploadconfig} {\meta{table}} {Metadata to describe the package for CTAN (see Table~\ref{tab:upload-setup})}
\luavarset{uploadconfig.pkg}{ctanpkg}{Name of the CTAN package}
\luavarseparator
@@ -1580,6 +1582,13 @@
% all files in the \meta{path}.
% \end{function}
%
+% \begin{function}{glob_to_pattern()}
+% \begin{syntax}
+% |glob_to_pattern(|\meta{glob}|)|
+% \end{syntax}
+% Returns the \meta{glob} converted to a Lua pattern.
+% \end{function}
+%
% \begin{function}{jobname()}
% \begin{syntax}
% |jobname(|\meta{file}|)|
More information about the latex3-commits
mailing list