-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstaller.py
executable file
·47 lines (34 loc) · 1.07 KB
/
installer.py
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
#!/usr/bin/env python3
import tarfile
from re import match
from os import system
from json import loads
from shutil import move
from requests import get
response = get(
"https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest"
)
assets = loads(response.content)['assets']
version = "java11"
os = "linux"
arch = "amd64"
regular_exp = "graalvm-ce-" + version + "-" + os + "-" + arch + "-.*.tar.gz"
url = list(filter(
lambda x: match(regular_exp, x['name']),
assets
))[0]["browser_download_url"]
path = url.split('/')[-1]
print("Downloading ", path, "...")
graalvm_file = get(url)
with open('/tmp/' + path,'wb') as f:
f.write(graalvm_file.content)
dir_name = ""
print("Extracting...")
with tarfile.open('/tmp/' + path) as tar:
dir_name = tar.firstmember.name.split('/')[0]
tar.extractall('/tmp/')
print("Installing...")
move('/tmp/' + dir_name, '/usr/lib/jvm/graalvm/')
system("update-alternatives --install /usr/bin/java java /usr/lib/jvm/graalvm/bin/java 1")
system("update-alternatives --set java /usr/lib/jvm/graalvm/bin/java")
print("Done!")