Update following CTAN rearrangements
[latex2e.git] / latex2e-20151001 / base / build.lua
blob9c6619e368ad294960dda4586d2a207f0b34dd31
1 #!/usr/bin/env texlua
3 -- Build script for LaTeX2e "base" files
5 -- Identify the bundle and module
6 module = "base"
7 bundle = ""
9 -- CTAN's name for this is a bit different from ours
10 ctanpkg = "latex-base"
12 -- Location of main directory: use Unix-style path separators
13 maindir = ".."
15 -- Set up the file types needed here
16 installfiles =
18 "*.cfg",
19 "*.clo",
20 "*.cls",
21 "*.def",
22 "*.dfu",
23 "*.fd",
24 "*.ltx",
25 "*.lua",
26 "*.sty",
27 "*.tex"
29 sourcefiles = {"*.cls", "unicode-letters.def", "*.dtx", "*.fdd", "*.ins", "*.tex"}
30 typesetfiles =
32 "source2e.tex",
33 "alltt.dtx",
34 "classes.dtx",
35 "cmfonts.dtx",
36 "doc.dtx",
37 "docstrip.dtx",
38 "exscale.dtx",
39 "fix-cm.dtx",
40 "graphpap.dtx",
41 "ifthen.dtx",
42 "inputenc.dtx",
43 "ltunicode.dtx",
44 "lppl.tex",
45 "utf8ienc.dtx",
46 "latexrelease.dtx",
47 "latexsym.dtx",
48 "letter.dtx",
49 "ltluatex.dtx",
50 "ltxdoc.dtx",
51 "makeindx.dtx",
52 "nfssfont.dtx",
53 "proc.dtx",
54 "slides.dtx",
55 "slifonts.dtx",
56 "syntonly.dtx",
57 "*.fdd",
58 "*.err",
61 -- A few special file for unpacking
62 unpackfiles = {"unpack.ins"}
63 unpacksuppfiles = {"hyphen.cfg", "UShyphen.tex"}
65 -- Custom settings for the check system
66 testsuppdir = "testfiles/helpers"
68 -- No dependencies at all (other than l3build of course)
69 checkdeps = { }
70 unpackdeps = { }
72 -- Customise typesetting
73 indexstyle = "source2e.ist"
75 function format ()
76 local errorlevel = unpack ()
77 if errorlevel ~=0 then
78 return errorlevel
79 end
80 local function format (engine,fmtname)
81 -- the relationships are all correct
82 local errorlevel = os.execute (
83 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir
84 .. os_concat ..
85 engine .. " -etex -ini " .. " -output-directory=" .. unpackdir ..
86 " " .. unpackdir .. "/latex.ltx"
88 if errorlevel ~=0 then
89 return errorlevel
90 end
91 ren (unpackdir, "latex.fmt", fmtname)
92 -- As format building is added in as an 'extra', the normal
93 -- copy mechanism (checkfiles) will fail as things get cleaned up
94 -- inside bundleunpack(): get around that using a manual copy
95 cp (fmtname, unpackdir, localdir)
96 if fmtname == "elatex.fmt" then
97 rm(localdir, "latex.fmt")
98 ren(localdir, fmtname, "latex.fmt")
99 end
100 return 0
102 local checkengines = optengines or checkengines
103 for _,i in ipairs(checkengines) do
104 errorlevel = format (i, string.gsub (i, "tex$", "") .. "latex.fmt")
105 if errorlevel ~=0 then
106 return errorlevel
109 return 0
112 -- Custom bundleunpack which does not search the localdir
113 -- That is needed as texsys.cfg is unpacked in an odd way and
114 -- without this will otherwise not be available
115 function bundleunpack ()
116 local errorlevel = mkdir(localdir)
117 if errorlevel ~=0 then
118 return errorlevel
120 errorlevel = cleandir(unpackdir)
121 if errorlevel ~=0 then
122 return errorlevel
124 for _,i in ipairs (sourcefiles) do
125 errorlevel = cp (i, ".", unpackdir)
126 if errorlevel ~=0 then
127 return errorlevel
130 for _,i in ipairs (unpacksuppfiles) do
131 errorlevel = cp (i, supportdir, localdir)
132 if errorlevel ~=0 then
133 return errorlevel
136 for _,i in ipairs (unpackfiles) do
137 for _,j in ipairs (filelist (unpackdir, i)) do
138 os.execute (os_yes .. ">>" .. localdir .. "/yes")
139 errorlevel = os.execute (
140 -- Notice that os.execute is used from 'here' as this ensures that
141 -- localdir points to the correct place: running 'inside'
142 -- unpackdir would avoid the need for setting -output-directory
143 -- but at the cost of needing to correct the relative position
144 -- of localdir w.r.t. unpackdir
145 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_concat ..
146 unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir
147 .. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes"
149 if errorlevel ~=0 then
150 return errorlevel
154 return 0
157 -- base does all of the targets itself
158 function main (target, file, engine)
159 local errorlevel
160 if target == "check" then
161 format ()
162 errorlevel = check (file, engine)
163 elseif target == "clean" then
164 errorlevel = clean ()
165 elseif target == "ctan" then
166 format ()
167 errorlevel = ctan (true)
168 elseif target == "doc" then
169 errorlevel = doc ()
170 elseif target == "install" then
171 install ()
172 elseif target == "save" then
173 if file then
174 errorlevel = save (file, engine)
175 else
176 help ()
178 elseif target == "unpack" then
179 -- A simple way to have the unpack target also build the format
180 errorlevel = format ()
181 elseif target == "version" then
182 version ()
183 else
184 help ()
186 os.exit (errorlevel)
189 -- Load the common settings for the LaTeX2e repo
190 dofile (maindir .. "/build-config.lua")
192 -- Find and run the build system
193 kpse.set_program_name ("kpsewhich")
194 dofile (kpse.lookup ("l3build.lua"))