summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2008-01-28 21:28:00 +0100
committerHans Hagen <pragma@wxs.nl>2008-01-28 21:28:00 +0100
commitf0302311dd47bf250c0e2b5f8be46f21437f43d8 (patch)
treece920dd169066a8dcdf13b81490816ab58c0e4cd /scripts
parente3467ba8810e788b01d8e7ce2e16d3c8ffdd3e2a (diff)
downloadcontext-f0302311dd47bf250c0e2b5f8be46f21437f43d8.tar.gz
stable 2008.01.28 21:28
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/luatools.lua31
-rw-r--r--scripts/context/lua/mtx-context.lua8
-rw-r--r--scripts/context/lua/mtx-convert.lua2
-rw-r--r--scripts/context/lua/mtx-update.lua268
-rw-r--r--scripts/context/lua/mtx-watch.lua4
-rw-r--r--scripts/context/lua/mtxrun.lua12
6 files changed, 291 insertions, 34 deletions
diff --git a/scripts/context/lua/luatools.lua b/scripts/context/lua/luatools.lua
index 165221fb4..b6a158f6e 100644
--- a/scripts/context/lua/luatools.lua
+++ b/scripts/context/lua/luatools.lua
@@ -1454,18 +1454,14 @@ function os.resultof(command)
return io.popen(command,"r"):read("*all")
end
-if not os.exec then -- still not ok
- os.exec = os.execute
-end
-if not os.spawn then -- still not ok
- os.spawn = os.execute
-end
+if not os.exec then os.exec = os.execute end
+if not os.spawn then os.spawn = os.execute end
function os.launch(str)
if os.platform == "windows" then
- os.execute("start " .. str)
+ os.execute("start " .. str) -- os.spawn ?
else
- os.execute(str .. " &")
+ os.execute(str .. " &") -- os.spawn ?
end
end
@@ -2107,17 +2103,15 @@ function utils.lua.compile(luafile, lucfile)
if utils.lua.compile_strip then
command = "-s " .. command
end
- if os.execute("texluac " .. command) == 0 then
+ if os.spawn("texluac " .. command) == 0 then
return true
- elseif os.execute("luac " .. command) == 0 then
+ elseif os.spawn("luac " .. command) == 0 then
return true
else
return false
end
end
-
-
-- filename : luat-lib.lua
-- comment : companion to luat-lib.tex
-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
@@ -6096,17 +6090,14 @@ function input.my_make_format(instance,texname)
input.report("using lua initialization file " .. luaname)
local flags = { "--ini" }
if environment.arguments["mkii"] then
- -- flags[#flags+1] = "--mkii" -- web2c error
flags[#flags+1] = "--progname=" .. instance.progname
else
- -- flags[#flags+1] = "--lua=" .. string.quote(luaname)
- flags[#flags+1] = string.quote("--lua=" .. luaname)
- -- flags[#flags+1] = "--progname=" .. instance.progname -- potential fallback
+ flags[#flags+1] = "--lua=" .. string.quote(luaname)
end
local bs = (environment.platform == "unix" and "\\\\") or "\\" -- todo: make a function
local command = "luatex ".. table.concat(flags," ") .. " " .. string.quote(fullname) .. " " .. bs .. "dump"
input.report("running command: " .. command .. "\n")
- os.exec(command)
+ os.spawn(command)
end
end
else
@@ -6139,11 +6130,9 @@ function input.my_run_format(instance,name,data,more)
end
if f then
f:close()
- -- bug, no .fmt !
- -- local command = "luatex --fmt=" .. string.quote(barename) .. " --lua=" .. string.quote(luaname) .. " " .. string.quote(data) .. " " .. string.quote(more)
- local command = "luatex " .. string.quote("--fmt=" .. barename) .. " " .. string.quote("--lua=" .. luaname) .. " " .. string.quote(data) .. " " .. string.quote(more)
+ local command = "luatex --fmt=" .. string.quote(barename) .. " --lua=" .. string.quote(luaname) .. " " .. string.quote(data) .. " " .. string.quote(more)
input.report("running command: " .. command)
- os.exec(command)
+ os.spawn(command)
else
input.report("using format name",fmtname)
input.report("no luc/lua with name",barename)
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index 9ecaa7198..3abd270aa 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -335,7 +335,7 @@ do
-- potential optimization: when mtxrun run internal
command = ctxrunner.justtext(command) -- command is still xml element here
input.report("command",command)
- local result = os.execute(command)
+ local result = os.spawn(command)
if result > 0 then
input.report("error, return code",result)
end
@@ -554,7 +554,7 @@ function scripts.context.run(ctxdata)
scripts.context.multipass.makeoptionfile(jobname,ctxdata)
for i=1, scripts.context.multipass.nofruns do
input.report(string.format("run %s: %s",i,command))
- local returncode = os.execute(command)
+ local returncode = os.spawn(command)
input.report("return code: " .. returncode)
if returncode > 0 then
input.report("fatal error, run aborted")
@@ -582,7 +582,7 @@ function scripts.context.make()
for _, name in ipairs( { "cont-en", "cont-nl", "mptopdf" } ) do
local command = "luatools --make --compile " .. name
input.report("running command: " .. command)
- os.execute(command)
+ os.spawn(command)
end
end
@@ -590,7 +590,7 @@ function scripts.context.generate()
-- hack, should also be a shared function
local command = "luatools --generate " .. name
input.report("running command: " .. command)
- os.execute(command)
+ os.spawn(command)
end
function scripts.context.ctx()
diff --git a/scripts/context/lua/mtx-convert.lua b/scripts/context/lua/mtx-convert.lua
index c9827c8b7..1bfc10c0f 100644
--- a/scripts/context/lua/mtx-convert.lua
+++ b/scripts/context/lua/mtx-convert.lua
@@ -25,7 +25,7 @@ do
dir.mkdirs(outputpath)
local tmpname = file.replacesuffix(newname,"tmp")
local command = string.format(gstemplate,gsprogram,tmpname,oldname)
- os.execute(command)
+ os.spawn(command)
os.remove(newname)
os.rename(tmpname,newname)
end
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
new file mode 100644
index 000000000..cfe553731
--- /dev/null
+++ b/scripts/context/lua/mtx-update.lua
@@ -0,0 +1,268 @@
+if not modules then modules = { } end modules ['mtx-update'] = {
+ version = 1.001,
+ comment = "companion to mtxrun.lua",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- This script is dedicated to Mojca Miklavec, who is the driving force behind
+-- moving minimal generation from our internal machines to the context garden.
+-- Together with Arthur Reutenauer she made sure that it worked well on all
+-- platforms that matter.
+
+texmf.instance = instance -- we need to get rid of this / maybe current instance in global table
+
+scripts = scripts or { }
+scripts.update = scripts.update or { }
+
+minimals = minimals or { }
+minimals.config = minimals.config or { }
+
+scripts.update.collections = {
+ ["luatex"] = {
+ { "base/tex/", "texmf" },
+ { "base/metapost/", "texmf" },
+ { "fonts/new/", "texmf" },
+ { "fonts/common/", "texmf" },
+ { "fonts/other/", "texmf" },
+ { "context/current/", "texmf-context" },
+ { "context/img/", "texmf-context" },
+ { "misc/setuptex/", "." },
+ { "misc/web2c", "texmf" },
+ { "bin/common/%s/", "texmf-%s" },
+ { "bin/context/%s/", "texmf-%s" },
+ { "bin/metapost/%s/", "texmf-%s" },
+ { "bin/luatex/%s/", "texmf-%s" },
+ { "bin/man/", "texmf-%s" }
+ },
+ ["xetex"] = {
+ { "base/tex/", "texmf" },
+ { "base/metapost/", "texmf" },
+ { "base/xetex/", "texmf" },
+ { "fonts/new/", "texmf" },
+ { "fonts/common/", "texmf" },
+ { "fonts/other/", "texmf" },
+ { "context/current/", "texmf-context" },
+ { "context/img/", "texmf-context" },
+ { "misc/setuptex/", "." },
+ { "misc/web2c", "texmf" },
+ { "bin/common/%s/", "texmf-%s" },
+ { "bin/context/%s/", "texmf-%s" },
+ { "bin/metapost/%s/", "texmf-%s" },
+ { "bin/xetex/%s/", "texmf-%s" },
+ { "bin/man/", "texmf-%s" }
+ },
+ ["pdftex"] = {
+ { "base/tex/", "texmf" },
+ { "base/metapost/", "texmf" },
+ { "fonts/old/", "texmf" },
+ { "fonts/common/", "texmf" },
+ { "fonts/other/", "texmf" },
+ { "context/current/", "texmf-context" },
+ { "context/img/", "texmf-context" },
+ { "misc/setuptex/", "." },
+ { "misc/web2c", "texmf" },
+ { "bin/common/%s/", "texmf-%s" },
+ { "bin/context/%s/", "texmf-%s" },
+ { "bin/metapost/%s/", "texmf-%s" },
+ { "bin/pdftex/%s/", "texmf-%s" },
+ { "bin/man/", "texmf-%s" }
+ },
+ ["all"] = {
+ { "base/tex/", "texmf" },
+ { "base/metapost/", "texmf" },
+ { "base/xetex/", "texmf" },
+ { "fonts/old/", "texmf" },
+ { "fonts/new/", "texmf" },
+ { "fonts/common/", "texmf" },
+ { "fonts/other/", "texmf" },
+ { "context/current/", "texmf-context" },
+ { "context/img/", "texmf-context" },
+ { "misc/setuptex/", "." },
+ { "misc/web2c", "texmf" },
+ { "bin/common/%s/", "texmf-%s" },
+ { "bin/context/%s/", "texmf-%s" },
+ { "bin/metapost/%s/", "texmf-%s" },
+ { "bin/luatex/%s/", "texmf-%s" },
+ { "bin/xetex/%s/", "texmf-%s" },
+ { "bin/pdftex/%s/", "texmf-%s" },
+ { "bin/man/", "texmf-%s" }
+ },
+}
+
+scripts.update.platforms = {
+ ["mswin"] = "mswin",
+ ["windows"] = "mswin",
+ ["win32"] = "mswin",
+ ["win"] = "mswin",
+ ["linux"] = "linux",
+ ["linux-32"] = "linux",
+ ["linux-64"] = "linux-64",
+ ["osx"] = "osx-intel",
+ ["osx-intel"] = "osx-intel",
+ ["osx-ppc"] = "osx-ppc",
+}
+
+scripts.update.rsyncflagspath = "-rpztlv --stats --delete"
+scripts.update.rsyncflagsroot = "-rpztlv --stats"
+
+function scripts.update.prepare()
+ local texroot = environment.argument("texroot") or "tex"
+ local engines = environment.argument("engine")
+ if engines then
+ engines = engines:split(",")
+ else
+ engines = minimals.config.engines or { "all" }
+ end
+ local platforms = environment.argument("platform")
+ if platforms then
+ platforms = platforms:split(",")
+ else
+ platforms = minimals.config.platform or { os.currentplatform() }
+ end
+ return texroot, engines, platforms
+end
+
+function scripts.update.run(str)
+ if environment.argument("dryrun") then
+ logs.report("run", str)
+ else
+ -- 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)
+ os.spawn(str)
+ end
+end
+
+function scripts.update.synchronize()
+ local texroot, engines, platforms = scripts.update.prepare()
+ local dryrun = environment.argument("dryrun")
+ os.setenv("CYGWIN","nontsec")
+ local rsyncbin = environment.argument("rsync") or "rsync"
+ local url = environment.argument("url") or "contextgarden.net::"
+ if not url:find("::$") then url = url .. "::" end
+ local ok = lfs.attributes(texroot,"mode") == "directory"
+ if not ok and not dryrun then
+ dir.mkdirs(texroot)
+ ok = lfs.attributes(texroot,"mode") == "directory"
+ end
+ if ok or dryrun then
+ if not dryrun then
+ dir.mkdirs(string.format("%s/%s", texroot, "texmf-cache"))
+ end
+ local fetched = { }
+ local individual = { }
+ local context = environment.argument("context")
+ for _, engine in ipairs(engines) do
+ local collections = scripts.update.collections[engine]
+ if collections then
+ for _, collection in ipairs(collections) do
+ for _, platform in ipairs(platforms) do
+ platform = scripts.update.platforms[platform]
+ if platform then
+ local archive = string.format(collection[1], platform)
+ local destination = string.format("%s/%s", texroot, string.format(collection[2], platform))
+ destination = destination:gsub("\\","/")
+ if platform == "windows" or platform == "mswin" then
+ destination = destination:gsub("([a-zA-Z]):/", "/cygdrive/%1/")
+ end
+ -- if one uses experimental, context=... has no effect
+ if context and not environment.argument("experimental") then
+ archive = archive:gsub("/current/", "/" .. context .. "/")
+ end
+ individual[#individual+1] = { archive, destination }
+ end
+ end
+ end
+ end
+ end
+ local combined = { }
+ local distributions = { "current" }
+ -- we need to fetch files from both "current" and "experimental" branch
+ if environment.argument("experimental") then
+ distributions = { "experimental", "current" }
+ end
+ for _, d in pairs(distributions) do
+ for _, v in pairs(individual) do
+ local archive, destination = v[1], v[2]
+ local cd = combined[destination]
+ if not cd then
+ cd = { }
+ combined[destination] = cd
+ end
+ cd[#cd+1] = 'minimals/' .. d .. '/' .. archive
+ end
+ end
+ if input.verbose then
+ for k, v in pairs(combined) do
+ logs.report("update", k)
+ for k,v in ipairs(v) do
+ logs.report("update", " <= " .. v)
+ end
+ end
+ end
+ for destination, archive in pairs(combined) do
+ local archives, command = table.concat(archive," "), ""
+ if not environment.argument("delete") or destination:find("%.$") then
+ command = string.format("%s %s %s'%s' %s", rsyncbin, scripts.update.rsyncflagsroot, url, archives, destination)
+ else
+ command = string.format("%s %s %s'%s' %s", rsyncbin, scripts.update.rsyncflagspath, url, archives, destination)
+ end
+ logs.report("mtx update", string.format("running command: %s",command))
+ if not fetched[command] then
+ scripts.update.run(command)
+ fetched[command] = command
+ end
+ end
+ else
+ logs.report("mtx update", string.format("no valid texroot: %s",texroot))
+ end
+ if environment.argument("make") then
+ scripts.update.make()
+ end
+end
+
+function scripts.update.make()
+ local texroot, engines, platforms = scripts.update.prepare()
+ input.load_tree(texroot)
+ scripts.update.run("mktexlsr")
+ scripts.update.run("luatools --generate")
+ engines = (engines[1] and engines[1] == "all" and { "pdftex", "xetex", "luatex" }) or engines
+ for _, engine in ipairs(engines) do
+ scripts.update.run(string.format("texexec --make --all --fast --%s",engine))
+ end
+end
+
+banner = banner .. " | download tools "
+
+input.runners.save_list = {
+ "update", "engine", "platform", "url", "rsync", "texroot", "dryrun", "make", "delete", "context"
+}
+
+messages.help = [[
+--update update minimal tree
+--engine tex engine (luatex, pdftex, xetex)
+--platform platform (windows, linux, linux-64, osx-intel, osx-ppc)
+--url repository url (rsync://contextgarden.net/minimals)
+--rsync rsync binary (rsync)
+--texroot installation directory (not guessed for the moment)
+--dryrun just show what will be done
+--make also make formats and generate file databases
+--delete delete unused files
+--context=string specify version (current, experimental, yyyy.mm.dd)
+]]
+
+input.verbose = true
+
+if environment.argument("update") then
+ logs.report("update","start")
+ scripts.update.synchronize()
+ logs.report("update","done")
+elseif environment.argument("make") then
+ logs.report("make","start")
+ scripts.update.make()
+ logs.report("make","done")
+else
+ input.help(banner,messages.help)
+end
diff --git a/scripts/context/lua/mtx-watch.lua b/scripts/context/lua/mtx-watch.lua
index 651865ab4..96f6f7eb2 100644
--- a/scripts/context/lua/mtx-watch.lua
+++ b/scripts/context/lua/mtx-watch.lua
@@ -76,10 +76,10 @@ function scripts.watch.watch()
if newpath ~= "" and newpath ~= "." then
local oldpath = lfs.currentdir()
lfs.chdir(newpath)
- if pipe then result = os.resultof(command) else result = os.execute(command) end
+ if pipe then result = os.resultof(command) else result = os.spawn(command) end
lfs.chdir(oldpath)
else
- if pipe then result = os.resultof(command) else result = os.execute(command) end
+ if pipe then result = os.resultof(command) else result = os.spawn(command) end
end
logs.report("watch",string.format("return value: %s", result))
done = true
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 0b6720a4e..d0c7469e0 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -1497,9 +1497,9 @@ end
function os.launch(str)
if os.platform == "windows" then
- os.execute("start " .. str)
+ os.spawn("start " .. str)
else
- os.execute(str .. " &")
+ os.spawn(str .. " &")
end
end
@@ -3914,9 +3914,9 @@ function utils.lua.compile(luafile, lucfile)
if utils.lua.compile_strip then
command = "-s " .. command
end
- if os.execute("texluac " .. command) == 0 then
+ if os.spawn("texluac " .. command) == 0 then
return true
- elseif os.execute("luac " .. command) == 0 then
+ elseif os.spawn("luac " .. command) == 0 then
return true
else
return false
@@ -7322,7 +7322,7 @@ function input.runners.execute_script(instance,fullname,internal)
input.report("executing: " .. command)
input.report("\n \n")
io.flush()
- local code = os.exec(command)
+ local code = os.exec(command) -- maybe spawn
return code == 0
end
end
@@ -7347,7 +7347,7 @@ function input.runners.execute_program(instance,fullname)
input.report("executing: " .. command)
input.report("\n \n")
io.flush()
- local code = os.exec(command) -- (fullname,unpack(after)) does not work
+ local code = os.exec(command) -- (fullname,unpack(after)) does not work / maybe spawn
return code == 0
end
end