summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtx-update.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/lua/mtx-update.lua')
-rw-r--r--scripts/context/lua/mtx-update.lua124
1 files changed, 63 insertions, 61 deletions
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index 8a23ba9a6..20ca9ce27 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -19,7 +19,7 @@ local helpinfo = [[
<metadata>
<entry name="name">mtx-update</entry>
<entry name="detail">ConTeXt Minimals Updater</entry>
- <entry name="version">1.02</entry>
+ <entry name="version">1.03</entry>
</metadata>
<flags>
<category name="basic">
@@ -51,7 +51,7 @@ local helpinfo = [[
local application = logs.application {
name = "mtx-update",
- banner = "ConTeXt Minimals Updater 1.02",
+ banner = "ConTeXt Minimals Updater 1.03",
helpinfo = helpinfo,
}
@@ -61,6 +61,7 @@ local format, concat, gmatch, gsub, find = string.format, table.concat, string.g
scripts = scripts or { }
scripts.update = scripts.update or { }
+local update = scripts.update
minimals = minimals or { }
minimals.config = minimals.config or { }
@@ -70,7 +71,7 @@ minimals.config = minimals.config or { }
os.setenv("CYGWIN","nontsec")
-scripts.update.texformats = {
+update.texformats = {
"cont-en",
"cont-nl",
"cont-cz",
@@ -85,28 +86,28 @@ scripts.update.texformats = {
"plain"
}
--- scripts.update.mpformats = {
+-- update.mpformats = {
-- -- "metafun",
-- -- "mpost",
-- }
-- experimental is not functional at the moment
-scripts.update.repositories = {
+update.repositories = {
"current",
"experimental"
}
-- more options than just these two are available (no idea why this is here)
-scripts.update.versions = {
+update.versions = {
"current",
"latest"
}
-- list of basic folders that are needed to make a functional distribution
-scripts.update.base = {
+update.base = {
{ "base/tex/", "texmf" },
{ "base/metapost/", "texmf" },
{ "fonts/common/", "texmf" },
@@ -123,7 +124,10 @@ scripts.update.base = {
-- binaries and font-related files
-- for pdftex we don't need OpenType fonts, for LuaTeX/XeTeX we don't need TFM files
-scripts.update.engines = {
+update.defaultengine = "luatex"
+update.rsyncvariant = "cygwin" -- will be come mingw
+
+update.engines = {
["luatex"] = {
{ "fonts/new/", "texmf" },
{ "bin/luatex/<platform>/", "texmf-<platform>" },
@@ -151,7 +155,7 @@ scripts.update.engines = {
},
}
-scripts.update.goodies = {
+update.goodies = {
["scite"] = {
{ "bin/<platform>/scite/", "texmf-<platform>" },
},
@@ -160,7 +164,7 @@ scripts.update.goodies = {
},
}
-scripts.update.platforms = {
+update.platforms = {
["mswin"] = "mswin",
["windows"] = "mswin",
["win32"] = "mswin",
@@ -222,20 +226,20 @@ local windowsplatform = {
["win64"] = true,
}
-scripts.update.selfscripts = {
+update.selfscripts = {
"mtxrun",
-- "luatools",
}
-- the list is filled up later (when we know what modules to download)
-scripts.update.modules = {
+update.modules = {
}
-scripts.update.fonts = {
+update.fonts = {
}
-function scripts.update.run(str)
+function update.run(str)
-- important, otherwise formats fly to a weird place
-- (texlua sets luatex as the engine, we need to reset that or to fix texexec :)
os.setenv("engine",nil)
@@ -247,7 +251,7 @@ function scripts.update.run(str)
end
end
-function scripts.update.fullpath(path)
+function update.fullpath(path)
if file.is_rootbased_path(path) then
return path
else
@@ -255,10 +259,8 @@ function scripts.update.fullpath(path)
end
end
-local rsync_variant = "cygwin" -- will be come mingw
-
local function drive(d)
- if rsync_variant == "cygwin" then
+ if update.rsyncvariant == "cygwin" then
d = gsub(d,[[([a-zA-Z]):/]], "/cygdrive/%1/")
else
d = gsub(d,[[([a-zA-Z]):/]], "/%1/")
@@ -266,11 +268,11 @@ local function drive(d)
return d
end
-function scripts.update.synchronize()
+function update.synchronize()
report("update, start")
- local texroot = scripts.update.fullpath(states.get("paths.root"))
+ local texroot = update.fullpath(states.get("paths.root"))
local engines = states.get('engines') or { }
local platforms = states.get('platforms') or { }
local repositories = states.get('repositories') -- minimals
@@ -331,7 +333,7 @@ function scripts.update.synchronize()
return prefix .. concat(list_of_folders, format(" %s", prefix))
end
- -- example of usage: print(list_of_folders_to_rsync_string(collection_to_list_of_folders(scripts.update.base, os.platform)))
+ -- example of usage: print(list_of_folders_to_rsync_string(collection_to_list_of_folders(update.base, os.platform)))
-- rename function and add some more functionality:
-- * recursive/non-recursive (default: non-recursive)
@@ -377,7 +379,7 @@ function scripts.update.synchronize()
for i=1,#available_modules do
local s = available_modules[i]
if modules.all or modules[s] then
- scripts.update.modules[#scripts.update.modules+1] = { format("modules/%s/",s), "texmf-modules" }
+ update.modules[#update.modules+1] = { format("modules/%s/",s), "texmf-modules" }
report("+ %s",s)
else
report(" %s",s)
@@ -398,7 +400,7 @@ function scripts.update.synchronize()
for i=1,#available_fonts do
local s = available_fonts[i]
if fonts.all or fonts[s] then
- scripts.update.fonts[#scripts.update.fonts+1] = { format("fonts/extra/%s/",s), "texmf" }
+ update.fonts[#update.fonts+1] = { format("fonts/extra/%s/",s), "texmf" }
end
asked[s] = nil
end
@@ -409,7 +411,7 @@ function scripts.update.synchronize()
local function add_collection(collection,platform)
if collection and platform then
- platform = scripts.update.platforms[platform]
+ platform = update.platforms[platform]
if platform then
for i=1,#collection do
local c = collection[i]
@@ -427,30 +429,30 @@ function scripts.update.synchronize()
end
for platform in table.sortedhash(platforms) do
- add_collection(scripts.update.base,platform)
+ add_collection(update.base,platform)
end
for platform in table.sortedhash(platforms) do
- add_collection(scripts.update.modules,platform)
+ add_collection(update.modules,platform)
end
for platform in table.sortedhash(platforms) do
- add_collection(scripts.update.fonts,platform)
+ add_collection(update.fonts,platform)
end
for engine in table.sortedhash(engines) do
for platform in table.sortedhash(platforms) do
- add_collection(scripts.update.engines[engine],platform)
+ add_collection(update.engines[engine],platform)
end
end
if goodies and type(goodies) == "table" then
for goodie in table.sortedhash(goodies) do
for platform in table.sortedhash(platforms) do
- add_collection(scripts.update.goodies[goodie],platform)
+ add_collection(update.goodies[goodie],platform)
end
end
end
local combined = { }
- local update_repositories = scripts.update.repositories
+ local update_repositories = update.repositories
for i=1,#update_repositories do
local repository = update_repositories[i]
if repositories[repository] then
@@ -481,7 +483,7 @@ function scripts.update.synchronize()
command = format("%s %s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, dryrunflags, url, archives, drive(destination))
-- report("running command: %s",command)
if not fetched[command] then
- scripts.update.run(command,true)
+ update.run(command,true)
fetched[command] = command
end
end
@@ -489,7 +491,7 @@ function scripts.update.synchronize()
local function update_script(script, platform)
local bin = gsub(bin,"\\","/")
local texroot = gsub(texroot,"\\","/")
- platform = scripts.update.platforms[platform]
+ platform = update.platforms[platform]
if platform then
local command
if windowsplatform[platform] then
@@ -500,13 +502,13 @@ function scripts.update.synchronize()
command = format([[%s -tgo --chmod=a+x '%s/texmf-context/scripts/context/lua/%s.lua' '%s/texmf-%s/bin/%s']], bin, texroot, script, texroot, platform, script)
end
report("updating %s for %s: %s", script, platform, command)
- scripts.update.run(command)
+ update.run(command)
end
end
for platform in table.sortedhash(platforms) do
- for i=1, #scripts.update.selfscripts do
- update_script(scripts.update.selfscripts[i],platform)
+ for i=1, #update.selfscripts do
+ update_script(update.selfscripts[i],platform)
end
end
@@ -520,9 +522,9 @@ function scripts.update.synchronize()
resolvers.load_tree(texroot) -- else we operate in the wrong tree
-- update filename database for pdftex/xetex
- scripts.update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr %s',texroot,silent,quiet))
+ update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr %s',texroot,silent,quiet))
-- update filename database for luatex
- scripts.update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
+ update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
report("update, done")
end
@@ -536,14 +538,14 @@ function table.fromhash(t)
end
-- make the ConTeXt formats
-function scripts.update.make()
+function update.make()
report("make, start")
local force = environment.argument("force")
local silent = environment.argument("silent") and "--silent" or ""
local quiet = silent == "" and "" or "--quiet"
- local texroot = scripts.update.fullpath(states.get("paths.root"))
+ local texroot = update.fullpath(states.get("paths.root"))
local engines = states.get('engines')
local goodies = states.get('goodies')
local platforms = states.get('platforms')
@@ -551,12 +553,12 @@ function scripts.update.make()
resolvers.load_tree(texroot)
- scripts.update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr %s',texroot,silent,quiet))
- scripts.update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
+ update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr %s',texroot,silent,quiet))
+ update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
local askedformats = formats
- local texformats = table.tohash(scripts.update.texformats)
- -- local mpformats = table.tohash(scripts.update.mpformats)
+ local texformats = table.tohash(update.texformats)
+ -- local mpformats = table.tohash(update.mpformats)
for k,v in table.sortedhash(texformats) do
if not askedformats[k] then
texformats[k] = nil
@@ -571,24 +573,24 @@ function scripts.update.make()
if formatlist ~= "" then
for engine in table.sortedhash(engines) do
if engine == "luatex" or engine == "luajittex" then
- scripts.update.run(format('mtxrun --tree="%s" %s --script context --autogenerate --make %s',texroot,silent,silent))
- scripts.update.run(format('mtxrun --tree="%s" %s --script context --autogenerate --make --engine=luajittex %s',texroot,silent,silent))
+ update.run(format('mtxrun --tree="%s" %s --script context --autogenerate --make %s',texroot,silent,silent))
+ update.run(format('mtxrun --tree="%s" %s --script context --autogenerate --make --engine=luajittex %s',texroot,silent,silent))
else
- -- scripts.update.run(format('mtxrun --tree="%s" %s --script texexec --make --all %s --%s %s',texroot,silent,silent,engine,formatlist))
- scripts.update.run(format('mtxrun --tree="%s" --resolve %s --script context --resolve --make %s --engine=%s %s',texroot,silent,silent,engine,formatlist))
+ -- update.run(format('mtxrun --tree="%s" %s --script texexec --make --all %s --%s %s',texroot,silent,silent,engine,formatlist))
+ update.run(format('mtxrun --tree="%s" --resolve %s --script context --resolve --make %s --engine=%s %s',texroot,silent,silent,engine,formatlist))
end
end
end
-- local formatlist = concat(table.fromhash(mpformats), " ")
-- if formatlist ~= "" then
- -- scripts.update.run(format('mtxrun --tree="%s" %s --script texexec --make --all %s %s',texroot,silent,silent,formatlist))
+ -- update.run(format('mtxrun --tree="%s" %s --script texexec --make --all %s %s',texroot,silent,silent,formatlist))
-- end
if not force then
report("make, use --force to really make formats")
end
- -- scripts.update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr',texroot,silent)) -- needed for mpost
- scripts.update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
+ -- update.run(format('mtxrun --tree="%s" %s --direct --resolve mktexlsr',texroot,silent)) -- needed for mpost
+ update.run(format('mtxrun --tree="%s" %s --generate',texroot,silent))
report("make, done")
end
@@ -618,17 +620,17 @@ if scripts.savestate then
states.set("context.version", environment.argument("context"), "current", true) -- ok
- local valid = table.tohash(scripts.update.repositories)
+ local valid = table.tohash(update.repositories)
for r in gmatch(environment.argument("repository") or "current","([^, ]+)") do
if valid[r] then states.set("repositories." .. r, true) end
end
- local valid = scripts.update.engines
+ local valid = update.engines
local engine = environment.argument("engine") or ""
if engine == "" then
local e = states.get("engines")
if not e or not next(e) then
- engine = "all"
+ engine = update.defaultengine
end
end
if engine ~= "" then
@@ -646,16 +648,16 @@ if scripts.savestate then
end
end
- local valid = scripts.update.platforms
+ local valid = update.platforms
for r in gmatch(environment.argument("platform") or os.platform,"([^, ]+)") do
if valid[r] then states.set("platforms." .. r, true) end
end
- local valid = table.tohash(scripts.update.texformats)
+ local valid = table.tohash(update.texformats)
for r in gmatch(environment.argument("formats") or "","([^, ]+)") do
if valid[r] then states.set("formats." .. r, true) end
end
- -- local valid = table.tohash(scripts.update.mpformats)
+ -- local valid = table.tohash(update.mpformats)
-- for r in gmatch(environment.argument("formats") or "","([^, ]+)") do
-- if valid[r] then states.set("formats." .. r, true) end
-- end
@@ -695,18 +697,18 @@ if environment.argument("state") then
end
if environment.argument("mingw") then
- rsync_variant = "mingw"
+ update.rsyncvariant = "mingw"
elseif environment.argument("cygwin") then
- rsync_variant = "cygwin"
+ update.rsyncvariant = "cygwin"
end
if environment.argument("update") then
- scripts.update.synchronize()
+ update.synchronize()
if environment.argument("make") then
- scripts.update.make()
+ update.make()
end
elseif environment.argument("make") then
- scripts.update.make()
+ update.make()
elseif environment.argument("exporthelp") then
application.export(environment.argument("exporthelp"),environment.files[1])
else