From cd7569cc81822cfed9e08837114d85459b5b9323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Thu, 18 Jan 2024 19:52:59 +0100 Subject: [PATCH] Fixed repository and service probing (bsc#1218977, bsc#1218399) ... with libzypp 7.31.26 and newer - fixes broken repository handling - 4.5.3 --- configure.in.in | 3 ++- package/yast2-pkg-bindings-devel-doc.spec | 2 +- package/yast2-pkg-bindings.changes | 8 ++++++ package/yast2-pkg-bindings.spec | 2 +- src/PkgFunctions.h | 2 +- src/ServiceManager.cc | 12 ++++++++- src/Source_Create.cc | 2 +- src/Source_Get.cc | 2 +- src/Source_Misc.cc | 32 +++++++---------------- 9 files changed, 35 insertions(+), 30 deletions(-) diff --git a/configure.in.in b/configure.in.in index a38b8031..35a883ee 100644 --- a/configure.in.in +++ b/configure.in.in @@ -29,7 +29,8 @@ fi AX_CHECK_DOCBOOK # libzypp uses the C++17 standard -CXXFLAGS="${CXXFLAGS} -std=c++17" +# treat missing values in switch statements as errors +CXXFLAGS="${CXXFLAGS} -std=c++17 -Werror=switch" ## and generate the output @YAST2-OUTPUT@ diff --git a/package/yast2-pkg-bindings-devel-doc.spec b/package/yast2-pkg-bindings-devel-doc.spec index 25a68882..0e47717e 100644 --- a/package/yast2-pkg-bindings-devel-doc.spec +++ b/package/yast2-pkg-bindings-devel-doc.spec @@ -17,7 +17,7 @@ Name: yast2-pkg-bindings-devel-doc -Version: 4.5.2 +Version: 4.5.3 Release: 0 Summary: YaST2 - Documentation for yast2-pkg-bindings package License: GPL-2.0-only diff --git a/package/yast2-pkg-bindings.changes b/package/yast2-pkg-bindings.changes index 3c08c886..a5c8b015 100644 --- a/package/yast2-pkg-bindings.changes +++ b/package/yast2-pkg-bindings.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Jan 19 13:47:43 UTC 2024 - Ladislav Slezák + +- Fixed repository and service probing with libzypp 7.31.26 + and newer, fixes broken repository handling (bsc#1218977, + bsc#1218399) +- 4.5.3 + ------------------------------------------------------------------- Wed Apr 12 07:36:47 UTC 2023 - Ladislav Slezák diff --git a/package/yast2-pkg-bindings.spec b/package/yast2-pkg-bindings.spec index 8a6c4764..8a35609f 100644 --- a/package/yast2-pkg-bindings.spec +++ b/package/yast2-pkg-bindings.spec @@ -17,7 +17,7 @@ Name: yast2-pkg-bindings -Version: 4.5.2 +Version: 4.5.3 Release: 0 Summary: YaST2 - Package Manager Access License: GPL-2.0-only diff --git a/src/PkgFunctions.h b/src/PkgFunctions.h index 57fd2b0a..77d2e20a 100644 --- a/src/PkgFunctions.h +++ b/src/PkgFunctions.h @@ -149,7 +149,7 @@ class PkgFunctions bool remoteRepo(const zypp::Url &url); // conversion methods for type string between Yast and libzypp (for backward compatibility) - std::string zypp2yastType(const std::string &type); + std::string zypp2yastType(const zypp::repo::RepoType &type); std::string yast2zyppType(const std::string &type); // helper - create a directory if it doesn't exist diff --git a/src/ServiceManager.cc b/src/ServiceManager.cc index 4cd69b6b..6348e1f0 100644 --- a/src/ServiceManager.cc +++ b/src/ServiceManager.cc @@ -300,7 +300,17 @@ bool ServiceManager::SetService(const std::string &old_alias, const zypp::Servic std::string ServiceManager::Probe(const zypp::Url &url, const zypp::RepoManager &repomgr) const { y2milestone("Probing service at %s...", url.asString().c_str()); - std::string ret(repomgr.probeService(url).asString()); + + std::string ret; + + zypp::repo::ServiceType type(repomgr.probeService(url)); + switch (type.toEnum()) + { + case zypp::repo::ServiceType::NONE_e: ret = "NONE"; break; + case zypp::repo::ServiceType::PLUGIN_e: ret = "plugin"; break; + case zypp::repo::ServiceType::RIS_e: ret = "ris"; break; + } + y2milestone("Detected service type: %s", ret.c_str()); return ret; diff --git a/src/Source_Create.cc b/src/Source_Create.cc index ed4d7098..f904dd80 100644 --- a/src/Source_Create.cc +++ b/src/Source_Create.cc @@ -814,7 +814,7 @@ YCPValue PkgFunctions::RepositoryProbe(const YCPString& url, const YCPString& pr // autoprobe type of the repository zypp::repo::RepoType repotype = ProbeWithCallbacks(probe_url); - ret = zypp2yastType(repotype.asString()); + ret = zypp2yastType(repotype); y2milestone("Detected type: '%s'...", ret.c_str()); } catch (const zypp::Exception& excpt) diff --git a/src/Source_Get.cc b/src/Source_Get.cc index 217bf92e..bcb954ab 100644 --- a/src/Source_Get.cc +++ b/src/Source_Get.cc @@ -134,7 +134,7 @@ PkgFunctions::SourceGeneralData (const YCPInteger& id) return YCPVoid (); // convert type to the old strings ("YaST", "YUM" or "Plaindir") - std::string srctype = zypp2yastType(repo->repoInfo().type().asString()); + std::string srctype = zypp2yastType(repo->repoInfo().type()); data->add( YCPString("enabled"), YCPBoolean(repo->repoInfo().enabled())); data->add( YCPString("autorefresh"), YCPBoolean(repo->repoInfo().autorefresh())); diff --git a/src/Source_Misc.cc b/src/Source_Misc.cc index 92c225d1..de8cd6f7 100644 --- a/src/Source_Misc.cc +++ b/src/Source_Misc.cc @@ -108,32 +108,18 @@ bool PkgFunctions::aliasExists(const std::string &alias, const std::list::const_iterator it = type_conversion_table.find(type); - - // found in the conversion table - if (it != type_conversion_table.end()) - { - ret = it->second; - } - else - { - y2error("Cannot convert type '%s'", type.c_str()); - } - - return ret; + // never reached, unhandled enums are treated as errors via the -Werror option + return ""; } std::string PkgFunctions::yast2zyppType(const std::string &type) @@ -159,7 +145,7 @@ std::string PkgFunctions::UniqueAlias(const std::string &alias) { y2milestone("Alias %s already found: %lld", ret.c_str(), logFindAlias(ret)); - // the alias already exists - add a counter + // the alias already exists - add a counter std::ostringstream ostr; ostr << alias << "_" << id;