3 -- Build script for LaTeX2e "base" files
5 -- Identify the bundle and module
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
15 -- Set up the file types needed here
78 -- A few special file for unpacking
79 unpackfiles
= {"unpack.ins"}
85 "load-unicode-data.tex",
86 "load-unicode-xetex-classes.tex",
92 -- Custom settings for the check system
93 testsuppdir
= "testfiles/helpers"
95 -- No dependencies at all (other than l3build of course)
99 -- Customise typesetting
100 indexstyle
= "source2e.ist"
103 local errorlevel
= unpack ()
104 if errorlevel
~=0 then
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
112 engine
.. " -etex -ini " .. " -output-directory=" .. unpackdir
..
113 " " .. unpackdir
.. "/latex.ltx"
115 if errorlevel
~=0 then
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")
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
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
147 errorlevel
= cleandir(unpackdir
)
148 if errorlevel
~=0 then
151 for _
,i
in ipairs (sourcefiles
) do
152 errorlevel
= cp (i
, ".", unpackdir
)
153 if errorlevel
~=0 then
157 for _
,i
in ipairs (unpacksuppfiles
) do
158 errorlevel
= cp (i
, supportdir
, localdir
)
159 if errorlevel
~=0 then
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
184 -- base does all of the targets itself
185 function main (target
, file
, engine
)
187 if target
== "check" then
189 errorlevel
= check (file
, engine
)
190 elseif target
== "clean" then
191 errorlevel
= clean ()
192 elseif target
== "ctan" then
194 errorlevel
= ctan (true)
195 elseif target
== "doc" then
197 elseif target
== "install" then
199 elseif target
== "save" then
201 errorlevel
= save (file
, engine
)
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
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"))