From 8a795de9ad98af6139551f6a0754fe7b3e677d13 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 04 2021 06:13:19 +0000 Subject: import libdnf-0.55.0-2.el8 --- diff --git a/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch b/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch new file mode 100644 index 0000000..7666421 --- /dev/null +++ b/SOURCES/0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch @@ -0,0 +1,87 @@ +From 2353dfbcb49a16bd37115915517417678fe49b19 Mon Sep 17 00:00:00 2001 +From: Jaroslav Rohel +Date: Fri, 13 Nov 2020 09:55:23 +0100 +Subject: [PATCH] Better msgs if "basecachedir" or "proxy_password" isn't set + (RhBug:1888946) + +Generates more specific error messages: +- repo '%s': 'basecachedir' is not set +- repo '%s': 'proxy_username' is set but not 'proxy_password' +- 'proxy_username' is set but not 'proxy_password' +instead of generic "GetValue(): Value not set" +--- + libdnf/repo/Repo.cpp | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp +index d7c137d75..34539e1ee 100644 +--- a/libdnf/repo/Repo.cpp ++++ b/libdnf/repo/Repo.cpp +@@ -484,8 +484,12 @@ std::unique_ptr Repo::Impl::lrHandleInitLocal() + handleSetOpt(h.get(), LRO_LOCAL, 1L); + #ifdef LRO_SUPPORTS_CACHEDIR + /* If zchunk is enabled, set librepo cache dir */ +- if (conf->getMasterConfig().zchunk().getValue()) ++ if (conf->getMasterConfig().zchunk().getValue()) { ++ if (conf->basecachedir().empty()) { ++ throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id)); ++ } + handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str()); ++ } + #endif + return h; + } +@@ -526,6 +530,9 @@ std::unique_ptr Repo::Impl::lrHandleInitRemote(const char *destdir) + handleSetOpt(h.get(), LRO_METALINKURL, tmp.c_str()); + } + handleSetOpt(h.get(), LRO_FASTESTMIRROR, conf->fastestmirror().getValue() ? 1L : 0L); ++ if (conf->basecachedir().empty()) { ++ throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id)); ++ } + auto fastestMirrorCacheDir = conf->basecachedir().getValue(); + if (fastestMirrorCacheDir.back() != '/') + fastestMirrorCacheDir.push_back('/'); +@@ -569,8 +576,12 @@ std::unique_ptr Repo::Impl::lrHandleInitRemote(const char *destdir) + + #ifdef LRO_SUPPORTS_CACHEDIR + /* If zchunk is enabled, set librepo cache dir */ +- if (conf->getMasterConfig().zchunk().getValue()) ++ if (conf->getMasterConfig().zchunk().getValue()) { ++ if (conf->basecachedir().empty()) { ++ throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id)); ++ } + handleSetOpt(h.get(), LRO_CACHEDIR, conf->basecachedir().getValue().c_str()); ++ } + #endif + + auto minrate = conf->minrate().getValue(); +@@ -610,6 +621,9 @@ std::unique_ptr Repo::Impl::lrHandleInitRemote(const char *destdir) + if (!conf->proxy_username().empty()) { + userpwd = conf->proxy_username().getValue(); + if (!userpwd.empty()) { ++ if (conf->proxy_password().empty()) { ++ throw RepoError(tfm::format(_("repo '%s': 'proxy_username' is set but not 'proxy_password'"), id)); ++ } + userpwd = formatUserPassString(userpwd, conf->proxy_password().getValue(), true); + handleSetOpt(h.get(), LRO_PROXYUSERPWD, userpwd.c_str()); + } +@@ -1346,6 +1360,9 @@ std::string Repo::Impl::getHash() const + + std::string Repo::Impl::getCachedir() const + { ++ if (conf->basecachedir().empty()) { ++ throw Exception(tfm::format(_("repo '%s': 'basecachedir' is not set"), id)); ++ } + auto repodir(conf->basecachedir().getValue()); + if (repodir.back() != '/') + repodir.push_back('/'); +@@ -1690,6 +1707,9 @@ static LrHandle * newHandle(ConfigMain * conf) + if (!conf->proxy_username().empty()) { + auto userpwd = conf->proxy_username().getValue(); + if (!userpwd.empty()) { ++ if (conf->proxy_password().empty()) { ++ throw RepoError(_("'proxy_username' is set but not 'proxy_password'")); ++ } + userpwd = formatUserPassString(userpwd, conf->proxy_password().getValue(), true); + handleSetOpt(h, LRO_PROXYUSERPWD, userpwd.c_str()); + } diff --git a/SPECS/libdnf.spec b/SPECS/libdnf.spec index de52c6c..5305a12 100644 --- a/SPECS/libdnf.spec +++ b/SPECS/libdnf.spec @@ -56,11 +56,12 @@ Name: libdnf Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version} -Release: 1%{?dist} +Release: 2%{?dist} Summary: Library providing simplified C and Python API to libsolv License: LGPLv2+ URL: https://github.com/rpm-software-management/libdnf Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch0: 0001-Better-msgs-if-basecachedir-or-proxy-password-isn-t-set-RhBug-1888946.patch BuildRequires: cmake BuildRequires: gcc @@ -308,6 +309,9 @@ popd %endif %changelog +* Fri Jan 15 2021 Nicola Sella - 0.55.0-2 +- Better msgs if "basecachedir" or "proxy_password" isn't set (RhBug:1888946) + * Mon Nov 09 2020 Nicola Sella - 0.55.0-1 - Add vendor to dnf API (RhBug:1876561) - Add formatting function for solver error