-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminiconda.lua
More file actions
125 lines (105 loc) · 3.02 KB
/
miniconda.lua
File metadata and controls
125 lines (105 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
--[[
Miniconda installation
--]]
-- global variables
sdk_name = "miniconda"
plugin_name = "miniconda"
plugin_version = "0.1"
homepage = "https://www.anaconda.com/docs/getting-started/miniconda/main"
-- installer config
ic = vmrNewInstallerConfig()
ic = vmrAddBinaryDirs(ic, "windows", { "bin" })
ic = vmrAddBinaryDirs(ic, "windows", { "condabin" })
ic = vmrAddBinaryDirs(ic, "linux", { "bin" })
ic = vmrAddBinaryDirs(ic, "linux", { "condabin" })
ic = vmrAddBinaryDirs(ic, "darwin", { "bin" })
ic = vmrAddBinaryDirs(ic, "darwin", { "condabin" })
-- spider
function parseArch(archStr)
aa = vmrToLower(archStr)
if vmrContains(aa, "x86_64") then
return "amd64"
end
if vmrContains(aa, "arm64") then
return "arm64"
end
if vmrContains(aa, "aarch64") then
return "arm64"
end
return ""
end
function parseOs(osStr)
oo = vmrToLower(osStr)
if vmrContains(oo, "macosx") then
return "darwin"
elseif vmrContains(oo, "windows") then
return "windows"
elseif vmrContains(oo, "linux") then
return "linux"
end
return ""
end
function parseVersionFromName(verName)
local result = vmrRegexpFindString("(\\d+\\.\\d+\\.\\d+-\\d+)", verName)
if result == "" then
return vmrRegexpFindString("(\\d+\\.\\d+\\.\\d+)", verName)
end
return result
end
function filterByHref(h)
if vmrHasSuffix(h, ".pkg") then
return false
end
return true
end
function crawl()
local url = "https://repo.anaconda.com/miniconda"
local timeout = 600
local headers = {}
headers["User-Agent"] =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
local resp = vmrGetResponse(url, timeout, headers)
local os, arch = vmrGetOsArch()
local tr = vmrInitSelection(resp, "tr")
local versionList = vmrNewVersionList()
function parseTr(i, ss)
if not ss then
return
end
local tds = vmrFind(ss, "td")
local eqs = vmrEq(tds, 0)
local a = vmrFind(eqs, "a")
if not a then
return
end
local href = vmrAttr(a, "href")
if not href or (not filterByHref(href)) then
return
end
local itemOs = parseOs(href)
local itemArch = parseArch(href)
if itemOs ~= os or itemArch ~= arch then
return
end
local versionName = parseVersionFromName(href)
if versionName == "" then
return
end
local item = {}
item["url"] = vmrUrlJoin(url, href)
item["os"] = os
item["arch"] = arch
item["installer"] = vmrInstallerExecutable
eqs = vmrEq(tds, 3)
item["sum"] = vmrTrimSpace(vmrText(eqs))
if item["sum"] ~= "" then
item["sum_type"] = "sha256"
end
item["size"] = 0
vmrAddItem(versionList, versionName, item)
end
vmrEach(tr, parseTr)
return versionList
end
function install(localFilePath, version)
end