summaryrefslogtreecommitdiff
path: root/scripts/context/lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-02-17 16:17:51 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-02-17 16:17:51 +0100
commit631a40d69d7fb4e5beff90039d21da5472dd1020 (patch)
tree8e9d9dc68c506fe309ccef784fe4b59853e98add /scripts/context/lua
parent8e11d447440b44990432ac838953a8cde4ef914f (diff)
downloadcontext-631a40d69d7fb4e5beff90039d21da5472dd1020.tar.gz
2020-02-17 12:10:00
Diffstat (limited to 'scripts/context/lua')
-rw-r--r--scripts/context/lua/mtx-install.lua39
-rw-r--r--scripts/context/lua/mtx-update.lua9
-rw-r--r--scripts/context/lua/mtxrun.lua56
3 files changed, 81 insertions, 23 deletions
diff --git a/scripts/context/lua/mtx-install.lua b/scripts/context/lua/mtx-install.lua
index 095ded2d6..b9b410353 100644
--- a/scripts/context/lua/mtx-install.lua
+++ b/scripts/context/lua/mtx-install.lua
@@ -194,6 +194,8 @@ end
function install.update()
+ local hashdata = sha2 and sha2.HASH256 or md5.hex
+
local function validdir(d)
local ok = isdir(d)
if not ok then
@@ -203,7 +205,7 @@ function install.update()
return ok
end
- local function download(what,url,target,total,done)
+ local function download(what,url,target,total,done,oldhash)
local data = fetch(url .. "/" .. target)
if data then
if total and done then
@@ -211,11 +213,15 @@ function install.update()
else
report("%-8s : %8i : %s",what,#data,target)
end
- if validdir(dirname(target)) then
- savedata(target,data)
+ if oldhash and oldhash ~= hashdata(data) then
+ return "different hash value"
+ elseif not validdir(dirname(target)) then
+ return "wrong target directory"
else
- -- message
+ savedata(target,data)
end
+ else
+ return "unable to download"
end
end
@@ -364,7 +370,12 @@ function install.update()
if action then
local size = newhash[2]
total = total + size
- todo[#todo+1] = { action, target, size }
+ todo[#todo+1] = {
+ action = action,
+ target = target,
+ size = size,
+ hash = newhash[3],
+ }
end
else
report("skipping %s",target)
@@ -375,8 +386,22 @@ function install.update()
for i=1,count do
local entry = todo[i]
- download(entry[1],url,entry[2],total,done)
- done = done + entry[3]
+ for i=1,5 do
+ local target = entry.target
+ local message = download(entry.action,url,target,total,done,entry.hash)
+ if message then
+ if i == 5 then
+ report("%s, try again later: %s",target)
+ os.exit()
+ else
+ report("%s, trying again: %s",target)
+ os.sleep(2)
+ end
+ else
+ break
+ end
+ end
+ done = done + entry.size
end
for oldname, oldhash in sortedhash(hold) do
diff --git a/scripts/context/lua/mtx-update.lua b/scripts/context/lua/mtx-update.lua
index 0462313d6..e03012901 100644
--- a/scripts/context/lua/mtx-update.lua
+++ b/scripts/context/lua/mtx-update.lua
@@ -98,13 +98,6 @@ update.repositories = {
"experimental"
}
--- more options than just these two are available (no idea why this is here)
-
-update.versions = {
- "current",
- "latest"
-}
-
-- list of basic folders that are needed to make a functional distribution
update.base = {
@@ -684,7 +677,7 @@ if scripts.savestate then
local valid = table.tohash(update.repositories)
for r in gmatch(environment.argument("repository") or "current","([^, ]+)") do
- if valid[r] then states.set("repositories." .. r, true) end
+ if valid[r] then states.set(" ." .. r, true) end
end
local valid = update.engines
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index 15e99eb91..5907fa33c 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -8562,7 +8562,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["util-sac"] = package.loaded["util-sac"] or true
--- original size: 12898, stripped down to: 9275
+-- original size: 12946, stripped down to: 9507
if not modules then modules={} end modules ['util-sac']={
version=1.001,
@@ -8790,9 +8790,9 @@ function streams.readfixed2(f)
f[2]=j+1
local a,b=byte(f[1],i,j)
if a>=0x80 then
- tonumber((a-0x100).."."..b)
+ return tonumber((a-0x100).."."..b) or 0
else
- tonumber((a ).."."..b)
+ return tonumber((a ).."."..b) or 0
end
end
function streams.readfixed4(f)
@@ -8801,9 +8801,9 @@ function streams.readfixed4(f)
f[2]=j+1
local a,b,c,d=byte(f[1],i,j)
if a>=0x80 then
- tonumber((0x100*a+b-0x10000).."."..(0x100*c+d))
+ return tonumber((0x100*a+b-0x10000).."."..(0x100*c+d)) or 0
else
- tonumber((0x100*a+b ).."."..(0x100*c+d))
+ return tonumber((0x100*a+b ).."."..(0x100*c+d)) or 0
end
end
if bit32 then
@@ -8883,6 +8883,16 @@ if sio and sio.readcardinal2 then
f[2]=i+4
return readinteger4(f[1],i)
end
+ function streams.readfixed2(f)
+ local i=f[2]
+ f[2]=i+2
+ return readfixed2(f[1],i)
+ end
+ function streams.readfixed4(f)
+ local i=f[2]
+ f[2]=i+4
+ return readfixed4(f[1],i)
+ end
function streams.read2dot4(f)
local i=f[2]
f[2]=i+2
@@ -13951,7 +13961,7 @@ do -- create closure to overcome 200 locals limit
package.loaded["trac-inf"] = package.loaded["trac-inf"] or true
--- original size: 9904, stripped down to: 6712
+-- original size: 9973, stripped down to: 7492
if not modules then modules={} end modules ['trac-inf']={
version=1.001,
@@ -13985,6 +13995,36 @@ local function resettiming(instance)
end
local ticks=clock
local seconds=function(n) return n or 0 end
+if lua.getpreciseticks then
+ ticks=lua.getpreciseticks
+ seconds=lua.getpreciseseconds
+elseif FFISUPPORTED and ffi and os.type=="windows" then
+ local okay,kernel=pcall(ffi.load,"kernel32")
+ if kernel then
+ local tonumber=ffi.number or tonumber
+ ffi.cdef[[
+ int QueryPerformanceFrequency(int64_t *lpFrequency);
+ int QueryPerformanceCounter(int64_t *lpPerformanceCount);
+ ]]
+ local target=ffi.new("__int64[1]")
+ ticks=function()
+ if kernel.QueryPerformanceCounter(target)==1 then
+ return tonumber(target[0])
+ else
+ return 0
+ end
+ end
+ local target=ffi.new("__int64[1]")
+ seconds=function(ticks)
+ if kernel.QueryPerformanceFrequency(target)==1 then
+ return ticks/tonumber(target[0])
+ else
+ return 0
+ end
+ end
+ end
+else
+end
local function starttiming(instance,reset)
local timer=timers[instance or "notimer"]
local it=timer.timing
@@ -26077,8 +26117,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 : 1038128
--- stripped bytes : 410736
+-- original bytes : 1038245
+-- stripped bytes : 409841
-- end library merge