-
Notifications
You must be signed in to change notification settings - Fork 80
/
jlinstall
executable file
·88 lines (76 loc) · 2.11 KB
/
jlinstall
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
#!/usr/bin/env julia
using Pkg, Pkg.BinaryPlatforms, Pkg.Artifacts
SUPPORTED = [
"LibCURL",
"FFMPEG",
"Git",
"HDF5",
"Lua",
"LAME",
"ImageMagick",
"Htop",
"Vmtouch",
"iperf",
"tmux",
"bmon",
"TerminalImageViewer",
"OATHToolkit",
"neofetch",
"datamash",
"peco"
]
if length(ARGS) == 1
NAME = ARGS[1]
else
println("Usage: ./jlinstall Software")
println("Supported softwares:")
println(join(SUPPORTED, "\n"))
exit(0)
end
INSTALLDIR = get(ENV, "JLROOT", joinpath(get(ENV, "ZZROOT", joinpath(homedir(), "app")), "jl"))
DOWNLOADDIR = joinpath(INSTALLDIR, "downloads")
mkpath(INSTALLDIR)
mkpath(DOWNLOADDIR)
function getdeps(name)
s = read(download("https://raw.githubusercontent.com/JuliaBinaryWrappers/$(name)_jll.jl/master/Project.toml"), String)
replace.(SubString.(s, findall(r"\w+_jll", s)), ["_jll" => ""])
end
function getartifact(name)
artifacts_toml = download("https://raw.githubusercontent.com/JuliaBinaryWrappers/$(name)_jll.jl/master/Artifacts.toml")
artifacts = Pkg.Artifacts.load_artifacts_toml(artifacts_toml)
platforms = [Pkg.Artifacts.unpack_platform(e, name, artifacts_toml) for e in artifacts[name]]
best_platform = select_platform(Dict(p => triplet(p) for p in platforms))
filter(e->triplet(Pkg.Artifacts.unpack_platform(e, name, artifacts_toml)) == best_platform, artifacts[name])[1]["download"][1]["url"]
end
deps = []
namesdone = []
function adddeps(name)
global deps, namedone
name in namesdone && return
push!(deps, name)
for d in getdeps(name)
if d ∉ deps
adddeps(d)
end
end
end
adddeps(NAME)
links = getartifact.(deps)
println(join(links, "\n"))
println()
files = joinpath.([DOWNLOADDIR], basename.(links))
for (link, file) in zip(links, files)
println("downloading $link to $file")
if !isfile(file)
tmpfile = tempname()
run(`wget -q -O $tmpfile $link`)
mv(tmpfile, file, force=true)
end
end
println()
for file in files
println("extracting $file")
run(`tar xf $file -C $INSTALLDIR`)
end
println()
println("done.")