From a42e4c5299d73b72d4d841328370319ac64b2749 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 15 Feb 2025 17:14:58 +0100 Subject: [PATCH] updater: Added updater support for more platforms --- main/updater/source/main.cpp | 38 ++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/main/updater/source/main.cpp b/main/updater/source/main.cpp index 330038701..eb442c962 100644 --- a/main/updater/source/main.cpp +++ b/main/updater/source/main.cpp @@ -79,13 +79,26 @@ std::string getUpdateType() { if (!hex::ImHexApi::System::isPortableVersion()) return "win-msi"; #elif defined (OS_MACOS) - return "mac-dmg"; + #if defined(__x86_64__) + return "mac-dmg-x86"; + #elif defined(__arm__) + return "mac-dmg-arm"; + #endif #elif defined (OS_LINUX) - if (hex::executeCommand("lsb_release -a | grep Ubuntu") == 0) { - if (hex::executeCommand("lsb_release -a | grep 22.") == 0) - return "linux-deb-22.04"; - else if (hex::executeCommand("lsb_release -a | grep 23.") == 0) - return "linux-deb-23.04"; + if (hex::executeCommand("grep 'ID=ubuntu' /etc/os-release") == 0) { + if (hex::executeCommand("grep 'VERSION_ID=\"24.04\"' /etc/os-release") == 0) + return "linux-deb-24.04"; + else if (hex::executeCommand("grep 'VERSION_ID=\"24.10\"' /etc/os-release") == 0) + return "linux-deb-24.10"; + } else if (hex::executeCommand("grep 'ID=fedora' /etc/os-release") == 0) { + if (hex::executeCommand("grep 'VERSION_ID=\"40\"' /etc/os-release") == 0) + return "linux-rpm-40"; + else if (hex::executeCommand("grep 'VERSION_ID=\"41\"' /etc/os-release") == 0) + return "linux-rpm-41"; + else if (hex::executeCommand("grep 'VERSION_ID=\"rawhide\"' /etc/os-release") == 0) + return "linux-rpm-rawhide"; + } else if (hex::executeCommand("grep '^NAME=\"Arch Linux\"' /etc/os-release") == 0) { + return "linux-arch"; } #endif @@ -100,10 +113,15 @@ int installUpdate(const std::string &type, std::fs::path updatePath) { }; constexpr static auto UpdateHandlers = { - UpdateHandler { "win-msi", ".msi", "msiexec /i {} /qb" }, - UpdateHandler { "macos-dmg", ".dmg", "hdiutil attach {}" }, - UpdateHandler { "linux-deb-22.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, - UpdateHandler { "linux-deb-23.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, + UpdateHandler { "win-msi", ".msi", "msiexec /i {} /qb" }, + UpdateHandler { "macos-dmg-x86", ".dmg", "hdiutil attach {}" }, + UpdateHandler { "macos-dmg-arm", ".dmg", "hdiutil attach {}" }, + UpdateHandler { "linux-deb-24.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, + UpdateHandler { "linux-deb-24.10", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, + UpdateHandler { "linux-rpm-40", ".rpm", "sudo rpm -i {}" }, + UpdateHandler { "linux-rpm-41", ".rpm", "sudo rpm -i {}" }, + UpdateHandler { "linux-rpm-rawhide", ".rpm", "sudo rpm -i {}" }, + UpdateHandler { "linux-arch", ".zst", "sudo pacman -Syy && sudo pacman -U --noconfirm {}" } }; for (const auto &handler : UpdateHandlers) {