Revert r1482
[latex2e.git] / trunk / base / build.lua
blobd050dcb8687a6ad7d0fbeb7d21ff6533a72b117f
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 =
31 "ltnews.cls",
32 "ltxguide.cls",
33 "minimal.cls",
34 "*.dtx",
35 "*.fdd",
36 "*.ins",
37 "idx.tex",
38 "lablst.tex",
39 "lppl.tex",
40 "ltxcheck.tex",
41 "sample2e.tex",
42 "small2e.tex",
43 "source2e.tex",
44 "testpage.tex",
46 typesetfiles =
48 "source2e.tex",
49 "alltt.dtx",
50 "classes.dtx",
51 "cmfonts.dtx",
52 "doc.dtx",
53 "docstrip.dtx",
54 "exscale.dtx",
55 "fix-cm.dtx",
56 "graphpap.dtx",
57 "ifthen.dtx",
58 "inputenc.dtx",
59 "ltunicode.dtx",
60 "lppl.tex",
61 "utf8ienc.dtx",
62 "latexrelease.dtx",
63 "latexsym.dtx",
64 "letter.dtx",
65 "ltluatex.dtx",
66 "ltxdoc.dtx",
67 "makeindx.dtx",
68 "nfssfont.dtx",
69 "proc.dtx",
70 "slides.dtx",
71 "slifonts.dtx",
72 "syntonly.dtx",
73 "*.fdd",
74 "*.err",
77 -- A few special file for unpacking
78 unpackfiles = {"unpack.ins"}
79 unpacksuppfiles =
81 "EastAsianWidth.txt",
82 "hyphen.cfg",
83 "LineBreak.txt",
84 "load-unicode-data.tex",
85 "load-unicode-xetex-classes.tex",
86 "MathClass.txt",
87 "UnicodeData.txt",
88 "UShyphen.tex",
89 "ot1lmr.fd"
92 -- Custom settings for the check system
93 testsuppdir = "testfiles/helpers"
95 -- No dependencies at all (other than l3build of course)
96 checkdeps = { }
97 unpackdeps = { }
99 -- Customise typesetting
100 indexstyle = "source2e.ist"
102 function format ()
103 local errorlevel = unpack ()
104 if errorlevel ~=0 then
105 return errorlevel
107 local function format (engine,fmtname)
108 -- the relationships are all correct
109 local errorlevel = os.execute (
110 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_pathsep .. localdir
111 .. os_concat ..
112 engine .. " -etex -ini " .. " -output-directory=" .. unpackdir ..
113 " " .. unpackdir .. "/latex.ltx"
115 if errorlevel ~=0 then
116 return errorlevel
118 ren (unpackdir, "latex.fmt", fmtname)
119 -- As format building is added in as an 'extra', the normal
120 -- copy mechanism (checkfiles) will fail as things get cleaned up
121 -- inside bundleunpack(): get around that using a manual copy
122 cp (fmtname, unpackdir, localdir)
123 if fmtname == "elatex.fmt" then
124 rm(localdir, "latex.fmt")
125 ren(localdir, fmtname, "latex.fmt")
127 return 0
129 if not userargs["testfiledir"] then
130 cp ('fonttext.cfg', supportdir, unpackdir)
132 local checkengines = optengines or checkengines
133 for _,i in ipairs(checkengines) do
134 errorlevel = format (i, string.gsub (i, "tex$", "") .. "latex.fmt")
135 if errorlevel ~=0 then
136 return errorlevel
139 return 0
142 -- Custom bundleunpack which does not search the localdir
143 -- That is needed as texsys.cfg is unpacked in an odd way and
144 -- without this will otherwise not be available
145 function bundleunpack ()
146 local errorlevel = mkdir(localdir)
147 if errorlevel ~=0 then
148 return errorlevel
150 errorlevel = cleandir(unpackdir)
151 if errorlevel ~=0 then
152 return errorlevel
154 for _,i in ipairs (sourcefiles) do
155 errorlevel = cp (i, ".", unpackdir)
156 if errorlevel ~=0 then
157 return errorlevel
160 for _,i in ipairs (unpacksuppfiles) do
161 errorlevel = cp (i, supportdir, localdir)
162 if errorlevel ~=0 then
163 return errorlevel
166 for _,i in ipairs (unpackfiles) do
167 for _,j in ipairs (filelist (unpackdir, i)) do
168 os.execute (os_yes .. ">>" .. localdir .. "/yes")
169 errorlevel = os.execute (
170 -- Notice that os.execute is used from 'here' as this ensures that
171 -- localdir points to the correct place: running 'inside'
172 -- unpackdir would avoid the need for setting -output-directory
173 -- but at the cost of needing to correct the relative position
174 -- of localdir w.r.t. unpackdir
175 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_concat ..
176 unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir
177 .. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes"
179 if errorlevel ~=0 then
180 return errorlevel
184 return 0
187 -- base does all of the targets itself
188 function main (target, file, engine)
189 local errorlevel
190 if target == "check" then
191 format ()
192 errorlevel = check (file, engine)
193 elseif target == "clean" then
194 errorlevel = clean ()
195 elseif target == "ctan" then
196 format ()
197 errorlevel = ctan (true)
198 elseif target == "doc" then
199 errorlevel = doc ()
200 elseif target == "install" then
201 install ()
202 elseif target == "save" then
203 if file then
204 errorlevel = save (file, engine)
205 else
206 help ()
208 elseif target == "unpack" then
209 -- A simple way to have the unpack target also build the format
210 errorlevel = format ()
211 elseif target == "version" then
212 version ()
213 else
214 help ()
216 os.exit (errorlevel)
219 -- Load the common settings for the LaTeX2e repo
220 dofile (maindir .. "/build-config.lua")
222 -- Find and run the build system
223 kpse.set_program_name ("kpsewhich")
224 dofile (kpse.lookup ("l3build.lua"))