-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.py
More file actions
46 lines (33 loc) · 2.34 KB
/
installer.py
File metadata and controls
46 lines (33 loc) · 2.34 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
import sys
import subprocess
# Install system dependencies first (needed for pip and other tools)
print("installing system dependencies...")
subprocess.run("sudo apt update && sudo apt install -y python3-pip python3-gi python3-gi-cairo gir1.2-gtk-3.0 python3 python3-cryptography", shell=True)
print("Downloading...")
os.makedirs(os.path.expanduser("~/.local/share/LockBox/"), exist_ok=True)
# Remove old dist folder if it exists (don't fail if it doesn't)
subprocess.run("rm -rf ~/.local/share/LockBox/dist", shell=True)
# Upgrade pip using the now-installed python3-pip
subprocess.run("python3 -m pip install --upgrade pip", shell=True)
# Install pyinstaller
subprocess.run("python3 -m pip install pyinstaller --break-system-packages", shell=True)
# Download main.py from GitHub
subprocess.run("curl -L https://raw.githubusercontent.com/aahspaghetticode/LockBox/refs/heads/main/main.py -o ~/.local/share/LockBox/main.py", shell=True)
# Build executable with pyinstaller
subprocess.run("pyinstaller --onefile --noconsole --distpath ~/.local/share/LockBox/dist/ ~/.local/share/LockBox/main.py", shell=True)
# Make executable
subprocess.run("chmod +x ~/.local/share/LockBox/dist/main", shell=True)
# Create icon directory and download icon
os.makedirs(os.path.expanduser("~/.local/share/icons/"), exist_ok=True)
subprocess.run("curl -L https://raw.githubusercontent.com/aahspaghetticode/LockBox/refs/heads/main/Icon.png -o ~/.local/share/icons/LockBox.png", shell=True)
# Create desktop entry file
desktop_file_path = os.path.join(os.path.expanduser("~"), ".local", "share", "applications", "LockBox.desktop")
os.makedirs(os.path.dirname(desktop_file_path), exist_ok=True)
with open(desktop_file_path, "w") as file:
file.write(f'''[Desktop Entry]\nVersion=1.0\nType=Application\nName=LockBox\nComment=Secure password storage\nExec={{os.path.expanduser("~")}}/.local/share/LockBox/dist/main\nIcon={{os.path.expanduser("~")}}/.local/share/icons/LockBox.png\nTerminal=false\nCategories=Utility;\n''')
# Make desktop file executable
subprocess.run("chmod +x ~/.local/share/applications/LockBox.desktop", shell=True)
# Update icon cache and desktop database
subprocess.run("gtk-update-icon-cache ~/.local/share/icons/ 2>/dev/null || true", shell=True)
subprocess.run("update-desktop-database ~/.local/share/applications/ 2>/dev/null || true", shell=True)
print("Installation complete!")