[latex3-commits] [git/LaTeX3-latex3-l3build] master: Exclude sourcefiles entries from clean-ip (830f422)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 17 09:47:44 CET 2020


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/830f422a1f5e479115c78470e9bee176d6756226

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

commit 830f422a1f5e479115c78470e9bee176d6756226
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 17 08:47:44 2020 +0000

    Exclude sourcefiles entries from clean-ip


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

830f422a1f5e479115c78470e9bee176d6756226
 CHANGELOG.md      |  3 +++
 l3build-clean.lua | 26 +++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index c7dfda8..9d24452 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Changed
+- Exclude `sourcefiles` entries from file clean-up
+
 ## [2020-03-16]
 
 ### Changed
diff --git a/l3build-clean.lua b/l3build-clean.lua
index 01927a7..27ed42b 100644
--- a/l3build-clean.lua
+++ b/l3build-clean.lua
@@ -1,6 +1,6 @@
 --[[
 
-File l3build-clean.lua Copyright (C) 2018 The LaTeX3 Project
+File l3build-clean.lua Copyright (C) 2018,2020 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
@@ -34,12 +34,28 @@ function clean()
     cleandir(testdir)    +
     cleandir(typesetdir) +
     cleandir(unpackdir)
-  for _,i in ipairs(cleanfiles) do
-    for _,dir in pairs(remove_duplicates({maindir, sourcefiledir, docfiledir})) do
-      errorlevel = rm(dir, i) + errorlevel
+
+  if errorlevel ~= 0 then return errorlevel end
+
+  local clean_list = { }
+  for _,dir in pairs(remove_duplicates({maindir,sourcefiledir,docfiledir})) do
+    for _,glob in pairs(cleanfiles) do
+      for file,_ in pairs(tree(dir,glob)) do
+        clean_list[file] = true
+      end
+    end
+    for _,glob in pairs(sourcefiles) do
+      for file,_ in pairs(tree(dir,glob)) do
+        clean_list[file] = nil
+      end
+    end
+    for file,_ in pairs(clean_list) do
+      errorlevel = rm(dir,file)
+      if errorlevel ~= 0 then return errorlevel end
     end
   end
-  return errorlevel
+
+  return 0
 end
 
 function bundleclean()





More information about the latex3-commits mailing list.