diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-04-05 00:44:21 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-04-05 00:46:37 +0100 |
| commit | 1ae592fcd94b86c4fee6b91786dfdc78724930fe (patch) | |
| tree | 40b566cbcf0aa1c92f28c9ab4ff8e91b5639a8ba /hyprpm/src/core/PluginManager.cpp | |
| parent | 51b3148f097f7cd371622aff5c144ca6ccbeda92 (diff) | |
hyprpm: add support for minimum versions
Diffstat (limited to 'hyprpm/src/core/PluginManager.cpp')
| -rw-r--r-- | hyprpm/src/core/PluginManager.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
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(); |
