From: Michael Andres Date: Fri, 15 Apr 2011 18:48:59 +0000 (+0200) Subject: Fix list-patches/updates xml output to include architecture and patch status informat... X-Git-Tag: 1.5.8~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f9d7c3c009bd5fc9e9f18287c10e7c2063baf928;p=platform%2Fupstream%2Fzypper.git Fix list-patches/updates xml output to include architecture and patch status information (bnc#687529) --- diff --git a/src/output/xmlout.rnc b/src/output/xmlout.rnc index 8f4a642..087b1c6 100644 --- a/src/output/xmlout.rnc +++ b/src/output/xmlout.rnc @@ -56,7 +56,7 @@ download-progress-done = message-element = element message { - attribute type { "info" | "warning" | "error" }, # considering yet another type "result", maybe a separate element + attribute type { "info" | "warning" | "error" }, # considering yet another type "result", maybe a separate element text } @@ -81,6 +81,7 @@ update-status-element = update-commons = attribute name { xsd:string }, attribute edition { xsd:string }, + attribute arch { xsd:string }, element summary { text }, element description { text }, element license { text }, @@ -99,6 +100,7 @@ patch-update = element update { update-commons, attribute kind { "patch" }, + attribute status { "needed" | "unwanted" | "applied" | "not-needed" | "undetermined" }?, # attribute category { xsd:string }?, # patch category (security, recommended, ...) attribute pkgmanager { xsd:boolean }, # affect package management? attribute restart { xsd:boolean }, # needs restart of the machine? @@ -181,7 +183,7 @@ selectable-info-element = common-selectable-info & ( package-selectable-info | - patch-selectable-info + patch-selectable-info #pattern-selectable-info | #product-selectable-info ) diff --git a/src/update.cc b/src/update.cc index 2776708..903767b 100755 --- a/src/update.cc +++ b/src/update.cc @@ -79,9 +79,20 @@ void patch_check () } // ---------------------------------------------------------------------------- +inline const char *const patchStatusAsString( const PoolItem & pi_r ) +{ + switch ( pi_r.status().validate() ) + { + case zypp::ResStatus::UNDETERMINED: return "undetermined"; break; + case zypp::ResStatus::BROKEN: return pi_r.isUnwanted() ? "unwanted" + : "needed"; break; + case zypp::ResStatus::SATISFIED: return "applied"; break; + case zypp::ResStatus::NONRELEVANT: return "not-needed"; break; + } +} // returns true if restartSuggested() patches are availble -static bool xml_list_patches () +static bool xml_list_patches (Zypper & zypper) { const zypp::ResPool& pool = God->pool(); @@ -107,7 +118,7 @@ static bool xml_list_patches () it = pool.byKindBegin(ResKind::patch); for (; it != e; ++it, ++patchcount) { - if (it->isRelevant() && !it->isSatisfied()) + if (zypper.cOpts().count("all") || it->isBroken()) { ResObject::constPtr res = it->resolvable(); Patch::constPtr patch = asKind(res); @@ -118,6 +129,8 @@ static bool xml_list_patches () cout << " name () << "\" "; cout << "edition=\"" << res->edition ().asString() << "\" "; + cout << "arch=\"" << res->arch().asString() << "\" "; + cout << "status=\"" << patchStatusAsString( *it ) << "\" "; cout << "category=\"" << patch->category() << "\" "; cout << "pkgmanager=\"" << (patch->restartSuggested() ? "true" : "false") << "\" "; cout << "restart=\"" << (patch->rebootSuggested() ? "true" : "false") << "\" "; @@ -160,6 +173,7 @@ static void xml_list_updates(const ResKindSet & kinds) cout << " name () << "\" " ; cout << "edition=\"" << res->edition ().asString() << "\" "; + cout << "arch=\"" << res->arch().asString() << "\" "; cout << "kind=\"" << res->kind() << "\" "; cout << ">" << endl; cout << " " << xml_encode(res->summary()) << " " << endl; @@ -394,7 +408,7 @@ void list_updates(Zypper & zypper, const ResKindSet & kinds, bool best_effort) if(it != localkinds.end()) { if (zypper.out().type() == Out::TYPE_XML) - affects_pkgmgr = xml_list_patches(); + affects_pkgmgr = xml_list_patches(zypper); else { if (kinds.size() > 1)