diff options
author | Vaxry <[email protected]> | 2024-04-05 00:44:21 +0100 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-04-05 00:46:37 +0100 |
commit | 1ae592fcd94b86c4fee6b91786dfdc78724930fe (patch) | |
tree | 40b566cbcf0aa1c92f28c9ab4ff8e91b5639a8ba /hyprpm | |
parent | 51b3148f097f7cd371622aff5c144ca6ccbeda92 (diff) | |
download | Hyprland-1ae592fcd94b86c4fee6b91786dfdc78724930fe.tar.gz Hyprland-1ae592fcd94b86c4fee6b91786dfdc78724930fe.zip |
hyprpm: add support for minimum versions
Diffstat (limited to 'hyprpm')
-rw-r--r-- | hyprpm/src/core/Manifest.cpp | 1 | ||||
-rw-r--r-- | hyprpm/src/core/Manifest.hpp | 1 | ||||
-rw-r--r-- | hyprpm/src/core/PluginManager.cpp | 46 | ||||
-rw-r--r-- | hyprpm/src/core/PluginManager.hpp | 1 |
4 files changed, 39 insertions, 10 deletions
diff --git a/hyprpm/src/core/Manifest.cpp b/hyprpm/src/core/Manifest.cpp index 27ad058a..42a8357c 100644 --- a/hyprpm/src/core/Manifest.cpp +++ b/hyprpm/src/core/Manifest.cpp @@ -75,6 +75,7 @@ CManifest::CManifest(const eManifestType type, const std::string& path) { for (auto& plugin : m_vPlugins) { plugin.description = manifest[plugin.name]["description"].value_or("?"); plugin.output = manifest[plugin.name]["output"].value_or("?"); + plugin.since = manifest[plugin.name]["since_hyprland"].value_or(0); auto authors = manifest[plugin.name]["authors"].as_array(); if (authors) { for (auto&& a : *authors) { diff --git a/hyprpm/src/core/Manifest.hpp b/hyprpm/src/core/Manifest.hpp index 55b4a7f0..19f967eb 100644 --- a/hyprpm/src/core/Manifest.hpp +++ b/hyprpm/src/core/Manifest.hpp @@ -19,6 +19,7 @@ class CManifest { std::vector<std::string> authors; std::vector<std::string> buildSteps; std::string output; + int since = 0; bool failed = false; }; diff --git a/hyprpm/src/core/PluginManager.cpp b/hyprpm/src/core/PluginManager.cpp index 956c0612..64b87379 100644 --- a/hyprpm/src/core/PluginManager.cpp +++ b/hyprpm/src/core/PluginManager.cpp @@ -70,10 +70,22 @@ SHyprlandVersion CPluginManager::getHyprlandVersion() { std::string hlbranch = HLVERCALL.substr(HLVERCALL.find("from branch") + 12); hlbranch = hlbranch.substr(0, hlbranch.find(" at commit ")); + std::string hlcommits; + + if (HLVERCALL.contains("commits:")) { + hlcommits = HLVERCALL.substr(HLVERCALL.find("commits:") + 10); + hlcommits = hlcommits.substr(0, hlcommits.find(" ")); + } + + int commits = 0; + try { + commits = std::stoi(hlcommits); + } catch (...) { ; } + if (m_bVerbose) std::cout << Colors::BLUE << "[v] " << Colors::RESET << "parsed commit " << hlcommit << " at branch " << hlbranch << "\n"; - ver = SHyprlandVersion{hlbranch, hlcommit}; + ver = SHyprlandVersion{hlbranch, hlcommit, commits}; return ver; } @@ -214,6 +226,12 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& for (auto& p : pManifest->m_vPlugins) { std::string out; + if (p.since > HLVER.commits) { + progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n"); + p.failed = true; + continue; + } + progress.printMessageAbove(std::string{Colors::RESET} + " → Building " + p.name); for (auto& bs : p.buildSteps) { @@ -225,10 +243,12 @@ bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n"; if (!std::filesystem::exists("/tmp/hyprpm/new/" + p.output)) { - progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " Plugin " + p.name + " failed to build.\n" << " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n Try re-running with -v to see more verbose output.\n"); + progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " Plugin " + p.name + " failed to build.\n" + + " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update " + "first.\n Try re-running with -v to see " + "more verbose output.\n"); p.failed = true; - continue; } @@ -576,10 +596,15 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { } } - bool failed = false; for (auto& p : pManifest->m_vPlugins) { std::string out; + if (p.since > HLVER.commits) { + progress.printMessageAbove(std::string{Colors::RED} + "✖" + Colors::RESET + " Not building " + p.name + ": your Hyprland version is too old.\n"); + p.failed = true; + continue; + } + progress.printMessageAbove(std::string{Colors::RESET} + " → Building " + p.name); for (auto& bs : p.buildSteps) { @@ -591,17 +616,18 @@ bool CPluginManager::updatePlugins(bool forceUpdateAll) { std::cout << Colors::BLUE << "[v] " << Colors::RESET << "shell returned: " << out << "\n"; if (!std::filesystem::exists("/tmp/hyprpm/update/" + p.output)) { - std::cerr << "\n" << Colors::RED << "✖" << Colors::RESET << " Plugin " << p.name << " failed to build.\n" << " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n Try re-running with -v to see more verbose output.\n"; - failed = true; - break; + std::cerr << "\n" + << Colors::RED << "✖" << Colors::RESET << " Plugin " << p.name << " failed to build.\n" + << " This likely means that the plugin is either outdated, not yet available for your version, or broken.\n If you are on -git, update first.\n Try " + "re-running with -v to see more verbose " + "output.\n"; + p.failed = true; + continue; } progress.printMessageAbove(std::string{Colors::GREEN} + "✔" + Colors::RESET + " built " + p.name + " into " + p.output); } - if (failed) - continue; - // add repo toml to DataState SPluginRepository newrepo = repo; newrepo.plugins.clear(); diff --git a/hyprpm/src/core/PluginManager.hpp b/hyprpm/src/core/PluginManager.hpp index 028e6357..901a9b4b 100644 --- a/hyprpm/src/core/PluginManager.hpp +++ b/hyprpm/src/core/PluginManager.hpp @@ -32,6 +32,7 @@ enum ePluginLoadStateReturn { struct SHyprlandVersion { std::string branch; std::string hash; + int commits = 0; }; class CPluginManager { |