Skip to content

Commit

Permalink
Add an uninstall target (fixes #43)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Jan 21, 2018
1 parent b12fa55 commit bd3b32a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions l3build-help.lua
Expand Up @@ -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")

This comment has been minimized.

Copy link
@FrankMittelbach

FrankMittelbach Jan 21, 2018

Member

Uninstalls from not Uninstalls into I would think

print(" unpack Unpacks the source files into the build tree")
print("")
print("Valid options are:")
Expand Down
32 changes: 29 additions & 3 deletions l3build-install.lua
Expand Up @@ -22,16 +22,41 @@ 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()
local errorlevel = unpack()
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:"
Expand All @@ -41,6 +66,7 @@ function install()
print("- " .. file)
end
end
return 0
else
errorlevel = cleandir(installdir)
if errorlevel ~= 0 then
Expand Down
4 changes: 4 additions & 0 deletions l3build-stdmain.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd3b32a

Please sign in to comment.