diff options
Diffstat (limited to 'Master/texmf-dist/scripts/context/lua/mtx-update.lua')
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-update.lua | 111 |
1 files changed, 83 insertions, 28 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-update.lua b/Master/texmf-dist/scripts/context/lua/mtx-update.lua index 750c7488692..52c72da6d4d 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-update.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-update.lua @@ -20,7 +20,8 @@ local helpinfo = [[ --rsync=string rsync binary (rsync) --texroot=string installation directory (not guessed for the moment) --engine=string tex engine (luatex, pdftex, xetex) ---extras=string extra modules (can be list or 'all') +--modules=string extra modules (can be list or 'all') +--fonts=string additional fonts (can be list or 'all') --goodies=string extra binaries (like scite and texworks) --force instead of a dryrun, do the real thing --update update minimal tree @@ -31,13 +32,13 @@ local helpinfo = [[ local application = logs.application { name = "mtx-update", - banner = "ConTeXt Minimals Updater 0.22", + banner = "ConTeXt Minimals Updater 0.30", helpinfo = helpinfo, } local report = application.report -local format, concat, gmatch, gsub = string.format, table.concat, string.gmatch, string.gsub +local format, concat, gmatch, gsub, find = string.format, table.concat, string.gmatch, string.gsub, string.find scripts = scripts or { } scripts.update = scripts.update or { } @@ -60,7 +61,7 @@ scripts.update.texformats = { "cont-ro", "cont-uk", "cont-pe", - "cont-xp", + -- "cont-xp", "mptopdf", "plain" } @@ -92,7 +93,6 @@ scripts.update.base = { { "fonts/common/", "texmf" }, { "fonts/other/", "texmf" }, -- not *really* needed, but helpful { "context/<version>/", "texmf-context" }, - { "context/img/", "texmf-context" }, { "misc/setuptex/", "." }, { "misc/web2c", "texmf" }, { "bin/common/<platform>/", "texmf-<platform>" }, @@ -180,6 +180,9 @@ scripts.update.selfscripts = { scripts.update.modules = { } +scripts.update.fonts = { +} + function scripts.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 :) @@ -211,7 +214,8 @@ function scripts.update.synchronize() local bin = states.get("rsync.program") -- rsync local url = states.get("rsync.server") -- contextgarden.net local version = states.get("context.version") -- current (or beta) - local extras = states.get("extras") -- extras (like modules) + local modules = states.get("modules") -- modules (third party) + local fonts = states.get("fonts") -- fonts (experimental or special) local goodies = states.get("goodies") -- goodies (like editors) local force = environment.argument("force") @@ -229,6 +233,7 @@ function scripts.update.synchronize() dir.mkdirs(format("%s/%s", texroot, "texmf-local")) dir.mkdirs(format("%s/%s", texroot, "texmf-project")) dir.mkdirs(format("%s/%s", texroot, "texmf-fonts")) + dir.mkdirs(format("%s/%s", texroot, "texmf-modules")) end if ok or not force then @@ -291,20 +296,41 @@ function scripts.update.synchronize() -- rsync://contextgarden.net/minimals/current/modules/ - if extras and type(extras) == "table" then + if modules and type(modules) == "table" then -- fetch the list of available modules from rsync server local available_modules = get_list_of_files_from_rsync({"modules/"}) -- hash of requested modules - -- local h = table.tohash(extras:split(",")) + -- local h = table.tohash(modules:split(",")) + local asked = table.copy(modules) + asked.all = nil for i=1,#available_modules do local s = available_modules[i] - -- if extras == "all" or h[s] then - if extras.all or extras[s] then - scripts.update.modules[#scripts.update.modules+1] = { format("modules/%s/",s), "texmf-context" } + if modules.all or modules[s] then + scripts.update.modules[#scripts.update.modules+1] = { format("modules/%s/",s), "texmf-modules" } end + asked[s] = nil + end + if next(asked) then + report("skipping unknown modules: %s",table.concat(table.sortedkeys(asked),", ")) + end + end + + -- rsync://contextgarden.net/minimals/current/fonts/extra/ + + if fonts and type(fonts) == "table" then + local available_fonts = get_list_of_files_from_rsync({"fonts/extra/"}) + local asked = table.copy(fonts) + asked.all = nil + 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" } + end + asked[s] = nil + end + if next(asked) then + report("skipping unknown fonts: %s",table.concat(table.sortedkeys(asked),", ")) end - -- TODO: check if every module from the list has been added and issue warning otherwise - -- one idea to do it: remove every value from h once added and then check if anything is left in h end local function add_collection(collection,platform) @@ -318,7 +344,7 @@ function scripts.update.synchronize() destination = gsub(destination,"\\","/") archive = gsub(archive,"<version>",version) if osplatform == "windows" or osplatform == "mswin" then - destination = gsub(destination,"([a-zA-Z]):/", "/cygdrive/%1/") + destination = gsub(destination,"([a-zA-Z]):/", "/cygdrive/%1/") -- ^ end individual[#individual+1] = { archive, destination } end @@ -332,6 +358,9 @@ function scripts.update.synchronize() for platform, _ in next, platforms do add_collection(scripts.update.modules,platform) end + for platform, _ in next, platforms do + add_collection(scripts.update.fonts,platform) + end for engine, _ in next, engines do for platform, _ in next, platforms do add_collection(scripts.update.engines[engine],platform) @@ -372,7 +401,7 @@ function scripts.update.synchronize() if not environment.argument("force") then dryrunflags = "--dry-run" end - if (destination:find("texmf$") or destination:find("texmf%-context$")) and (not environment.argument("keep")) then + if (destination:find("texmf$") or destination:find("texmf%-context$") or destination:find("texmf%-modules$")) and (not environment.argument("keep")) then deleteflags = states.get("rsync.flags.delete") end command = format("%s %s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, dryrunflags, url, archives, destination) @@ -417,7 +446,7 @@ 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" --direct mktexlsr',texroot)) + scripts.update.run(format('mtxrun --tree="%s" --direct --resolve mktexlsr',texroot)) -- update filename database for luatex scripts.update.run(format('mtxrun --tree="%s" --generate',texroot)) @@ -446,7 +475,7 @@ function scripts.update.make() resolvers.load_tree(texroot) - scripts.update.run(format('mtxrun --tree="%s" --direct mktexlsr',texroot)) + scripts.update.run(format('mtxrun --tree="%s" --direct --resolve mktexlsr',texroot)) scripts.update.run(format('mtxrun --tree="%s" --generate',texroot)) local askedformats = formats @@ -479,8 +508,10 @@ function scripts.update.make() if not force then report("make, use --force to really make formats") end - scripts.update.run(format('mtxrun --tree="%s" --direct mktexlsr',texroot)) + + scripts.update.run(format('mtxrun --tree="%s" --direct --resolve mktexlsr',texroot)) -- needed for mpost scripts.update.run(format('mtxrun --tree="%s" --generate',texroot)) + report("make, done") end @@ -496,7 +527,7 @@ if scripts.savestate then states.set("info.version",0.1) -- ok states.set("info.count",(states.get("info.count") or 0) + 1,1,false) -- ok - states.set("info.comment","this file contains the settings of the last 'mtxrun --script update ' run",false) -- ok + states.set("info.comment","this file contains the settings of the last 'mtxrun --script update' run",false) -- ok states.set("info.date",os.date("!%Y-%m-%d %H:%M:%S")) -- ok states.set("rsync.program", environment.argument("rsync"), "rsync", true) -- ok @@ -513,18 +544,30 @@ if scripts.savestate then 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 - for r in gmatch(environment.argument("engine") or "all","([^, ]+)") do - if r == "all" then - for k, v in next, valid do - if k ~= "all" then - states.set("engines." .. k, true) + local engine = environment.argument("engine") or "" + if engine == "" then + local e = states.get("engines") + if not e or not next(e) then + engine = "all" + end + end + if engine ~= "" then + for r in gmatch(engine,"([^, ]+)") do + if r == "all" then + for k, v in next, valid do + if k ~= "all" then + states.set("engines." .. k, true) + end end + break + elseif valid[r] then + states.set("engines." .. r, true) end - elseif valid[r] then - states.set("engines." .. r, true) end end + local valid = scripts.update.platforms for r in gmatch(environment.argument("platform") or os.platform,"([^, ]+)") do if valid[r] then states.set("platforms." .. r, true) end @@ -543,8 +586,20 @@ if scripts.savestate then states.set("formats.cont-nl", true) states.set("formats.metafun", true) - for r in gmatch(environment.argument("extras") or "","([^, ]+)") do - states.set("extras." .. r, true) + for r in gmatch(environment.argument("extras") or "","([^, ]+)") do -- for old times sake + if r ~= "all" and not find(r,"^[a-z]%-") then + r = "t-" .. r + end + states.set("modules." .. r, true) + end + for r in gmatch(environment.argument("modules") or "","([^, ]+)") do + if r ~= "all" and not find(r,"^[a-z]%-") then + r = "t-" .. r + end + states.set("modules." .. r, true) + end + for r in gmatch(environment.argument("fonts") or "","([^, ]+)") do + states.set("fonts." .. r, true) end for r in gmatch(environment.argument("goodies") or "","([^, ]+)") do states.set("goodies." .. r, true) |