summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-09-26 17:35:54 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-09-26 17:35:54 +0200
commit2073fe5d88215dddd9a9e6421afaea7ab7db955a (patch)
treed0a65846502c24c5951f03f6018c15125a532fa5 /scripts
parentd5e2ac5f857f2a003949fce54ed41eedc4fb9475 (diff)
downloadcontext-2073fe5d88215dddd9a9e6421afaea7ab7db955a.tar.gz
2021-09-26 16:50:00
Diffstat (limited to 'scripts')
-rw-r--r--scripts/context/lua/mtx-install.lua44
1 files changed, 40 insertions, 4 deletions
diff --git a/scripts/context/lua/mtx-install.lua b/scripts/context/lua/mtx-install.lua
index 9087a6524..826098cc7 100644
--- a/scripts/context/lua/mtx-install.lua
+++ b/scripts/context/lua/mtx-install.lua
@@ -14,7 +14,7 @@ local helpinfo = [[
<metadata>
<entry name="name">mtx-install</entry>
<entry name="detail">ConTeXt Installer</entry>
- <entry name="version">2.00</entry>
+ <entry name="version">2.01</entry>
</metadata>
<flags>
<category name="basic">
@@ -28,27 +28,55 @@ local helpinfo = [[
<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>
+ <flag name="secure"><short>use curl for https</short></flag>
</subcategory>
</category>
</flags>
</application>
]]
+local type, tonumber = type, tonumber
local gsub, find, escapedpattern = string.gsub, string.find, string.escapedpattern
local round = math.round
local savetable, loadtable, sortedhash = table.save, table.load, table.sortedhash
local copyfile, joinfile, filesize, dirname, addsuffix, basename = file.copy, file.join, file.size, file.dirname, file.addsuffix, file.basename
local isdir, isfile, walkdir, pushdir, popdir, currentdir = lfs.isdir, lfs.isfile, lfs.dir, lfs.chdir, dir.push, dir.pop, currentdir
local mkdirs, globdir = dir.mkdirs, dir.glob
-local osremove, osexecute, ostype = os.remove, os.execute, os.type
+local osremove, osexecute, ostype, resultof = os.remove, os.execute, os.type, os.resultof
local savedata = io.savedata
local formatters = string.formatters
+local httprequest = socket.http.request
-local fetch = socket.http.request
+local usecurl = false
+
+local function checkcurl()
+ local s = resultof("curl --version")
+ return type(s) == "string" and find(s,"libcurl") and find(s,"rotocols")
+end
+
+local function fetch(url)
+ local data = nil
+ local detail = nil
+ if usecurl and find(url,"^https") then
+ data = resultof("curl " .. url)
+ else
+ data, detail = httprequest(url)
+ end
+ if type(data) ~= "string" then
+ data = false
+ elseif #data < 2048 then
+ local n, t = find(data,"<head>%s*<title>%s*(%d+)%s(.-)</title>")
+ if tonumber(n) then
+ data = false
+ detail = n .. " " .. t
+ end
+ end
+ return data, detail
+end
local application = logs.application {
name = "mtx-install",
- banner = "ConTeXt Installer 2.00",
+ banner = "ConTeXt Installer 2.01",
helpinfo = helpinfo,
}
@@ -603,6 +631,14 @@ function install.update()
report("update, done")
end
+if environment.argument("secure") then
+ usecurl = checkcurl()
+ if not usecurl then
+ report("no curl installed, quitting")
+ os.exit()
+ end
+end
+
if environment.argument("identify") then
install.identify()
elseif environment.argument("install") then