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
29 sourcefiles
= {"*.cls", "unicode-letters.def", "*.dtx", "*.fdd", "*.ins", "*.tex"}
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)
72 -- Customise typesetting
73 indexstyle
= "source2e.ist"
76 local errorlevel
= unpack ()
77 if errorlevel
~=0 then
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
85 engine
.. " -etex -ini " .. " -output-directory=" .. unpackdir
..
86 " " .. unpackdir
.. "/latex.ltx"
88 if errorlevel
~=0 then
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")
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
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
120 errorlevel
= cleandir(unpackdir
)
121 if errorlevel
~=0 then
124 for _
,i
in ipairs (sourcefiles
) do
125 errorlevel
= cp (i
, ".", unpackdir
)
126 if errorlevel
~=0 then
130 for _
,i
in ipairs (unpacksuppfiles
) do
131 errorlevel
= cp (i
, supportdir
, localdir
)
132 if errorlevel
~=0 then
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
157 -- base does all of the targets itself
158 function main (target
, file
, engine
)
160 if target
== "check" then
162 errorlevel
= check (file
, engine
)
163 elseif target
== "clean" then
164 errorlevel
= clean ()
165 elseif target
== "ctan" then
167 errorlevel
= ctan (true)
168 elseif target
== "doc" then
170 elseif target
== "install" then
172 elseif target
== "save" then
174 errorlevel
= save (file
, engine
)
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
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"))