From 8b2184f8e3f132b009ec477782b55eb5d21f4c9c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 15 Feb 2025 17:50:29 +0100 Subject: [PATCH] updater: Fixed updater not working properly on macOS --- lib/external/libwolv | 2 +- lib/libimhex/source/helpers/default_paths.cpp | 2 +- lib/libimhex/source/helpers/utils.cpp | 2 +- main/updater/CMakeLists.txt | 8 ++----- main/updater/source/main.cpp | 24 +++++++++---------- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/external/libwolv b/lib/external/libwolv index 2ea4b7d73..4b42068ec 160000 --- a/lib/external/libwolv +++ b/lib/external/libwolv @@ -1 +1 @@ -Subproject commit 2ea4b7d73b9d8828c70d88ac729b00c603f8f7e7 +Subproject commit 4b42068eca113e45e1a052e0437a5c7a96c3eda5 diff --git a/lib/libimhex/source/helpers/default_paths.cpp b/lib/libimhex/source/helpers/default_paths.cpp index 7f437a0de..b3793ab8a 100644 --- a/lib/libimhex/source/helpers/default_paths.cpp +++ b/lib/libimhex/source/helpers/default_paths.cpp @@ -44,7 +44,7 @@ namespace hex::paths { if (includeSystemFolders) { if (auto executablePath = wolv::io::fs::getExecutablePath(); executablePath.has_value()) { - paths.push_back(*executablePath); + paths.push_back(executablePath->parent_path()); } } diff --git a/lib/libimhex/source/helpers/utils.cpp b/lib/libimhex/source/helpers/utils.cpp index 41cd147a6..109f51f45 100644 --- a/lib/libimhex/source/helpers/utils.cpp +++ b/lib/libimhex/source/helpers/utils.cpp @@ -341,7 +341,7 @@ namespace hex { #if defined(OS_WINDOWS) std::ignore = system(hex::format("start \"\" {0}", command).c_str()); #elif defined(OS_MACOS) - std::ignore = system(hex::format("open {0}", command).c_str()); + std::ignore = system(hex::format("{0}", command).c_str()); #elif defined(OS_LINUX) executeCmd({"xdg-open", command}); #elif defined(OS_WEB) diff --git a/main/updater/CMakeLists.txt b/main/updater/CMakeLists.txt index 4e07614a7..a5f48c35c 100644 --- a/main/updater/CMakeLists.txt +++ b/main/updater/CMakeLists.txt @@ -7,14 +7,10 @@ add_executable(updater target_compile_definitions(updater PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") target_link_libraries(updater PRIVATE libimhex ${FMT_LIBRARIES}) add_dependencies(main updater) +setupCompilerFlags(updater) -if (APPLE) - set(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${BUNDLE_NAME}/Contents/MacOS") -else () - set(OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") -endif() set_target_properties(updater PROPERTIES OUTPUT_NAME "imhex-updater" - RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY} + RUNTIME_OUTPUT_DIRECTORY ${IMHEX_MAIN_OUTPUT_DIRECTORY} ) \ No newline at end of file diff --git a/main/updater/source/main.cpp b/main/updater/source/main.cpp index eb442c962..17f1744fc 100644 --- a/main/updater/source/main.cpp +++ b/main/updater/source/main.cpp @@ -80,9 +80,9 @@ std::string getUpdateType() { return "win-msi"; #elif defined (OS_MACOS) #if defined(__x86_64__) - return "mac-dmg-x86"; - #elif defined(__arm__) - return "mac-dmg-arm"; + return "macos-dmg-x86"; + #elif defined(__arm64__) + return "macos-dmg-arm"; #endif #elif defined (OS_LINUX) if (hex::executeCommand("grep 'ID=ubuntu' /etc/os-release") == 0) { @@ -113,15 +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-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 {}" } + UpdateHandler { "win-msi", ".msi", "msiexec /i \"{}\" /qb" }, + UpdateHandler { "macos-dmg-x86", ".dmg", "hdiutil attach -autoopen \"{}\"" }, + UpdateHandler { "macos-dmg-arm", ".dmg", "hdiutil attach -autoopen \"{}\"" }, + 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) {