summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2023-05-27 12:37:50 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2023-05-27 12:37:50 +0200
commit32381f97e98465953bfde24b4436093e70fbe70f (patch)
tree1f585cf7af509e76c64aca108cecd23acd6fb437 /scripts
parentbb8ae12f4f94189fd1540b201e2aea78f485de97 (diff)
downloadcontext-32381f97e98465953bfde24b4436093e70fbe70f.tar.gz
2023-05-27 12:16:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-install-modules.lua155
-rw-r--r--scripts/context/lua/mtxrun.lua53
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua53
-rw-r--r--scripts/context/stubs/source/readme.txt80
-rw-r--r--scripts/context/stubs/unix/mtxrun53
-rw-r--r--scripts/context/stubs/win64/mtxrun.lua53
6 files changed, 304 insertions, 143 deletions
diff --git a/scripts/context/lua/mtx-install-modules.lua b/scripts/context/lua/mtx-install-modules.lua
index 2073cf6e1..63b892966 100644
--- a/scripts/context/lua/mtx-install-modules.lua
+++ b/scripts/context/lua/mtx-install-modules.lua
@@ -29,6 +29,8 @@ if not modules then modules = { } end modules ['mtx-install-modules'] = {
-- Maybe some day we can get the modules from ctan but then we need a consistent
-- names and such.
+local find = string.find
+
local helpinfo = [[
<?xml version="1.0"?>
<application>
@@ -41,7 +43,9 @@ local helpinfo = [[
<category name="basic">
<subcategory>
<flag name="list"><short>list modules</short></flag>
+ <flag name="installed"><short>list installed modules</short></flag>
<flag name="install"><short>install modules</short></flag>
+ <flag name="uninstall"><short>uninstall modules</short></flag>
<flag name="module"><short>install (zip) file(s)</short></flag>
</subcategory>
</category>
@@ -58,14 +62,17 @@ local helpinfo = [[
<example><command>mtxrun --script install-modules --install --all</command></example>
</subcategory>
<subcategory>
- <example><command>mtxrun --script install-modules --install --module t-letter.zip</command></example>
+ <example><command>mtxrun --script install-modules --install --module t-letter.zip</command></example>
+ <example><command>mtxrun --script install-modules --uninstall --module t-letter.zip</command></example>
+ </subcategory>
+ <subcategory>
+ <example><command>mtxrun --script install-modules --installed</command></example>
</subcategory>
</category>
</examples>
</application>
]]
-
local application = logs.application {
name = "mtx-install-modules",
banner = "ConTeXt Module Installer 1.00",
@@ -97,11 +104,22 @@ end or function(str)
return data
end
+-- We use some abstraction:
+
local urls = {
ctan = "https://mirrors.ctan.org/install",
modules = "https://modules.contextgarden.net/dl"
}
+-- Some package this in the root which is asking for conflicts.
+
+-- local badones = {
+-- -- "LICENSE",
+-- -- "README",
+-- -- "README.md",
+-- -- "VERSION",
+-- }
+
local tmpzipfile = "temp.zip"
local checkdir = "texmf-context"
local targetdir = "texmf-modules"
@@ -149,35 +167,69 @@ local function loadlists()
else
report("base file %a is not found",basefile)
end
+ report()
end
- report()
end
-local function install(list)
- if type(list) ~= "table"then
+local function validate(n)
+ return not (
+ find(n,"latex")
+ -- or find(n,"lualatex")
+ or find(n,"plain")
+ or find(n,"optex")
+ or find(n,"luatex")
+ or find(n,"pdftex")
+ )
+end
+
+local function install(list,wipe)
+ if type(list) ~= "table" then
report("unknown specification")
end
- local zips = list.zips
- local wipes = list.wipes
+ local zips = list.zips
+ local wipes = list.wipes
if type(zips) ~= "table" then
report("incomplete specification")
else
- report("installing into %a",targetdir)
+ -- report("installing into %a",targetdir)
for i=1,#zips do
- local where = urls[list.url] .. "/" .. zips[i]
- local data = fetched(where)
- if string.find(data,"^PK") then
- io.savedata(tmpzipfile,data)
- report("from %a",where)
- report("into %a",targetdir)
- utilities.zipfiles.unzipdir {
- zipname = tmpzipfile,
- path = ".",
- verbose = "steps",
- }
- os.remove(tmpzipfile)
- else
- report("unknown %a",where)
+ local remote = list.url
+ local where = zips[i]
+ local hash = file.addsuffix(sha2.HASH256(where),"tma")
+ local data = table.load(hash)
+ if data then
+ local name = data.name
+ local list = data.list
+ if name and list then
+ report()
+ report("removing %i old files for %a",#list,name)
+ report()
+ for i=1,#list do
+ os.remove(list[i])
+ end
+ end
+ end
+ if not wipe then
+ if remote then
+ where = (urls[remote] or remote) .. "/" .. where
+ end
+ local data = fetched(where)
+ if string.find(data,"^PK") then
+ io.savedata(tmpzipfile,data)
+ report("from %a",where)
+ report("into %a",targetdir)
+ local done = utilities.zipfiles.unzipdir {
+ zipname = tmpzipfile,
+ path = ".",
+ verbose = "steps",
+ collect = true,
+ validate = validate,
+ }
+ table.save(hash,{ name = where, list = done })
+ os.remove(tmpzipfile)
+ else
+ report("unknown %a",where)
+ end
end
end
@@ -209,7 +261,23 @@ function scripts.modules.list()
end
end
-function scripts.modules.install()
+function scripts.modules.installed()
+ local files = dir.glob(targetdir .. "/*.tma")
+ if files then
+ for i=1,#files do
+ local data = table.load(files[i])
+ if data then
+ local name = data.name
+ local list = data.list
+ if name and list then
+ report("%4i : %s",#list,name)
+ end
+ end
+ end
+ end
+end
+
+function scripts.modules.install(wipe)
local curdir = dir.current()
local done = false
if not lfs.isdir(checkdir) then
@@ -219,14 +287,18 @@ function scripts.modules.install()
elseif not lfs.chdir(targetdir) then
report("unable to go into %a",targetdir)
elseif environment.argument("module") or environment.argument("modules") then
- loadlists()
local files = environment.files
if #files == 0 then
report("no archive names provided")
else
for i=1,#files do
local name = files[i]
- install { url = "modules", zips = { file.addsuffix(name,"zip") } }
+ if url.hasscheme(name) then
+ install({ url = false, zips = { file.addsuffix(name,"zip") } }, wipe)
+ else
+ loadlists()
+ install({ url = "modules", zips = { file.addsuffix(name,"zip") } }, wipe)
+ end
end
done = files
end
@@ -237,15 +309,36 @@ function scripts.modules.install()
report("no module names provided")
else
for i=1,#files do
- local list = lists[files[i]]
+ local name = files[i]
+ local list = lists[name]
if list then
- install(list)
+ install(list,wipe)
end
end
done = files
end
end
if done then
+ --
+ -- for i=1,#badones do
+ -- os.remove(badones[i])
+ -- end
+ local okay = false
+ local files = dir.glob("*")
+ for i=1,#files do
+ local name = files[i]
+ if file.suffix(name) == "tma" then
+ -- keep it
+ else
+ if not okay then
+ report()
+ okay = true
+ end
+ report("removed %a",name)
+ os.remove(name)
+ end
+ end
+ --
report()
report("renewing file database")
report()
@@ -258,10 +351,18 @@ function scripts.modules.install()
lfs.chdir(curdir)
end
+function scripts.modules.uninstall()
+ scripts.modules.install(true)
+end
+
if environment.argument("list") then
scripts.modules.list()
+elseif environment.argument("installed") then
+ scripts.modules.installed()
elseif environment.argument("install") then
scripts.modules.install()
+elseif environment.argument("uninstall") then
+ scripts.modules.uninstall()
elseif environment.argument("exporthelp") then
application.export(environment.argument("exporthelp"),environment.files[1])
else
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 27c2e6cb0..ad39c4579 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 32353, stripped down to: 16001
+-- original size: 33051, stripped down to: 16324
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -16301,8 +16301,10 @@ if xzip then
closezip(zipf)
end
end
- local function unzipdir(zipname,path,verbose)
+ local function unzipdir(zipname,path,verbose,collect,validate)
if type(zipname)=="table" then
+ validate=zipname.validate
+ collect=zipname.collect
verbose=zipname.verbose
path=zipname.path
zipname=zipname.zipname
@@ -16323,34 +16325,47 @@ if xzip then
local done=0
local steps=verbose=="steps"
local time=steps and osclock()
+ if collect then
+ collect={}
+ else
+ collect=false
+ end
for i=1,count do
local l=list[i]
local n=l.filename
- local d=unzipfile(z,n)
- if d then
- local p=filejoin(path,n)
- if mkdirs(dirname(p)) then
- if steps then
- total=total+#d
- done=done+1
- if done>=step then
- done=0
- logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ if not validate or validate(n) then
+ local d=unzipfile(z,n)
+ if d then
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if steps then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ if collect then
+ collect[#collect+1]=p
end
- elseif verbose then
- logwriter(n)
end
- savedata(p,d)
+ else
+ logwriter(format("problem with file %s",n))
end
else
- logwriter(format("problem with file %s",n))
end
end
if steps then
logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time))
end
closezipfile(z)
- return true
+ if collect then
+ return collect
+ end
else
closezipfile(z)
end
@@ -26188,8 +26203,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1046208
--- stripped bytes : 415601
+-- original bytes : 1046906
+-- stripped bytes : 415976
-- end library merge
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index 27c2e6cb0..ad39c4579 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 32353, stripped down to: 16001
+-- original size: 33051, stripped down to: 16324
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -16301,8 +16301,10 @@ if xzip then
closezip(zipf)
end
end
- local function unzipdir(zipname,path,verbose)
+ local function unzipdir(zipname,path,verbose,collect,validate)
if type(zipname)=="table" then
+ validate=zipname.validate
+ collect=zipname.collect
verbose=zipname.verbose
path=zipname.path
zipname=zipname.zipname
@@ -16323,34 +16325,47 @@ if xzip then
local done=0
local steps=verbose=="steps"
local time=steps and osclock()
+ if collect then
+ collect={}
+ else
+ collect=false
+ end
for i=1,count do
local l=list[i]
local n=l.filename
- local d=unzipfile(z,n)
- if d then
- local p=filejoin(path,n)
- if mkdirs(dirname(p)) then
- if steps then
- total=total+#d
- done=done+1
- if done>=step then
- done=0
- logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ if not validate or validate(n) then
+ local d=unzipfile(z,n)
+ if d then
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if steps then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ if collect then
+ collect[#collect+1]=p
end
- elseif verbose then
- logwriter(n)
end
- savedata(p,d)
+ else
+ logwriter(format("problem with file %s",n))
end
else
- logwriter(format("problem with file %s",n))
end
end
if steps then
logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time))
end
closezipfile(z)
- return true
+ if collect then
+ return collect
+ end
else
closezipfile(z)
end
@@ -26188,8 +26203,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1046208
--- stripped bytes : 415601
+-- original bytes : 1046906
+-- stripped bytes : 415976
-- end library merge
diff --git a/scripts/context/stubs/source/readme.txt b/scripts/context/stubs/source/readme.txt
index 72892ee2f..4eae76a1e 100644
--- a/scripts/context/stubs/source/readme.txt
+++ b/scripts/context/stubs/source/readme.txt
@@ -1,40 +1,40 @@
-Copyright:
-
-The originally 'runscript' program was written by in 2009 by T.M.Trzeciak and is
-public domain. This derived mtxrun program is an adapted version by Hans Hagen and
-Luigi Scarso.
-
-Comment:
-
-In ConTeXt MkIV we have two core scripts: luatools.lua and mtxrun.lua where the
-second one is used to launch other scripts. The mtxrun.exe program calls luatex.exe.
-
-Normally a user will use a call like:
-
- mtxrun --script font --reload
-
-Here mtxrun is a lua script. In order to avoid the usage of a cmd file on windows this
-runner will start texlua directly. In TeXlive a runner is added for each cmd file but
-we don't want that overhead (and extra files). By using an exe we can call these
-scripts in batch files without the need for using call.
-
-The mtxrun.exe file can be copied to a mtxrunjit.exe file in which case luajittex.exe
-is called.
-
- mtxrunjit --script font --reload
-
-We also don't want to use other runners, like those that use kpse to locate the script
-as this is exactly what mtxrun itself is doing already. Therefore the runscript program
-is adapted to a more direct approach suitable for mtxrun.
-
-Compilation:
-
-with gcc (size optimized):
-
- gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
- gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
-
-with tcc (ver. 0.9.24), extra small size
-
- tcc -shared -o runscript.dll runscript_dll.c
- tcc -o runscript.exe runscript_exe.c runscript.def
+Copyright:
+
+The originally 'runscript' program was written by in 2009 by T.M.Trzeciak and is
+public domain. This derived mtxrun program is an adapted version by Hans Hagen and
+Luigi Scarso.
+
+Comment:
+
+In ConTeXt MkIV we have two core scripts: luatools.lua and mtxrun.lua where the
+second one is used to launch other scripts. The mtxrun.exe program calls luatex.exe.
+
+Normally a user will use a call like:
+
+ mtxrun --script font --reload
+
+Here mtxrun is a lua script. In order to avoid the usage of a cmd file on windows this
+runner will start texlua directly. In TeXlive a runner is added for each cmd file but
+we don't want that overhead (and extra files). By using an exe we can call these
+scripts in batch files without the need for using call.
+
+The mtxrun.exe file can be copied to a mtxrunjit.exe file in which case luajittex.exe
+is called.
+
+ mtxrunjit --script font --reload
+
+We also don't want to use other runners, like those that use kpse to locate the script
+as this is exactly what mtxrun itself is doing already. Therefore the runscript program
+is adapted to a more direct approach suitable for mtxrun.
+
+Compilation:
+
+with gcc (size optimized):
+
+ gcc -Os -s -shared -o mtxrun.dll mtxrun_dll.c
+ gcc -Os -s -o mtxrun.exe mtxrun_exe.c -L./ -lmtxrun
+
+with tcc (ver. 0.9.24), extra small size
+
+ tcc -shared -o runscript.dll runscript_dll.c
+ tcc -o runscript.exe runscript_exe.c runscript.def
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index 27c2e6cb0..ad39c4579 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 32353, stripped down to: 16001
+-- original size: 33051, stripped down to: 16324
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -16301,8 +16301,10 @@ if xzip then
closezip(zipf)
end
end
- local function unzipdir(zipname,path,verbose)
+ local function unzipdir(zipname,path,verbose,collect,validate)
if type(zipname)=="table" then
+ validate=zipname.validate
+ collect=zipname.collect
verbose=zipname.verbose
path=zipname.path
zipname=zipname.zipname
@@ -16323,34 +16325,47 @@ if xzip then
local done=0
local steps=verbose=="steps"
local time=steps and osclock()
+ if collect then
+ collect={}
+ else
+ collect=false
+ end
for i=1,count do
local l=list[i]
local n=l.filename
- local d=unzipfile(z,n)
- if d then
- local p=filejoin(path,n)
- if mkdirs(dirname(p)) then
- if steps then
- total=total+#d
- done=done+1
- if done>=step then
- done=0
- logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ if not validate or validate(n) then
+ local d=unzipfile(z,n)
+ if d then
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if steps then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ if collect then
+ collect[#collect+1]=p
end
- elseif verbose then
- logwriter(n)
end
- savedata(p,d)
+ else
+ logwriter(format("problem with file %s",n))
end
else
- logwriter(format("problem with file %s",n))
end
end
if steps then
logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time))
end
closezipfile(z)
- return true
+ if collect then
+ return collect
+ end
else
closezipfile(z)
end
@@ -26188,8 +26203,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1046208
--- stripped bytes : 415601
+-- original bytes : 1046906
+-- stripped bytes : 415976
-- end library merge
diff --git a/scripts/context/stubs/win64/mtxrun.lua b/scripts/context/stubs/win64/mtxrun.lua
index 27c2e6cb0..ad39c4579 100644
--- a/scripts/context/stubs/win64/mtxrun.lua
+++ b/scripts/context/stubs/win64/mtxrun.lua
@@ -15876,7 +15876,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-zip"] = package.loaded["util-zip"] or true
--- original size: 32353, stripped down to: 16001
+-- original size: 33051, stripped down to: 16324
if not modules then modules={} end modules ['util-zip']={
version=1.001,
@@ -16301,8 +16301,10 @@ if xzip then
closezip(zipf)
end
end
- local function unzipdir(zipname,path,verbose)
+ local function unzipdir(zipname,path,verbose,collect,validate)
if type(zipname)=="table" then
+ validate=zipname.validate
+ collect=zipname.collect
verbose=zipname.verbose
path=zipname.path
zipname=zipname.zipname
@@ -16323,34 +16325,47 @@ if xzip then
local done=0
local steps=verbose=="steps"
local time=steps and osclock()
+ if collect then
+ collect={}
+ else
+ collect=false
+ end
for i=1,count do
local l=list[i]
local n=l.filename
- local d=unzipfile(z,n)
- if d then
- local p=filejoin(path,n)
- if mkdirs(dirname(p)) then
- if steps then
- total=total+#d
- done=done+1
- if done>=step then
- done=0
- logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ if not validate or validate(n) then
+ local d=unzipfile(z,n)
+ if d then
+ local p=filejoin(path,n)
+ if mkdirs(dirname(p)) then
+ if steps then
+ total=total+#d
+ done=done+1
+ if done>=step then
+ done=0
+ logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",i,count,total,osclock()-time))
+ end
+ elseif verbose then
+ logwriter(n)
+ end
+ savedata(p,d)
+ if collect then
+ collect[#collect+1]=p
end
- elseif verbose then
- logwriter(n)
end
- savedata(p,d)
+ else
+ logwriter(format("problem with file %s",n))
end
else
- logwriter(format("problem with file %s",n))
end
end
if steps then
logwriter(format("%4i files of %4i done, %10i bytes, %0.3f seconds",count,count,total,osclock()-time))
end
closezipfile(z)
- return true
+ if collect then
+ return collect
+ end
else
closezipfile(z)
end
@@ -26188,8 +26203,8 @@ end -- of closure
-- used libraries : l-bit32.lua l-lua.lua l-macro.lua l-sandbox.lua l-package.lua l-lpeg.lua l-function.lua l-string.lua l-table.lua l-io.lua l-number.lua l-set.lua l-os.lua l-file.lua l-gzip.lua l-md5.lua l-sha.lua l-url.lua l-dir.lua l-boolean.lua l-unicode.lua l-math.lua util-str.lua util-tab.lua util-fil.lua util-sac.lua util-sto.lua util-prs.lua util-fmt.lua util-soc-imp-reset.lua util-soc-imp-socket.lua util-soc-imp-copas.lua util-soc-imp-ltn12.lua util-soc-imp-mime.lua util-soc-imp-url.lua util-soc-imp-headers.lua util-soc-imp-tp.lua util-soc-imp-http.lua util-soc-imp-ftp.lua util-soc-imp-smtp.lua trac-set.lua trac-log.lua trac-inf.lua trac-pro.lua util-lua.lua util-deb.lua util-tpl.lua util-sbx.lua util-mrg.lua util-env.lua luat-env.lua util-zip.lua lxml-tab.lua lxml-lpt.lua lxml-mis.lua lxml-aux.lua lxml-xml.lua trac-xml.lua data-ini.lua data-exp.lua data-env.lua data-tmp.lua data-met.lua data-res.lua data-pre.lua data-inp.lua data-out.lua data-fil.lua data-con.lua data-use.lua data-zip.lua data-tre.lua data-sch.lua data-lua.lua data-aux.lua data-tmf.lua data-lst.lua libs-ini.lua luat-sta.lua luat-fmt.lua
-- skipped libraries : -
--- original bytes : 1046208
--- stripped bytes : 415601
+-- original bytes : 1046906
+-- stripped bytes : 415976
-- end library merge