Skip to content

Commit

Permalink
hyprpm: err out on missing runtime deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Apr 16, 2024
1 parent 9a66514 commit eeca50e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hyprpm/src/core/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ SHyprlandVersion CPluginManager::getHyprlandVersion() {
bool CPluginManager::addNewPluginRepo(const std::string& url, const std::string& rev) {
const auto HLVER = getHyprlandVersion();

if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
return false;
}

if (DataState::pluginRepoExists(url)) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not clone the plugin repository. Repository already installed.\n";
return false;
Expand Down Expand Up @@ -378,6 +383,11 @@ bool CPluginManager::updateHeaders(bool force) {

const auto HLVER = getHyprlandVersion();

if (!hasDeps()) {
std::cerr << "\n" << Colors::RED << "" << Colors::RESET << " Could not update. Dependencies not satisfied. Hyprpm requires: cmake, meson, cpio\n";
return false;
}

if (!std::filesystem::exists("/tmp/hyprpm")) {
std::filesystem::create_directory("/tmp/hyprpm");
std::filesystem::permissions("/tmp/hyprpm", std::filesystem::perms::all, std::filesystem::perm_options::replace);
Expand Down Expand Up @@ -833,3 +843,13 @@ std::string CPluginManager::headerError(const eHeadersErrors err) {

return std::string{Colors::RED} + "" + Colors::RESET + " Unknown header error. Please run hyprpm update to fix those.\n";
}

bool CPluginManager::hasDeps() {
std::vector<std::string> deps = {"meson", "cpio", "cmake"};
for (auto& d : deps) {
if (!execAndGet("which " + d + " 2>&1").contains("/"))
return false;
}

return true;
}
2 changes: 2 additions & 0 deletions hyprpm/src/core/PluginManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class CPluginManager {

void notify(const eNotifyIcons icon, uint32_t color, int durationMs, const std::string& message);

bool hasDeps();

bool m_bVerbose = false;

private:
Expand Down

0 comments on commit eeca50e

Please sign in to comment.