[latex3-commits] [git/l3build] master: Add an uninstall target (fixes #43) (bd3b32a)
Joseph Wright
joseph.wright at morningstar2.co.uk
Sun Jan 21 21:31:42 CET 2018
Repository : https://github.com/latex3/l3build
On branch : master
Link : https://github.com/latex3/l3build/commit/bd3b32abe5a815a66b8965f814f586c1b72b01d3
>---------------------------------------------------------------
commit bd3b32abe5a815a66b8965f814f586c1b72b01d3
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Sun Jan 21 20:31:42 2018 +0000
Add an uninstall target (fixes #43)
>---------------------------------------------------------------
bd3b32abe5a815a66b8965f814f586c1b72b01d3
l3build-help.lua | 1 +
l3build-install.lua | 32 +++++++++++++++++++++++++++++---
l3build-stdmain.lua | 4 ++++
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/l3build-help.lua b/l3build-help.lua
index 656f829..f038dfc 100644
--- a/l3build-help.lua
+++ b/l3build-help.lua
@@ -47,6 +47,7 @@ function help()
print(" save Saves test validation log")
end
print(" setversion Update version information in sources")
+ print(" uninstall Uninstalls files into the local texmf tree")
print(" unpack Unpacks the source files into the build tree")
print("")
print("Valid options are:")
diff --git a/l3build-install.lua b/l3build-install.lua
index cee64a7..d3579ee 100644
--- a/l3build-install.lua
+++ b/l3build-install.lua
@@ -22,6 +22,33 @@ for those people who are interested.
--]]
+local set_program = kpse.set_program_name
+local var_value = kpse.var_value
+
+local function gethome()
+ set_program("latex")
+ return options["texmfhome"] or var_value("TEXMFHOME")
+end
+
+function uninstall()
+ local installdir = gethome() .. "/tex/" .. moduledir
+ 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
+ print("- " .. file)
+ end
+ else
+ print("No files present")
+ end
+ return 0
+ else
+ return rmdir(installdir)
+ end
+end
-- Locally install files: only deals with those extracted, not docs etc.
function install()
@@ -29,9 +56,7 @@ function install()
if errorlevel ~= 0 then
return errorlevel
end
- kpse.set_program_name("latex")
- local texmfhome = options["texmfhome"] or kpse.var_value("TEXMFHOME")
- local installdir = texmfhome .. "/tex/" .. moduledir
+ local installdir = gethome() .. "/tex/" .. moduledir
if options["dry-run"] then
print("\n" .. "Installation root: " .. installdir
.. "\n" .. "Installation files:"
@@ -41,6 +66,7 @@ function install()
print("- " .. file)
end
end
+ return 0
else
errorlevel = cleandir(installdir)
if errorlevel ~= 0 then
diff --git a/l3build-stdmain.lua b/l3build-stdmain.lua
index d8cd8da..200afa9 100644
--- a/l3build-stdmain.lua
+++ b/l3build-stdmain.lua
@@ -72,6 +72,8 @@ function stdmain(target, files)
if errorlevel == 0 then
errorlevel = setversion()
end
+ elseif target == "uninstall" then
+ errorlevel = call(modules, "uninstall")
elseif target == "unpack" then
errorlevel = call(modules, "bundleunpack")
elseif target == "version" then
@@ -107,6 +109,8 @@ function stdmain(target, files)
end
elseif target == "setversion" then
errorlevel = setversion()
+ elseif target == "uninstall" then
+ errorlevel = uninstall()
elseif target == "unpack" then
errorlevel = unpack()
elseif target == "version" then
More information about the latex3-commits
mailing list