From: Jan Kupec Date: Mon, 13 Aug 2007 14:41:38 +0000 (+0000) Subject: - providing correct capability for installing a resolvable (#298322) X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~154 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d7f0f367fb8fe5f8cc97325caa3729e0e8a7ab0;p=platform%2Fupstream%2Fzypper.git - providing correct capability for installing a resolvable (#298322) --- diff --git a/src/zypper-misc.cc b/src/zypper-misc.cc index 045b7f8..51051a4 100644 --- a/src/zypper-misc.cc +++ b/src/zypper-misc.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -160,6 +161,20 @@ static std::string xml_escape( const std::string &text ) return parser.escape(text); } +struct VersionGetter +{ + Edition edition; + bool found; + + VersionGetter() : found(false) {} + + bool operator()(const zypp::PoolItem& item) + { + edition = item.resolvable()->edition(); + found = true; + return false; // don't iterate further + } +}; // on error print a message and return noCap Capability safe_parse_cap (const ResObject::Kind &kind, const string & capstr) { @@ -181,6 +196,25 @@ Capability safe_parse_cap (const ResObject::Kind &kind, const string & capstr) { cout_vv << "new capstr: " << new_capstr << endl; } } + // if we are about to install stuff and + // if this is not a candidate for a version capability, take it like + // a package name and check if it is already installed + else if (command == ZypperCommand::INSTALL) + { + VersionGetter vg; + invokeOnEach( + God->pool().byNameBegin(capstr), + God->pool().byNameEnd(capstr), + resfilter::ByKind(kind), + functor::functorRef (vg) + ); + if (vg.found) + { + new_capstr = capstr + ">" + vg.edition.asString(); + cout_vv << "installed resolvable named " << capstr + << " found, changing capability to " << new_capstr << endl; + } + } cap = CapFactory().parse (kind, new_capstr); }