This repository has been archived by the owner on Jun 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
executable file
·139 lines (120 loc) · 4.7 KB
/
install.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
from subprocess import check_output, call
import os
import sys
version = 13
user = check_output(['whoami']).decode('utf-8')[:-1]
WorkingDirectory = os.getcwd()
path = "/home/" + user + "/.var/app/com.nyaker.RyzenTuningUtility"
desktopPath = "/home/" + user + "/.local/share/applications"
corefilelist = [("gui/RyzenTuningUtility.py", "/gui"), ]
configfileslist = [("daemon/config.py", "/daemon")]
installMode = "None"
def selectrepair():
global installMode
print('complete repair (including config files)(DATA LOSS RISK) : c \nbasic repair : b')
choice = input('>>> ')
if choice == "c":
print("complete Repair, Config Data will be lost ! \nAre you sure ? (y/n)")
if input(">>> ") == "y":
installMode = "repairC"
else:
selectrepair()
elif choice == "b":
print("Basic repair, your config data is safe")
installMode = "repairB"
def install_icon():
call(("pkexec", "cp", "-f", WorkingDirectory+"/etc/com.nyaker.RyzenTuningUtility.svg", "/usr/share/icons/hicolor/scalable/apps"))
print("\n======= Icon copied into " + "/usr/share/icons/hicolor/scalable/apps" + " =======\n")
def install_desktopShortcut():
call(("cp", "-f", "etc/RyzenTuningController.desktop", desktopPath))
os.system("echo Exec=/home/" + user + "/.var/app/com.nyaker.RyzenTuningUtility/start.py >> "+desktopPath+"/RyzenTuningController.desktop")
print("\n======= desktop files copied into " + desktopPath + " =======\n")
def install_libs():
print("\n======= installing libs =======")
call(("python",'-m','pip', "install", "PyGObject"))
call(("python",'-m','pip', "install", "PyGObject"))
def install_Core_Files():
i = 0
print("\n======= installing core files =======")
for file in corefilelist:
if file[1] == '':
pass
else:
call(("mkdir", "-p", path + file[1]))
call(("cp", "-f", "-r", file[0], path + file[1]))
i += 1
print((i / len(corefilelist)) * 100, "%.")
print("\n======= core files copied into " + path + " =======\n")
def install_safe_files():
call(("pkexec", "python",WorkingDirectory + "/etc/admin_installer.py", WorkingDirectory, path))
def install_Configs(mode):
if mode == 'force':
arg = "-f"
elif mode == 'normal':
arg = "-n"
elif mode == 'update':
print("\n======= updating config==========\n")
print("========= not implemented =========\n")
for file in configfileslist:
if file[1] == '':
pass
else:
call(("mkdir", "-p", path + file[1]))
call(("cp", "-f", "-r", file[0], path + file[1]))
print("==== copied " + file[0] + " to " + path + file[1] + "\n")
print("\n======= config files copied into " + path + " =======\n")
if os.path.exists("/usr/bin/python"):
print("=============== python bindings are ok, installing ===============\n")
python = "python"
elif os.path.exists("/usr/bin/python3"):
print("== using python3 executable (big chance that you are running a debian based system), it should work ==\n")
python = "python3"
else:
print("=============== python not found ===============")
print("Your distro is not currently supported, you can still try to modify the script, please report the problem into the github")
exit(1)
isdir = call(("mkdir", path))
try:
arg = sys.argv[1]
if arg == 'update':
installMode = 'update'
except:
if isdir == 0:
print('\n======= folder created =======\n')
installMode = "normal"
elif isdir == 1:
print('\n======= folder already exist =======\n')
if os.path.exists(path + "/start.py"):
print('\n======= detected start.py file, detecting version =======\n')
currentversion = int(check_output([python, path + "/start.py", "version"]).decode('utf-8'))
if int(currentversion) == version:
selectrepair()
else:
installMode = "update"
print('====== update from v' + str(currentversion) + ' to v' + str(version) + ' ======')
else:
installMode = "normal"
if installMode == "normal":
install_Core_Files()
install_safe_files()
#install_Configs("force")
install_desktopShortcut()
install_icon()
install_libs()
elif installMode == "update":
install_Core_Files()
install_desktopShortcut()
install_safe_files()
install_icon()
elif installMode == "repairC":
install_Core_Files()
install_Configs("force")
install_safe_files()
# install_desktopShortcut()
# install_libs()
# install_icon()
elif installMode == "repairB":
install_Core_Files()
install_desktopShortcut()
#install_icon()
print("\n======= done =======")