summaryrefslogtreecommitdiff
path: root/scripts/context/lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/lua')
-rw-r--r--scripts/context/lua/mtx-cache.lua99
-rw-r--r--scripts/context/lua/mtx-install.lua17
2 files changed, 59 insertions, 57 deletions
diff --git a/scripts/context/lua/mtx-cache.lua b/scripts/context/lua/mtx-cache.lua
index 56d3df188..4f378ff0a 100644
--- a/scripts/context/lua/mtx-cache.lua
+++ b/scripts/context/lua/mtx-cache.lua
@@ -12,12 +12,12 @@ local helpinfo = [[
<metadata>
<entry name="name">mtx-cache</entry>
<entry name="detail">ConTeXt &amp; MetaTeX Cache Management</entry>
- <entry name="version">0.10</entry>
+ <entry name="version">1.01</entry>
</metadata>
<flags>
<category name="basic">
<subcategory>
- <flag name="purge"><short>remove not used files</short></flag>
+ <flag name="make"><short>generate databases and formats</short></flag>
<flag name="erase"><short>completely remove cache</short></flag>
<flag name="list"><short>show cache</short></flag>
</subcategory>
@@ -48,97 +48,86 @@ scripts.cache = scripts.cache or { }
local function collect(path)
local all = dir.glob(path .. "/**/*")
- local tmas, tmcs, rest = { }, { }, { }
+ local ext = table.setmetatableindex("table")
for i=1,#all do
local name = all[i]
- local suffix = filesuffix(name)
- if suffix == "tma" then
- tmas[#tmas+1] = name
- elseif suffix == "tmc" then
- tmcs[#tmcs+1] = name
- else
- rest[#rest+1] = name
- end
+ local list = ext[filesuffix(name)]
+ list[#list+1] = name
end
- return tmas, tmcs, rest, all
+ return ext
end
-local function list(banner,path,tmas,tmcs,rest)
+local function list(banner,path,ext)
+ local total = 0
report("%s: %s",banner,path)
report()
- report("tma : %4i",#tmas)
- report("tmc : %4i",#tmcs)
- report("rest : %4i",#rest)
- report("total : %4i",#tmas+#tmcs+#rest)
+ for k, v in table.sortedhash(ext) do
+ total = total + #v
+ report("%-6s : %4i",k,#v)
+ end
+ report()
+ report("total : %4i",total)
report()
end
-local function purge(banner,path,list,all)
+local function erase(banner,path,list)
report("%s: %s",banner,path)
report()
- local fonts = environment.argument("fonts")
- local n = 0
- for i=1,#list do
- local filename = list[i]
- if find(filename,"luatex%-cache") then -- safeguard
- if fonts and not find(filename,"fonts") then
- -- skip
- elseif all then
+ for ext, list in table.sortedhash(list) do
+ local gone = 0
+ local kept = 0
+ for i=1,#list do
+ local filename = list[i]
+ if find(filename,"luatex%-cache") then
remove(filename)
- n = n + 1
- elseif not fonts or find(filename,"fonts") then
- local suffix = filesuffix(filename)
- if suffix == "tma" then
- local checkname = replacesuffix(filename,"tma","tmc")
- if isfile(checkname) then
- remove(filename)
- n = n + 1
- end
+ if isfile(filename) then
+ kept = kept + 1
+ else
+ gone = gone + 1
end
end
end
+ report("%-6s : %4i gone, %4i kept",ext,gone,kept)
end
- report("removed tma files : %i",n)
report()
- return n
end
-function scripts.cache.purge()
- local writable = caches.getwritablepath()
- local tmas, tmcs, rest = collect(writable)
- list("writable path",writable,tmas,tmcs,rest)
- purge("writable path",writable,tmas)
- list("writable path",writable,tmas,tmcs,rest)
+function scripts.cache.make()
+ os.execute("mtxrun --generate")
+ os.execute("context --make")
+ os.execute("mtxrun --script font --reload")
end
function scripts.cache.erase()
local writable = caches.getwritablepath()
- local tmas, tmcs, rest, all = collect(writable)
- list("writable path",writable,tmas,tmcs,rest)
- purge("writable path",writable,all,true)
- list("writable path",writable,tmas,tmcs,rest)
+ local groups = collect(writable)
+ list("writable path",writable,groups)
+ erase("writable path",writable,groups)
+ if environment.argument("make") then
+ scripts.cache.make()
+ end
end
function scripts.cache.list()
local readables = caches.getreadablepaths()
- local writable = caches.getwritablepath()
- local tmas, tmcs, rest = collect(writable)
- list("writable path",writable,tmas,tmcs,rest)
+ local writable = caches.getwritablepath()
+ local groups = collect(writable)
+ list("writable path",writable,groups)
for i=1,#readables do
local readable = readables[i]
if readable ~= writable then
- local tmas, tmcs = collect(readable)
- list("readable path",readable,tmas,tmcs,rest)
+ local groups = collect(readable)
+ list("readable path",readable,groups)
end
end
end
-if environment.argument("purge") then
- scripts.cache.purge()
-elseif environment.argument("erase") then
+if environment.argument("erase") then
scripts.cache.erase()
elseif environment.argument("list") then
scripts.cache.list()
+elseif environment.argument("make") then
+ scripts.cache.make()
elseif environment.argument("exporthelp") then
application.export(environment.argument("exporthelp"),environment.files[1])
else
diff --git a/scripts/context/lua/mtx-install.lua b/scripts/context/lua/mtx-install.lua
index 48b458897..cf6ba4e98 100644
--- a/scripts/context/lua/mtx-install.lua
+++ b/scripts/context/lua/mtx-install.lua
@@ -26,6 +26,7 @@ local helpinfo = [[
<flag name="goodies" value="string"><short>extra binaries (like scite and texworks)</short></flag>
<flag name="install"><short>install context</short></flag>
<flag name="update"><short>update context</short></flag>
+ <flag name="erase"><short>wipe the cache</short></flag>
<flag name="identify"><short>create list of files</short></flag>
</subcategory>
</category>
@@ -398,8 +399,15 @@ function install.update()
local server = environment.arguments.server or ""
local instance = environment.arguments.instance or ""
- local osplatform = environment.arguments.platform or os.platform
- local platform = platforms[osplatform]
+ local osplatform = environment.arguments.platform or nil
+ local platform = platforms[osplatform or os.platform or ""]
+
+ if platform == "unknown" and osplatform then
+ -- catches openbsdN.M kind of specifications
+ platform = osplatform
+ elseif not osplatform then
+ osplatform = platform
+ end
if server == "" then
server = "lmtx.contextgarden.net,lmtx.pragma-ade.com,lmtx.pragma-ade.nl,dmz.pragma-ade.nl"
@@ -531,8 +539,13 @@ function install.update()
end
run("%s --generate",mtxrunbin)
+ if environment.argument("erase") then
+ run("%s --script cache --erase",mtxrunbin)
+ run("%s --generate",mtxrunbin)
+ end
run("%s --make en", contextbin)
+
-- in calling script: update mtxrun.exe and mtxrun.lua
report("")