From dde2255b57c00769ec07282277aabfeaca16b29e Mon Sep 17 00:00:00 2001 From: Oskar Manhart <52569953+oskardotglobal@users.noreply.github.com> Date: Thu, 27 Jul 2023 11:32:58 +0200 Subject: [PATCH] feat: quickemu install script --- scripts/install_quickemu | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 scripts/install_quickemu diff --git a/scripts/install_quickemu b/scripts/install_quickemu new file mode 100644 index 0000000..582a2a1 --- /dev/null +++ b/scripts/install_quickemu @@ -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)