[latex3-commits] [git/LaTeX3-latex3-l3build] master: Extend uninstall() to cover all trees known (8ef6d18)

Joseph Wright joseph.wright at morningstar2.co.uk
Sat Aug 4 14:52:28 CEST 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/8ef6d1825ebe242b51ae8262ebe0ad1b97e2068c

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

commit 8ef6d1825ebe242b51ae8262ebe0ad1b97e2068c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Aug 3 22:10:28 2018 +0100

    Extend uninstall() to cover all trees known
    
    At least all those that are currently covered by TDS construction,
    and will therefore be affected by upcoming "--full" option.


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

8ef6d1825ebe242b51ae8262ebe0ad1b97e2068c
 l3build-install.lua |   40 ++++++++++++++++++++++++++++++++--------
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/l3build-install.lua b/l3build-install.lua
index c18677e..78e95da 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -28,18 +28,21 @@ local print = print
 local set_program = kpse.set_program_name
 local var_value   = kpse.var_value
 
+local match = string.match
+
 local function gethome()
   set_program("latex")
   return options["texmfhome"] or var_value("TEXMFHOME")
 end
 
 function uninstall()
-  local function uninstall_files(target)
-    local installdir = gethome() .. target
+  local function uninstall_files(dir,subdir)
+    subdir = subdir or moduledir
+    dir = dir .. "/" .. subdir
+    local installdir = gethome() .. "/" .. dir
     if options["dry-run"] then
       print("\n" .. "Installation root: " .. installdir)
       local files = filelist(installdir)
-      -- Deal with an empty directory
       if next(files) then
         print("\n" .. "Files for removal:")
         for _,file in pairs(filelist(installdir)) do
@@ -50,15 +53,36 @@ function uninstall()
       end
       return 0
     else
-      return rmdir(installdir)
+      if direxists(installdir) then
+        return rmdir(installdir)
+      end
+    end
+    return 0
+  end
+  local errorlevel = 0
+  -- Any script man files need special handling
+  for _,glob in pairs(scriptmanfiles) do
+    for file,_ in pairs(tree(docfiledir,glob)) do
+      -- Man files should have a single-digit extension: the type
+      local installdir = gethome() .. "/doc/man/man"  .. match(file,".$")
+      if fileexists(installdir .. "/" .. file) then
+        if options["dry-run"] then
+          print("- " .. file)
+        else
+          errorlevel = errorlevel + rm(installdir,file)
+        end
+      end
     end
   end
-  return   uninstall_files("/tex/" .. moduledir)
-         + uninstall_files("/scripts/" .. module)
+  return   uninstall_files("doc")
+         + uninstall_files("source")
+         + uninstall_files("tex")
+         + uninstall_files("bibtex/bst",module)
+         + uninstall_files("makeindex",module)
+         + uninstall_files("scripts",module)
+         + errorlevel
 end
 
-
--- Locally install files: only deals with those extracted, not docs etc.
 function install()
   local function install_files(files,target)
     if not next(files) then





More information about the latex3-commits mailing list