From 24508e6721e9858084618816d0757d19918c6418 Mon Sep 17 00:00:00 2001 From: Jaroslav Mracek Date: Wed, 26 Jul 2023 10:54:23 +0200 Subject: [PATCH] Set substitution for librepo handle from Base Vars It allows substitutions in mirrorlist. Additionally it marks method of Repo class as deprecated, because it is not required anymore. Closes: https://github.com/rpm-software-management/dnf5/issues/761 --- include/libdnf5/repo/repo.hpp | 1 + libdnf5/repo/repo_downloader.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/libdnf5/repo/repo.hpp b/include/libdnf5/repo/repo.hpp index 6adea48eb..5ef93958f 100644 --- a/include/libdnf5/repo/repo.hpp +++ b/include/libdnf5/repo/repo.hpp @@ -327,6 +327,7 @@ class Repo { // @replaces libdnf:repo/Repo.hpp:method:Repo.getMirrors() std::vector get_mirrors() const; + /// @deprecated It is redundant because repo class has direct access to Base and Vars /// Sets substitutions. Substitutions are used to substitute variables in repository configuration. // @replaces libdnf:repo/Repo.hpp:method:Repo.setSubstitutions(const std::map & substitutions) void set_substitutions(const std::map & substitutions); diff --git a/libdnf5/repo/repo_downloader.cpp b/libdnf5/repo/repo_downloader.cpp index 9df1ab823..db1d8c470 100644 --- a/libdnf5/repo/repo_downloader.cpp +++ b/libdnf5/repo/repo_downloader.cpp @@ -511,9 +511,13 @@ void RepoDownloader::common_handle_setup(LibrepoHandle & h) { h.set_opt(LRO_YUMSLIST, repomd_substs); LrUrlVars * substs = nullptr; + // Deprecated, we have direct access to base, therefore we don't need to set explicitly substitutions for (const auto & item : substitutions) { substs = lr_urlvars_set(substs, item.first.c_str(), item.second.c_str()); } + for (const auto & item : base->get_vars()->get_variables()) { + substs = lr_urlvars_set(substs, item.first.c_str(), item.second.value.c_str()); + } h.set_opt(LRO_VARSUB, substs); #ifdef LRO_SUPPORTS_CACHEDIR