diff --git a/include/cloysterhpc/repos.h b/include/cloysterhpc/repos.h index 24e6e97..3be92b8 100644 --- a/include/cloysterhpc/repos.h +++ b/include/cloysterhpc/repos.h @@ -36,21 +36,18 @@ class /* [[deprecated("refactoring")]] */ RepoManager { public: RepoManager(Runner& runner, const OS& osinfo); void loadFiles(const std::filesystem::path& basedir = "/etc/yum.repos.d"); - void loadCustom(inifile& file, const std::filesystem::path& path); - - // BUG: Enable and EnableMultiple are the same method. Overload it. - void enable(const std::string& id); - void enableMultiple(std::vector ids); - void disable(const std::string& id); - void commitStatus(); - + void enable(const std::string& repo); + void enableMultiple(std::vector repos); + void disable(const std::string& repo); const std::vector& listRepos() const; - - std::vector getxCATOSImageRepos() const; + [[nodiscard]] std::vector getxCATOSImageRepos() const; private: + void loadCustom(inifile& file, const std::filesystem::path& path); + // BUG: Enable and EnableMultiple are the same method. Overload it. std::vector m_repos; + BaseRunner& m_runner; const OS& m_os; diff --git a/src/repos.cpp b/src/repos.cpp index 7743496..2e8395e 100644 --- a/src/repos.cpp +++ b/src/repos.cpp @@ -198,22 +198,15 @@ static std::string buildPackageName(std::string stem) } static std::vector getDependenciesEL( - const OS& os, OS::Platform platform) + const OS& os) { + const auto platform = os.getPlatform(); std::vector dependencies; - // BUG: Bad code. We should use the OS::getVersion() method. - std::size_t version; + std::size_t version = os.getMajorVersion(); std::string powertools = "powertools"; if (platform == OS::Platform::el8) { powertools = "crb"; - version = 8; - } - if (platform == OS::Platform::el9) { - version = 9; - } - if (platform == OS::Platform::el10) { - version = 10; } switch (os.getDistro()) { @@ -243,10 +236,12 @@ static std::vector getDependenciesEL( template void RepoManager::configureEL() { - std::vector deps = getDependenciesEL(m_os, m_os.getPlatform()); + std::vector deps = getDependenciesEL(m_os); std::for_each( - deps.begin(), deps.end(), [this](const auto& id) { this->enable(id); }); + deps.begin(), deps.end(), [this](const auto& repo) { + this->enable(repo); + }); } template <> diff --git a/src/services/shell.cpp b/src/services/shell.cpp index 7c7e70c..ed361c5 100644 --- a/src/services/shell.cpp +++ b/src/services/shell.cpp @@ -404,11 +404,12 @@ void Shell::install() auto repos = *cloyster::getRepoManager(m_cluster->getHeadnode().getOS()); repos.loadFiles(); - std::vector toEnable = { "-beegfs", "-elrepo", "-epel", - "-openhpc", "-openhpc-updates", "-rpmfusion-free-updates" }; - for (auto& package : toEnable) { - package = cloyster::productName + package; - } + const auto toEnable = + std::vector({ "-beegfs", "-elrepo", "-epel", "-openhpc", "-openhpc-updates", "-rpmfusion-free-updates" }) + | std::views::transform([&](const std::string& pkg) { + return cloyster::productName + pkg; + }) + | std::ranges::to>(); repos.enableMultiple(toEnable); repos.commitStatus();