Skip to content

Commit

Permalink
feat: quickemu install script
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardotglobal committed Jul 27, 2023
1 parent 7288616 commit dde2255
Showing 1 changed file with 114 additions and 0 deletions.
114 changes: 114 additions & 0 deletions scripts/install_quickemu
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env python3

import platform
import os
import shutil
import sys


def clone_repo():
print("📦 Cloning quickemu...")

print("> git clone --filter=blob:none https://github.com/wimpysworld/quickemu /tmp/quickemu")
os.system("git clone --filter=blob:none https://github.com/wimpysworld/quickemu /tmp/quickemu")

print("> mkdir -p ~/.local/bin")
os.system("mkdir -p ~/.local/bin")

print("> mv /tmp/quickemu/quickemu ~/.local/bin")
os.system("mv /tmp/quickemu/quickemu ~/.local/bin")

print("> mv /tmp/quickemu/macrecovery ~/.local/bin")
os.system("mv /tmp/quickemu/macrecovery ~/.local/bin")

print("> mv /tmp/quickemu/quickget ~/.local/bin")
os.system("mv /tmp/quickemu/quickget ~/.local/bin")

print("> mv /tmp/quickemu/windowskey ~/.local/bin")
os.system("mv /tmp/quickemu/windowskey ~/.local/bin")

print("> rm -rf /tmp/quickemu")
os.system("rm -rf /tmp/quickemu")

print("Installation complete.")
print("⚠️ Make sure ~/.local/bin is in your PATH.")


def install_fedora():
print("📦 Installing dependencies...")

cmd = "sudo dnf install qemu bash coreutils edk2-tools grep jq lsb procps python3 genisoimage usbutils util-linux " \
"sed spice-gtk-tools swtpm wget xdg-user-dirs xrandr unzip socat -y"
print("> " + cmd)
os.system(cmd)

clone_repo()

sys.exit(0)


def install_deb():
print("📦 Installing dependencies...")

print("> sudo apt update")
os.system("sudo apt update")

cmd = "sudo apt install qemu bash coreutils ovmf grep jq lsb-base procps python3 genisoimage usbutils util-linux " \
"sed spice-client-gtk libtss2-tcti-swtpm0 wget xdg-user-dirs zsync unzip socat -y"
print("> " + cmd)
os.system(cmd)

clone_repo()

sys.exit(0)


def install_ubuntu():
print("⚠️ Adding ppa...")

print("> sudo apt-add-repository ppa:flexiondotorg/quickemu")
os.system("sudo apt-add-repository ppa:flexiondotorg/quickemu")

print("> sudo apt update")
os.system("sudo apt update")

print("> sudo apt install quickemu -y")
os.system("sudo apt install quickemu -y")

sys.exit(0)


if __name__ == "__main__":
print("⚠️ This script requires elevated privileges (sudo). You will be asked for your password.")

os_release = platform.freedesktop_os_release()

distro_id = os_release.get("ID_LIKE")
distro_id_like = os_release.get("ID")

if not distro_id and not distro_id_like:
print("❌ Couldn't fetch distro, is os-release installed?")

if distro_id == "ubuntu" \
or distro_id_like == "ubuntu":
install_ubuntu()
elif distro_id == "debian" \
or distro_id_like == "debian" \
or shutil.which("apt"):
install_deb()
elif distro_id == "fedora" \
or distro_id_like == "fedora" \
or shutil.which("dnf"):
install_fedora()
else:
if distro_id:
print("❌ Unsupported distro: ", distro_id)
elif distro_id_like:
print("❌ Unsupported distro: ", distro_id_like)
else:
print("❌ Unsupported distro. Couldn't fetch data from os-release and couldn't find dnf or apt on PATH.")

sys.exit(1)

print("❌ Unsupported platform.")
sys.exit(1)

0 comments on commit dde2255

Please sign in to comment.