Explicitly list .cls and .tex files for installation
[latex2e.git] / trunk / base / build.lua
blob9a89abf88f1fe771cc4e32d6fa27bafc7a888b5f
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 "latexbug.tex",
40 "lppl.tex",
41 "ltxcheck.tex",
42 "sample2e.tex",
43 "small2e.tex",
44 "source2e.tex",
45 "testpage.tex"
47 typesetfiles =
49 "source2e.tex",
50 "alltt.dtx",
51 "classes.dtx",
52 "cmfonts.dtx",
53 "doc.dtx",
54 "docstrip.dtx",
55 "exscale.dtx",
56 "fix-cm.dtx",
57 "graphpap.dtx",
58 "ifthen.dtx",
59 "inputenc.dtx",
60 "ltunicode.dtx",
61 "lppl.tex",
62 "utf8ienc.dtx",
63 "latexrelease.dtx",
64 "latexsym.dtx",
65 "letter.dtx",
66 "ltluatex.dtx",
67 "ltxdoc.dtx",
68 "makeindx.dtx",
69 "nfssfont.dtx",
70 "proc.dtx",
71 "slides.dtx",
72 "slifonts.dtx",
73 "syntonly.dtx",
74 "*.fdd",
75 "*.err",
78 -- A few special file for unpacking
79 unpackfiles = {"unpack.ins"}
80 unpacksuppfiles =
82 "EastAsianWidth.txt",
83 "hyphen.cfg",
84 "LineBreak.txt",
85 "load-unicode-data.tex",
86 "load-unicode-xetex-classes.tex",
87 "MathClass.txt",
88 "UnicodeData.txt",
89 "UShyphen.tex"
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 local checkengines = optengines or checkengines
130 for _,i in ipairs(checkengines) do
131 errorlevel = format (i, string.gsub (i, "tex$", "") .. "latex.fmt")
132 if errorlevel ~=0 then
133 return errorlevel
136 return 0
139 -- Custom bundleunpack which does not search the localdir
140 -- That is needed as texsys.cfg is unpacked in an odd way and
141 -- without this will otherwise not be available
142 function bundleunpack ()
143 local errorlevel = mkdir(localdir)
144 if errorlevel ~=0 then
145 return errorlevel
147 errorlevel = cleandir(unpackdir)
148 if errorlevel ~=0 then
149 return errorlevel
151 for _,i in ipairs (sourcefiles) do
152 errorlevel = cp (i, ".", unpackdir)
153 if errorlevel ~=0 then
154 return errorlevel
157 for _,i in ipairs (unpacksuppfiles) do
158 errorlevel = cp (i, supportdir, localdir)
159 if errorlevel ~=0 then
160 return errorlevel
163 for _,i in ipairs (unpackfiles) do
164 for _,j in ipairs (filelist (unpackdir, i)) do
165 os.execute (os_yes .. ">>" .. localdir .. "/yes")
166 errorlevel = os.execute (
167 -- Notice that os.execute is used from 'here' as this ensures that
168 -- localdir points to the correct place: running 'inside'
169 -- unpackdir would avoid the need for setting -output-directory
170 -- but at the cost of needing to correct the relative position
171 -- of localdir w.r.t. unpackdir
172 os_setenv .. " TEXINPUTS=" .. unpackdir .. os_concat ..
173 unpackexe .. " " .. unpackopts .. " -output-directory=" .. unpackdir
174 .. " " .. unpackdir .. "/" .. j .. " < " .. localdir .. "/yes"
176 if errorlevel ~=0 then
177 return errorlevel
181 return 0
184 -- base does all of the targets itself
185 function main (target, file, engine)
186 local errorlevel
187 if target == "check" then
188 format ()
189 errorlevel = check (file, engine)
190 elseif target == "clean" then
191 errorlevel = clean ()
192 elseif target == "ctan" then
193 format ()
194 errorlevel = ctan (true)
195 elseif target == "doc" then
196 errorlevel = doc ()
197 elseif target == "install" then
198 install ()
199 elseif target == "save" then
200 if file then
201 errorlevel = save (file, engine)
202 else
203 help ()
205 elseif target == "unpack" then
206 -- A simple way to have the unpack target also build the format
207 errorlevel = format ()
208 elseif target == "version" then
209 version ()
210 else
211 help ()
213 os.exit (errorlevel)
216 -- Load the common settings for the LaTeX2e repo
217 dofile (maindir .. "/build-config.lua")
219 -- Find and run the build system
220 kpse.set_program_name ("kpsewhich")
221 dofile (kpse.lookup ("l3build.lua"))