-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.lua
55 lines (52 loc) · 1.7 KB
/
build.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
bundle = "expltools"
modules = {"explcheck"}
local function dirzip(dir, zipname)
local newzip = require"l3build-zip"
local lfs = require("lfs")
local attributes = lfs.attributes
zipname = zipname .. ".zip"
local zip = assert(newzip(dir .. '/' .. zipname))
local function tab_to_check(table)
local patterns = {}
for n,i in ipairs(table) do
patterns[n] = glob_to_pattern(i)
end
return function(name)
for n, patt in ipairs(patterns) do
if name:match"([^/]*)$":match(patt) then return true end
end
return false
end
end
-- Convert the tables of files to quoted strings
local binfile = tab_to_check(binaryfiles)
local exclude = tab_to_check(excludefiles)
local exefile = tab_to_check(exefiles)
-- First, zip up all of the text files
for _, p in ipairs(tree(dir, "**")) do
local src = p.src:sub(3) -- Strip ./
if not (attributes(p.cwd, "mode") == "directory" or exclude(src) or src == zipname) then
zip:add(p.cwd, src, binfile(src), exefile(src))
end
end
return zip:close()
end
-- A custom main function
function main(target, names)
local return_value
if ({check=true, bundlecheck=true, doc=true, tag=true})[target] ~= nil then
return_value = call(modules, target)
elseif ({ctan=true, bundlectan=true})[target] ~= nil then
return_value = target_list[target].bundle_func(names)
-- After installing CTAN files, add one extra level of directories.
local pkgdir = ctandir .. "/" .. ctanpkg
cp("CHANGES.md", pkgdir, pkgdir .. "/doc")
rm(pkgdir, "CHANGES.md")
dirzip(ctandir, ctanzip)
cp(ctanzip .. ".zip", ctandir, currentdir)
else
help()
return_value = 0
end
os.exit(return_value == 0 and 0 or 1)
end