[latex3-commits] [git/LaTeX3-latex3-l3build] main: Add tdsdirs (0c72324)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Dec 9 10:40:08 CET 2021


Repository : https://github.com/latex3/l3build
On branch  : main
Link       : https://github.com/latex3/l3build/commit/0c723247e25eac70d1c905ac87e88018770e34ca

>---------------------------------------------------------------

commit 0c723247e25eac70d1c905ac87e88018770e34ca
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Thu Oct 7 18:31:01 2021 +0200

    Add tdsdirs


>---------------------------------------------------------------

0c723247e25eac70d1c905ac87e88018770e34ca
 l3build-install.lua   | 38 ++++++++++++++++++++++++++++++++++++++
 l3build-variables.lua |  1 +
 2 files changed, 39 insertions(+)

diff --git a/l3build-install.lua b/l3build-install.lua
index 78fe2d4..6a28463 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -32,6 +32,7 @@ local var_value   = kpse.var_value
 local gsub  = string.gsub
 local lower = string.lower
 local match = string.match
+local format = string.format
 
 local insert = table.insert
 
@@ -107,6 +108,23 @@ function uninstall()
     errorlevel = zapdir(path)
     if errorlevel ~= 0 then return errorlevel end
   end
+  -- We remove all directories which contain at least one ordinary file in the source tree
+  for src, dest in pairs(tdsdirs) do
+    dest = dest .. '/'
+    local skipdir
+    for _, p in ipairs(tree(src, '**')) do
+      local src = p.src:sub(2) -- Skip the first '.'
+      if skipdir and src:sub(1, #skipdir) ~= skipdir then
+        skipdir = nil
+      end
+      if (not skipdir) and (not direxists(p.cwd)) then
+        skipdir = dirname(src)
+        errorlevel = zapdir(dest .. skipdir)
+        if errorlevel ~= 0 then return errorlevel end
+        skipdir = skipdir .. '/'
+      end
+    end
+  end
   return 0
 end
 
@@ -287,6 +305,26 @@ function install_files(target,full,dry_run)
     + create_install_map(unpackdir,"makeindex",{makeindexfiles},module)
     + create_install_map(unpackdir,"scripts",{scriptfiles},module)
 
+  for src, dest in pairs(tdsdirs) do
+    dest = target .. '/' .. dest
+    insert(installmap,
+      {file = '*', source = src, dest = dest})
+    dest = dest .. '/'
+    local skipdir
+    for _, p in ipairs(tree(src, '**')) do
+      local src = p.src:sub(2) -- Skip the first '.'
+      if skipdir and src:sub(1, #skipdir) ~= skipdir then
+        skipdir = nil
+      end
+      if (not skipdir) and (not direxists(p.cwd)) then
+        skipdir = dirname(src)
+        errorlevel = cleandir(dest .. skipdir)
+        if errorlevel ~= 0 then return errorlevel end
+        skipdir = skipdir .. '/'
+      end
+    end
+  end
+
   if errorlevel ~= 0 then return errorlevel end
 
   -- Files are all copied in one shot: this ensures that cleandir()
diff --git a/l3build-variables.lua b/l3build-variables.lua
index d78c39c..ffabf34 100644
--- a/l3build-variables.lua
+++ b/l3build-variables.lua
@@ -229,6 +229,7 @@ manifestfile = manifestfile or "MANIFEST.md"
 
 -- Non-standard installation locations
 tdslocations = tdslocations or { }
+tdsdirs = tdsdirs or {}
 
 -- Upload settings
 curlexe  = curlexe  or "curl"





More information about the latex3-commits mailing list.