From eee61ad9c8ca07b6716addf06bc751ca490f5255 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Thu, 9 Jul 2009 12:18:32 +0200 Subject: [PATCH] Enable use of name-version.arch all together (bnc #519312). --- src/install.cc | 6 +++--- src/utils/misc.cc | 20 ++++++++++++-------- src/utils/misc.h | 3 ++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/install.cc b/src/install.cc index 8b72666..d63cd6d 100755 --- a/src/install.cc +++ b/src/install.cc @@ -570,7 +570,6 @@ void install_remove(Zypper & zypper, if ((pos = str.rfind('.')) != string::npos) { arch = str.substr(pos + 1); - //str = str.substr(0, pos); if (Arch(arch).isBuiltIn()) { if (force_by_name) @@ -584,6 +583,7 @@ void install_remove(Zypper & zypper, // name.arch is a valid capability since libzypp-4.15.0 (bnc #305445) by_capability = true; + str = str.substr(0, pos); } else { @@ -640,7 +640,7 @@ void install_remove(Zypper & zypper, DBG << "trying: " << trythis << " edition: " << tryver << endl; - Capability cap = safe_parse_cap (zypper, trythis, kind); + Capability cap = safe_parse_cap (zypper, trythis, kind, arch); sat::WhatProvides q(cap); for_(sit, q.begin(), q.end()) { @@ -679,7 +679,7 @@ void install_remove(Zypper & zypper, // try by capability - Capability cap = safe_parse_cap (zypper, str, kind); + Capability cap = safe_parse_cap (zypper, str, kind, arch); sat::WhatProvides q(cap); // is there a provider for the requested capability? diff --git a/src/utils/misc.cc b/src/utils/misc.cc index 6c44e8a..618dcd0 100644 --- a/src/utils/misc.cc +++ b/src/utils/misc.cc @@ -304,7 +304,7 @@ std::string & indent(std::string & text, int columns) return text; } -static string preparse_cap_str(const string & capstr) +static string preparse_cap_str(const string & capstr, const string & arch) { // expect versioned caps as NAME[OP] // transform to NAME[ OP ] (add spaces) @@ -315,12 +315,15 @@ static string preparse_cap_str(const string & capstr) { new_capstr.insert(op_pos, " "); DBG << "new capstr: " << new_capstr << endl; - op_pos = new_capstr.find_first_not_of("<>=", op_pos + 1); - if (op_pos != string::npos && new_capstr.size() > op_pos) + string::size_type post_op_pos = + new_capstr.find_first_not_of("<>=", op_pos + 1); + if (post_op_pos != string::npos && new_capstr.size() > post_op_pos) { - new_capstr.insert(op_pos, " "); - DBG << "new capstr: " << new_capstr << endl; + new_capstr.insert(post_op_pos, " "); } + if (!arch.empty()) + new_capstr.insert(op_pos, "." + arch); + DBG << "new capstr: " << new_capstr << endl; } return new_capstr; @@ -328,14 +331,15 @@ static string preparse_cap_str(const string & capstr) Capability safe_parse_cap (Zypper & zypper, const string & capstr, - const ResKind & kind) + const ResKind & kind, + const string & arch) { try { if (kind == ResKind::nokind) - return Capability(preparse_cap_str(capstr)); + return Capability(preparse_cap_str(capstr, arch)); else - return Capability(preparse_cap_str(capstr), kind); + return Capability(preparse_cap_str(capstr, arch), kind); } catch (const Exception& e) { diff --git a/src/utils/misc.h b/src/utils/misc.h index 67f9b7f..f8888c2 100644 --- a/src/utils/misc.h +++ b/src/utils/misc.h @@ -86,7 +86,8 @@ std::string & indent(std::string & text, int columns); zypp::Capability safe_parse_cap (Zypper & zypper, const std::string & capstr, - const zypp::ResKind & kind = zypp::ResKind::nokind); + const zypp::ResKind & kind = zypp::ResKind::nokind, + const std::string & arch = ""); // comparator for RepoInfo set -- 2.7.4