diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2010-05-24 14:05:02 +0000 |
commit | 57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch) | |
tree | 1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/scripts/context/lua/mtx-update.lua | |
parent | 6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff) |
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/context/lua/mtx-update.lua')
-rw-r--r-- | Master/texmf-dist/scripts/context/lua/mtx-update.lua | 175 |
1 files changed, 100 insertions, 75 deletions
diff --git a/Master/texmf-dist/scripts/context/lua/mtx-update.lua b/Master/texmf-dist/scripts/context/lua/mtx-update.lua index bc6ca402639..b56083d3809 100644 --- a/Master/texmf-dist/scripts/context/lua/mtx-update.lua +++ b/Master/texmf-dist/scripts/context/lua/mtx-update.lua @@ -86,10 +86,12 @@ scripts.update.engines = { ["xetex"] = { { "base/xetex/", "texmf" }, { "fonts/new/", "texmf" }, + { "bin/luatex/<platform>/", "texmf-<platform>" }, -- tools { "bin/xetex/<platform>/", "texmf-<platform>" }, }, ["pdftex"] = { { "fonts/old/", "texmf" }, + { "bin/luatex/<platform>/", "texmf-<platform>" }, -- tools { "bin/pdftex/<platform>/", "texmf-<platform>" }, }, ["all"] = { @@ -112,30 +114,34 @@ scripts.update.goodies = { } scripts.update.platforms = { - ["mswin"] = "mswin", - ["windows"] = "mswin", - ["win32"] = "mswin", - ["win"] = "mswin", - ["linux"] = "linux", - ["freebsd"] = "freebsd", - ["freebsd-amd64"] = "freebsd-amd64", - ["linux-32"] = "linux", - ["linux-64"] = "linux-64", - ["linux32"] = "linux", - ["linux64"] = "linux-64", - ["linux-ppc"] = "linux-ppc", - ["ppc"] = "linux-ppc", - ["osx"] = "osx-intel", - ["macosx"] = "osx-intel", - ["osx-intel"] = "osx-intel", - ["osx-ppc"] = "osx-ppc", - ["osx-powerpc"] = "osx-ppc", - ["osxintel"] = "osx-intel", - ["osxppc"] = "osx-ppc", - ["osxpowerpc"] = "osx-ppc", - ["solaris-intel"] = "solaris-intel", - ["solaris-sparc"] = "solaris-sparc", - ["solaris"] = "solaris-sparc", + ["mswin"] = "mswin", + ["windows"] = "mswin", + ["win32"] = "mswin", + ["win"] = "mswin", + ["linux"] = "linux", + ["freebsd"] = "freebsd", + ["freebsd-amd64"] = "freebsd-amd64", + ["kfreebsd"] = "kfreebsd-i386", + ["kfreebsd-i386"] = "kfreebsd-i386", + ["kfreebsd-amd64"] = "kfreebsd-amd64", + ["linux-32"] = "linux", + ["linux-64"] = "linux-64", + ["linux32"] = "linux", + ["linux64"] = "linux-64", + ["linux-ppc"] = "linux-ppc", + ["ppc"] = "linux-ppc", + ["osx"] = "osx-intel", + ["macosx"] = "osx-intel", + ["osx-intel"] = "osx-intel", + ["osx-ppc"] = "osx-ppc", + ["osx-powerpc"] = "osx-ppc", + ["osx-64"] = "osx-64", + ["osxintel"] = "osx-intel", + ["osxppc"] = "osx-ppc", + ["osxpowerpc"] = "osx-ppc", + ["solaris-intel"] = "solaris-intel", + ["solaris-sparc"] = "solaris-sparc", + ["solaris"] = "solaris-sparc", } -- the list is filled up later (when we know what modules to download) @@ -144,12 +150,14 @@ scripts.update.modules = { } function scripts.update.run(str) - logs.report("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) if environment.argument("force") then - -- 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) + logs.report("run", str) os.execute(str) + else + logs.report("dry run", str) end end @@ -165,16 +173,16 @@ function scripts.update.synchronize() logs.report("update","start") - local texroot = scripts.update.fullpath(states.get("paths.root")) - local engines = states.get('engines') or { } - local platforms = states.get('platforms') or { } - local repositories = states.get('repositories') -- minimals - 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 goodies = states.get("goodies") -- goodies (like editors) - local force = environment.argument("force") + local texroot = scripts.update.fullpath(states.get("paths.root")) + local engines = states.get('engines') or { } + local platforms = states.get('platforms') or { } + local repositories = states.get('repositories') -- minimals + 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 goodies = states.get("goodies") -- goodies (like editors) + local force = environment.argument("force") bin = string.gsub(bin,"\\","/") @@ -188,18 +196,19 @@ function scripts.update.synchronize() if force then dir.mkdirs(format("%s/%s", texroot, "texmf-cache")) dir.mkdirs(format("%s/%s", texroot, "texmf-local")) + dir.mkdirs(format("%s/%s", texroot, "texmf-project")) end if ok or not force then - local fetched, individual, osplatform = { }, { }, os.currentplatform() + local fetched, individual, osplatform = { }, { }, os.platform -- takes a collection as argument and returns a list of folders local function collection_to_list_of_folders(collection, platform) local archives = {} - for _, c in ipairs(collection) do - local archive = c[1] + for i=1,#collection do + local archive = collection[i][1] archive = archive:gsub("<platform>", platform) archive = archive:gsub("<version>", version) archives[#archives+1] = archive @@ -220,7 +229,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.currentplatform))) + -- example of usage: print(list_of_folders_to_rsync_string(collection_to_list_of_folders(scripts.update.base, os.platform))) -- rename function and add some more functionality: -- * recursive/non-recursive (default: non-recursive) @@ -255,7 +264,8 @@ function scripts.update.synchronize() local available_modules = get_list_of_files_from_rsync({"modules/"}) -- hash of requested modules -- local h = table.tohash(extras:split(",")) - for _, s in ipairs(available_modules) do + 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" } @@ -269,7 +279,8 @@ function scripts.update.synchronize() if collection and platform then platform = scripts.update.platforms[platform] if platform then - for _, c in ipairs(collection) do + for i=1,#collection do + local c = collection[i] local archive = c[1]:gsub("<platform>", platform) local destination = format("%s/%s", texroot, c[2]:gsub("<platform>", platform)) destination = destination:gsub("\\","/") @@ -283,30 +294,32 @@ function scripts.update.synchronize() end end - for platform, _ in pairs(platforms) do + for platform, _ in next, platforms do add_collection(scripts.update.base,platform) end - for platform, _ in pairs(platforms) do + for platform, _ in next, platforms do add_collection(scripts.update.modules,platform) end - for engine, _ in pairs(engines) do - for platform, _ in pairs(platforms) do + for engine, _ in next, engines do + for platform, _ in next, platforms do add_collection(scripts.update.engines[engine],platform) end end if goodies and type(goodies) == "table" then - for goodie, _ in pairs(goodies) do - for platform, _ in pairs(platforms) do + for goodie, _ in next, goodies do + for platform, _ in next, platforms do add_collection(scripts.update.goodies[goodie],platform) end end end local combined = { } - for _, repository in ipairs(scripts.update.repositories) do + local update_repositories = scripts.update.repositories + for i=1,#update_repositories do + local repository = update_repositories[i] if repositories[repository] then - for _, v in pairs(individual) do + for _, v in next, individual do local archive, destination = v[1], v[2] local cd = combined[destination] if not cd then @@ -318,14 +331,14 @@ function scripts.update.synchronize() end end if logs.verbose then - for k, v in pairs(combined) do + for k, v in next, combined do logs.report("update", k) - for k,v in ipairs(v) do - logs.report("update", " <= " .. v) + for i=1,#v do + logs.report("update", " <= " .. v[i]) end end end - for destination, archive in pairs(combined) do + for destination, archive in next, combined do local archives, command = concat(archive," "), "" -- local normalflags, deleteflags = states.get("rsync.flags.normal"), states.get("rsync.flags.delete") -- if environment.argument("keep") or destination:find("%.$") then @@ -334,13 +347,17 @@ function scripts.update.synchronize() -- command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination) -- end local normalflags, deleteflags = states.get("rsync.flags.normal"), "" + local dryrunflags = "" + 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 deleteflags = states.get("rsync.flags.delete") end - command = format("%s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, url, archives, destination) - logs.report("mtx update", format("running command: %s",command)) + command = format("%s %s %s %s %s'%s' '%s'", bin, normalflags, deleteflags, dryrunflags, url, archives, destination) + --logs.report("mtx update", format("running command: %s",command)) if not fetched[command] then - scripts.update.run(command) + scripts.update.run(command,true) fetched[command] = command end end @@ -363,7 +380,7 @@ function scripts.update.synchronize() end end - for platform, _ in pairs(platforms) do + for platform, _ in next, platforms do update_script('luatools',platform) update_script('mtxrun',platform) end @@ -374,12 +391,20 @@ function scripts.update.synchronize() if not force then logs.report("update", "use --force to really update files") end + + resolvers.load_tree(texroot) -- else we operate in the wrong tree + + -- update filename database for pdftex/xetex + scripts.update.run("mktexlsr") + -- update filename database for luatex + scripts.update.run("luatools --generate") + logs.report("update","done") end function table.fromhash(t) local h = { } - for k, v in pairs(t) do -- no ipairs here + for k, v in next, t do -- not indexed if v then h[#h+1] = k end end return h @@ -390,34 +415,34 @@ function scripts.update.make() logs.report("make","start") - local force = environment.argument("force") - local texroot = scripts.update.fullpath(states.get("paths.root")) - local engines = states.get('engines') - local goodies = states.get('goodies') + local force = environment.argument("force") + local texroot = scripts.update.fullpath(states.get("paths.root")) + local engines = states.get('engines') + local goodies = states.get('goodies') local platforms = states.get('platforms') - local formats = states.get('formats') + local formats = states.get('formats') resolvers.load_tree(texroot) - -- update filename database for pdftex/xetex + scripts.update.run("mktexlsr") - -- update filename database for luatex scripts.update.run("luatools --generate") + local askedformats = formats local texformats = table.tohash(scripts.update.texformats) local mpformats = table.tohash(scripts.update.mpformats) - for k,v in pairs(texformats) do + for k,v in next, texformats do if not askedformats[k] then texformats[k] = nil end end - for k,v in pairs(mpformats) do + for k,v in next, mpformats do if not askedformats[k] then mpformats[k] = nil end end local formatlist = concat(table.fromhash(texformats), " ") if formatlist ~= "" then - for engine in pairs(engines) do + for engine in next, engines do if engine == "luatex" then scripts.update.run(format("context --make")) -- maybe also formatlist else @@ -438,7 +463,7 @@ function scripts.update.make() logs.report("make","done") end -logs.extendbanner("Download Tools 0.20",true) +logs.extendbanner("ConTeXt Minimals Updater 0.21",true) messages.help = [[ --platform=string platform (windows, linux, linux-64, osx-intel, osx-ppc, linux-ppc) @@ -476,7 +501,7 @@ if scripts.savestate then states.set("rsync.program", environment.argument("rsync"), "rsync", true) -- ok states.set("rsync.server", environment.argument("server"), "contextgarden.net::", true) -- ok states.set("rsync.module", environment.argument("module"), "minimals", true) -- ok - states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv --stats", true) -- ok + states.set("rsync.flags.normal", environment.argument("flags"), "-rpztlv", true) -- ok states.set("rsync.flags.delete", nil, "--delete", true) -- ok states.set("paths.root", environment.argument("texroot"), "tex", true) -- ok @@ -490,7 +515,7 @@ if scripts.savestate then local valid = scripts.update.engines for r in gmatch(environment.argument("engine") or "all","([^, ]+)") do if r == "all" then - for k, v in pairs(valid) do + for k, v in next, valid do if k ~= "all" then states.set("engines." .. k, true) end @@ -500,7 +525,7 @@ if scripts.savestate then end end local valid = scripts.update.platforms - for r in gmatch(environment.argument("platform") or os.currentplatform(),"([^, ]+)") do + for r in gmatch(environment.argument("platform") or os.platform,"([^, ]+)") do if valid[r] then states.set("platforms." .. r, true) end end |