summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3build/l3build-install.lua
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3build/l3build-install.lua')
-rw-r--r--macros/latex/contrib/l3build/l3build-install.lua82
1 files changed, 42 insertions, 40 deletions
diff --git a/macros/latex/contrib/l3build/l3build-install.lua b/macros/latex/contrib/l3build/l3build-install.lua
index 77c15fd0e2..f4839fdca7 100644
--- a/macros/latex/contrib/l3build/l3build-install.lua
+++ b/macros/latex/contrib/l3build/l3build-install.lua
@@ -1,6 +1,6 @@
--[[
-File l3build-install.lua Copyright (C) 2018-2020 The LaTeX3 Project
+File l3build-install.lua Copyright (C) 2018-2020 The LaTeX Project
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -37,7 +37,9 @@ local insert = table.insert
local function gethome()
set_program("latex")
- return abspath(options["texmfhome"] or var_value("TEXMFHOME"))
+ local result = options["texmfhome"] or var_value("TEXMFHOME")
+ mkdir(result)
+ return abspath(result)
end
function uninstall()
@@ -68,15 +70,15 @@ function uninstall()
-- Any script man files need special handling
local manfiles = { }
for _,glob in pairs(scriptmanfiles) do
- for file,_ in pairs(tree(docfiledir,glob)) do
+ for _,p in ipairs(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
+ local installdir = gethome() .. "/doc/man/man" .. match(p.src,".$")
+ if fileexists(installdir .. "/" .. p.src) then
if options["dry-run"] then
- insert(manfiles,"man" .. match(file,".$") .. "/" ..
- select(2,splitpath(file)))
+ insert(manfiles,"man" .. match(p.src,".$") .. "/" ..
+ select(2,splitpath(p.src)))
else
- errorlevel = errorlevel + rm(installdir,file)
+ errorlevel = errorlevel + rm(installdir,p.src)
end
end
end
@@ -97,7 +99,7 @@ function uninstall()
if errorlevel ~= 0 then return errorlevel end
-- Finally, clean up special locations
for _,location in ipairs(tdslocations) do
- local path,glob = splitpath(location)
+ local path = dirname(location)
errorlevel = zapdir(path)
if errorlevel ~= 0 then return errorlevel end
end
@@ -127,9 +129,9 @@ function install_files(target,full,dry_run)
-- Generate a file list and include the directory
for _,glob_table in pairs(files) do
for _,glob in pairs(glob_table) do
- for file,_ in pairs(tree(source,glob)) do
+ for _,p in ipairs(tree(source,glob)) do
-- Just want the name
- local path,filename = splitpath(file)
+ local path,filename = splitpath(p.src)
local sourcepath = "/"
if path == "." then
sourcepaths[filename] = source
@@ -140,11 +142,11 @@ function install_files(target,full,dry_run)
end
local matched = false
for _,location in ipairs(tdslocations) do
- local path,glob = splitpath(location)
- local pattern = glob_to_pattern(glob)
+ local l_dir,l_glob = splitpath(location)
+ local pattern = glob_to_pattern(l_glob)
if match(filename,pattern) then
- insert(paths,path)
- insert(filenames,path .. sourcepath .. filename)
+ insert(paths,l_dir)
+ insert(filenames,l_dir .. sourcepath .. filename)
matched = true
break
end
@@ -161,20 +163,20 @@ function install_files(target,full,dry_run)
-- The target is only created if there are actual files to install
if next(filenames) then
if not dry_run then
- for _,path in pairs(paths) do
- local dir = target .. "/" .. path
- if not cleanpaths[dir] then
- errorlevel = cleandir(dir)
+ for _,path in ipairs(paths) do
+ local target_path = target .. "/" .. path
+ if not cleanpaths[target_path] then
+ errorlevel = cleandir(target_path)
if errorlevel ~= 0 then return errorlevel end
end
- cleanpaths[dir] = true
+ cleanpaths[target_path] = true
end
end
- for _,file in ipairs(filenames) do
+ for _,name in ipairs(filenames) do
if dry_run then
- print("- " .. file)
+ print("- " .. name)
else
- local path,file = splitpath(file)
+ local path,file = splitpath(name)
insert(installmap,
{file = file, source = sourcepaths[file], dest = target .. "/" .. path})
end
@@ -187,30 +189,30 @@ function install_files(target,full,dry_run)
if errorlevel ~= 0 then return errorlevel end
-- Creates a 'controlled' list of files
- local function excludelist(dir,include,exclude)
+ local function create_file_list(dir,include,exclude)
+ dir = dir or currentdir
include = include or { }
exclude = exclude or { }
- dir = dir or currentdir
- local includelist = { }
local excludelist = { }
for _,glob_table in pairs(exclude) do
for _,glob in pairs(glob_table) do
- for file,_ in pairs(tree(dir,glob)) do
- excludelist[file] = true
+ for _,p in ipairs(tree(dir,glob)) do
+ excludelist[p.src] = true
end
end
end
+ local result = { }
for _,glob in pairs(include) do
- for file,_ in pairs(tree(dir,glob)) do
- if not excludelist[file] then
- insert(includelist, file)
+ for _,p in ipairs(tree(dir,glob)) do
+ if not excludelist[p.src] then
+ insert(result, p.src)
end
end
end
- return includelist
+ return result
end
- local installlist = excludelist(unpackdir,installfiles,{scriptfiles})
+ local installlist = create_file_list(unpackdir,installfiles,{scriptfiles})
if full then
errorlevel = doc()
@@ -229,8 +231,8 @@ function install_files(target,full,dry_run)
end
-- Set up lists: global as they are also needed to do CTAN releases
- typesetlist = excludelist(docfiledir,typesetfiles,{sourcefiles})
- sourcelist = excludelist(sourcefiledir,sourcefiles,
+ typesetlist = create_file_list(docfiledir,typesetfiles,{sourcefiles})
+ sourcelist = create_file_list(sourcefiledir,sourcefiles,
{bstfiles,installfiles,makeindexfiles,scriptfiles})
if dry_run then
@@ -255,15 +257,15 @@ function install_files(target,full,dry_run)
-- Any script man files need special handling
local manfiles = { }
for _,glob in pairs(scriptmanfiles) do
- for file,_ in pairs(tree(docfiledir,glob)) do
+ for _,p in ipairs(tree(docfiledir,glob)) do
if dry_run then
- insert(manfiles,"man" .. match(file,".$") .. "/" ..
- select(2,splitpath(file)))
+ insert(manfiles,"man" .. match(p.src,".$") .. "/" ..
+ select(2,splitpath(p.src)))
else
-- Man files should have a single-digit extension: the type
- local installdir = target .. "/doc/man/man" .. match(file,".$")
+ local installdir = target .. "/doc/man/man" .. match(p.src,".$")
errorlevel = errorlevel + mkdir(installdir)
- errorlevel = errorlevel + cp(file,docfiledir,installdir)
+ errorlevel = errorlevel + cp(p.src,docfiledir,installdir)
end
end
end