From: Martin Vidner Date: Sun, 1 Oct 2006 11:07:30 +0000 (+0000) Subject: added command: patches X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~330 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8861301294cf84d1fdc4ea6608f99c9f2de52345;p=platform%2Fupstream%2Flibzypp.git added command: patches --- diff --git a/tools/zmart/zmart-misc.cc b/tools/zmart/zmart-misc.cc index 46a8586..d19d854 100644 --- a/tools/zmart/zmart-misc.cc +++ b/tools/zmart/zmart-misc.cc @@ -331,33 +331,53 @@ void patch_check () cout << gData.patches_count << " patches needed. ( " << gData.security_patches_count << " security patches )" << std::endl; } +string string_status (const ResStatus& rs) +{ + bool i = rs.isInstalled (); + if (rs.isUndetermined ()) + return i? "Installed": "Uninstalled"; + else if (rs.isEstablishedUneeded ()) + return i? "No Longer Applicable": "Not Applicable"; + else if (rs.isEstablishedSatisfied ()) + return i? "Applied": "Not Needed"; + else if (rs.isEstablishedIncomplete ()) + return i? "Broken": "Needed"; + // if ResStatus interface changes + return "error"; +} + +// patches void show_pool() { MIL << "Pool contains " << God->pool().size() << " items. Checking whether available patches are needed." << std::endl; Table tbl; + TableRow th; + th << "Catalog" << "Name" << "Version" << "Category" << "Status"; + tbl << th; + tbl.hasHeader (true); + ResPool::byKind_iterator it = God->pool().byKindBegin(), e = God->pool().byKindEnd(); for (; it != e; ++it ) { Resolvable::constPtr res = it->resolvable(); + if ( it->status().isUndetermined() ) { +#warning is this a library bug? + // these are duplicates of those that are determined + continue; + } Patch::constPtr patch = asKind(res); - if ( it->status().isNeeded() ) - { - gData.patches_count++; - if (patch->category() == "security") - gData.security_patches_count++; - - TableRow tr; - tr << patch->name() << patch->edition().asString() << patch->category(); - tbl << tr; - } + TableRow tr; + tr << patch->source ().alias (); + tr << res->name () << res->edition ().asString(); + tr << patch->category(); + tr << string_status (it->status ()); + tbl << tr; } cout << tbl; - - cout << gData.patches_count << " patches needed. ( " << gData.security_patches_count << " security patches )" << std::endl; } void usage(int argc, char **argv) diff --git a/tools/zmart/zypper.cc b/tools/zmart/zypper.cc index 27d7a16..e0b27ec 100644 --- a/tools/zmart/zypper.cc +++ b/tools/zmart/zypper.cc @@ -233,7 +233,8 @@ int main(int argc, char **argv) "\tservice-add, sa\t\tAdd a new service\n" "\tservice-delete, sd\tDelete a service\n" "\tservice-rename, sr\tRename a service\n" - "\tpatch-check,pchk\tCheck for patches\n" + "\tpatch-check, pchk\tCheck for patches\n" + "\tpatches, pch\t\tList patches\n" ; string help_global_source_options = " Source options:\n" @@ -576,6 +577,13 @@ int main(int argc, char **argv) } if (command == "patch-check" || command == "pchk") { + if (help) { + cerr << "patch-check\n" + << specific_help + ; + return !help; + } + cond_init_target (); cond_init_system_sources (); // TODO additional_sources @@ -595,5 +603,21 @@ int main(int argc, char **argv) return 0; } + if (command == "patches" || command == "pch") { + if (help) { + cerr << "patches\n" + << specific_help + ; + return !help; + } + + cond_init_target (); + cond_init_system_sources (); + cond_load_resolvables (); + establish (); + show_pool (); + return 0; + } + return 0; }