mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Allow more release types to be updated
This commit is contained in:
@@ -942,41 +942,52 @@ namespace hex {
|
||||
}
|
||||
|
||||
bool updateImHex(UpdateType updateType) {
|
||||
// Get the path of the updater executable
|
||||
std::fs::path executablePath;
|
||||
|
||||
for (const auto &entry : std::fs::directory_iterator(wolv::io::fs::getExecutablePath()->parent_path())) {
|
||||
if (entry.path().filename().string().starts_with("imhex-updater")) {
|
||||
executablePath = entry.path();
|
||||
break;
|
||||
#if defined(OS_WEB)
|
||||
switch (updateType) {
|
||||
case UpdateType::Stable:
|
||||
EM_ASM({ window.location.href = window.location.origin; });
|
||||
break;
|
||||
case UpdateType::Nightly:
|
||||
EM_ASM({ window.location.href = window.location.origin + "/nightly"; });
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Get the path of the updater executable
|
||||
std::fs::path executablePath;
|
||||
|
||||
if (executablePath.empty() || !wolv::io::fs::exists(executablePath))
|
||||
return false;
|
||||
for (const auto &entry : std::fs::directory_iterator(wolv::io::fs::getExecutablePath()->parent_path())) {
|
||||
if (entry.path().filename().string().starts_with("imhex-updater")) {
|
||||
executablePath = entry.path();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string updateTypeString;
|
||||
switch (updateType) {
|
||||
case UpdateType::Stable:
|
||||
updateTypeString = "stable";
|
||||
break;
|
||||
case UpdateType::Nightly:
|
||||
updateTypeString = "nightly";
|
||||
break;
|
||||
}
|
||||
if (executablePath.empty() || !wolv::io::fs::exists(executablePath))
|
||||
return false;
|
||||
|
||||
EventImHexClosing::subscribe([executablePath, updateTypeString] {
|
||||
hex::startProgram(
|
||||
fmt::format("\"{}\" \"{}\"",
|
||||
wolv::util::toUTF8String(executablePath),
|
||||
updateTypeString
|
||||
)
|
||||
);
|
||||
});
|
||||
std::string updateTypeString;
|
||||
switch (updateType) {
|
||||
case UpdateType::Stable:
|
||||
updateTypeString = "stable";
|
||||
break;
|
||||
case UpdateType::Nightly:
|
||||
updateTypeString = "nightly";
|
||||
break;
|
||||
}
|
||||
|
||||
ImHexApi::System::closeImHex();
|
||||
EventImHexClosing::subscribe([executablePath, updateTypeString] {
|
||||
hex::startProgram(
|
||||
fmt::format("\"{}\" \"{}\"",
|
||||
wolv::util::toUTF8String(executablePath),
|
||||
updateTypeString
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
return true;
|
||||
ImHexApi::System::closeImHex();
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void addStartupTask(const std::string &name, bool async, const std::function<bool()> &function) {
|
||||
|
||||
@@ -18,7 +18,7 @@ else()
|
||||
source/stacktrace.cpp
|
||||
source/exceptions.cpp
|
||||
)
|
||||
target_link_libraries(tracing PRIVATE LLVMDemangle)
|
||||
target_link_libraries(tracing PRIVATE LLVMDemangle ${FMT_LIBRARIES})
|
||||
|
||||
set(LIBIMHEX_LIBRARY_TYPE_PUBLIC PUBLIC)
|
||||
set(LIBIMHEX_LIBRARY_TYPE_PRIVATE PRIVATE)
|
||||
|
||||
@@ -118,7 +118,13 @@ std::string_view getUpdateArtifactEnding() {
|
||||
#elif defined (OS_MACOS)
|
||||
return ARCH_DEPENDENT("macOS-x86_64.dmg", "macOS-arm64.dmg");
|
||||
#elif defined (OS_LINUX)
|
||||
if (hex::executeCommand("grep 'ID=ubuntu' /etc/os-release") == 0) {
|
||||
if (hex::getEnvironmentVariable("APPIMAGE").has_value()) {
|
||||
return ARCH_DEPENDENT("x86_64.AppImage", "arm64.AppImage");
|
||||
} else if (hex::getEnvironmentVariable("FLATPAK_BINARY").has_value()) {
|
||||
return ARCH_DEPENDENT("x86_64.flatpak", "arm64.flatpak");
|
||||
} else if (hex::getEnvironmentVariable("SNAP").has_value()) {
|
||||
return ARCH_DEPENDENT("x86_64.snap", "arm64.snap");
|
||||
} else if (hex::executeCommand("grep 'ID=ubuntu' /etc/os-release") == 0) {
|
||||
if (hex::executeCommand("grep 'VERSION_ID=\"24.04\"' /etc/os-release") == 0)
|
||||
return ARCH_DEPENDENT("Ubuntu-24.04-x86_64.deb", "");
|
||||
else if (hex::executeCommand("grep 'VERSION_ID=\"24.10\"' /etc/os-release") == 0)
|
||||
@@ -142,16 +148,19 @@ std::string_view getUpdateArtifactEnding() {
|
||||
|
||||
bool installUpdate(const std::fs::path &updatePath) {
|
||||
struct UpdateHandler {
|
||||
const char *ending;
|
||||
const char *command;
|
||||
std::string ending;
|
||||
std::string command;
|
||||
};
|
||||
|
||||
constexpr static auto UpdateHandlers = {
|
||||
UpdateHandler { ".msi", "msiexec /i \"{}\" /qb" },
|
||||
UpdateHandler { ".dmg", "hdiutil attach -autoopen \"{}\"" },
|
||||
UpdateHandler { ".deb", "sudo apt update && sudo apt install -y --fix-broken \"{}\"" },
|
||||
UpdateHandler { ".rpm", "sudo rpm -i \"{}\"" },
|
||||
UpdateHandler { ".pkg.tar.zst", "sudo pacman -Syy && sudo pacman -U --noconfirm \"{}\"" }
|
||||
const static auto UpdateHandlers = {
|
||||
UpdateHandler { ".msi", "msiexec /i \"{}\" /qb" },
|
||||
UpdateHandler { ".dmg", "hdiutil attach -autoopen \"{}\"" },
|
||||
UpdateHandler { ".deb", "sudo apt install -y --fix-broken \"{}\"" },
|
||||
UpdateHandler { ".rpm", "sudo rpm -i \"{}\"" },
|
||||
UpdateHandler { ".pkg.tar.zst", "sudo pacman -Syy && sudo pacman -U --noconfirm \"{}\"" },
|
||||
UpdateHandler { ".AppImage", fmt::format("sudo cp \"{{}}\" \"{}\"", *hex::getEnvironmentVariable("APPIMAGE")) },
|
||||
UpdateHandler { ".flatpak", "sudo flatpak install -y --reinstall \"{}\"" },
|
||||
UpdateHandler { ".snap", "sudo snap install --dangerous \"{}\"" },
|
||||
};
|
||||
|
||||
const auto updateFileName = wolv::util::toUTF8String(updatePath.filename());
|
||||
|
||||
@@ -421,6 +421,11 @@ namespace hex::plugin::builtin {
|
||||
std::vector<ContentRegistry::CommandPaletteCommands::impl::QueryResult> result;
|
||||
|
||||
for (const auto &[unlocalizedName, view] : ContentRegistry::Views::impl::getEntries()) {
|
||||
if (!view->shouldProcess())
|
||||
continue;
|
||||
if (!view->hasViewMenuItemEntry())
|
||||
continue;
|
||||
|
||||
const auto name = Lang(unlocalizedName);
|
||||
if (!hex::containsIgnoreCase(name, input))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user