From e1d84a53889713171fc610acd14926dba5431693 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Tue, 31 Oct 2006 16:30:50 +0000 Subject: [PATCH] patch-info implemented --- src/zypper-info.cc | 51 +++++++++++++++++++++++++++++++++++++++++++-------- src/zypper-info.h | 2 +- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/zypper-info.cc b/src/zypper-info.cc index 4a51667..75bc91d 100644 --- a/src/zypper-info.cc +++ b/src/zypper-info.cc @@ -4,13 +4,16 @@ #include #include +#include +#include "zmart.h" #include "zmart-misc.h" using namespace std; using namespace zypp; extern ZYpp::Ptr God; +extern Settings gSettings; /** * @@ -18,7 +21,7 @@ extern ZYpp::Ptr God; void printInfo(const string & command, const vector & arguments) { Resolvable::Kind kind; if (command == "info" || command == "if") kind = ResTraits::kind; - else if (command == "patch-info") kind = ResTraits::kind; + else if (command == "patch-info") kind = ResTraits::kind; ResPool pool = God->pool(); @@ -31,7 +34,7 @@ void printInfo(const string & command, const vector & arguments) { PoolItem installed; for(ResPool::byName_iterator it = pool.byNameBegin(*nameit); it != pool.byNameEnd(*nameit); ++it) { - if (it->status().isInstalled()) installed = *it; + if (it->status().isInstalled()) { installed = *it; break; } } // find installation candidate @@ -50,8 +53,8 @@ void printInfo(const string & command, const vector & arguments) { if (command == "info" || command == "if") printPkgInfo(installer.item,installed); -// else if (command == "patch-info") -// pritPatchInfo(installer.item,installed); + else if (command == "patch-info") + printPatchInfo(installer.item,installed); } } } @@ -114,7 +117,7 @@ Status: Satisfied Category: recommended Created On: 5/31/2006 2:34:37 AM Reboot Required: No -Restart Required: No +Package Manager Restart Required: No Interactive: No Summary: XV can not grab in KDE Description: XV can not grab in KDE @@ -130,10 +133,42 @@ void printPatchInfo(const PoolItem & pool_item, const PoolItem & ins_pool_item) cout << "Name: " << pool_item.resolvable()->name() << endl; cout << "Version: " << pool_item.resolvable()->edition().asString() << endl; cout << "Arch: " << pool_item.resolvable()->arch().asString() << endl; - cout << "Status: TODO" << endl; - cout << "Installed Size: " << pool_item.resolvable()->size().asString() << endl; + + cout << "Status: "; // TODO debug + bool i = ins_pool_item ? true : false; + if (pool_item.status().isUndetermined ()) + cout << (i ? "Installed": "Uninstalled"); + else if (pool_item.status().isEstablishedUneeded ()) + cout << (i ? "No Longer Applicable": "Not Applicable"); + else if (pool_item.status().isEstablishedSatisfied ()) + cout << (i ? "Applied": "Not Needed"); + else if (pool_item.status().isEstablishedIncomplete ()) + cout << (i ? "Broken": "Needed"); + cout << endl; + + Patch::constPtr patch = asKind(pool_item.resolvable()); + cout << "Category: " << patch->category() << endl; + cout << "Created On: " << patch->timestamp().asString() << endl; + cout << "Reboot Required: " << (patch->reboot_needed() ? "Yes" : "No") << endl; + + if (!gSettings.is_rug_compatible) + cout << "Package Manager "; + cout << "Restart Required: "; + cout << (patch->affects_pkg_manager() ? "Yes" : "No") << endl; + + cout << "Interactive: " << (patch->interactive() ? "Yes" : "No") << endl; cout << "Summary: " << pool_item.resolvable()->summary() << endl; cout << "Description: " << pool_item.resolvable()->description() << endl; - // TODO + cout << "Provides:" << endl; + CapSet capSet = pool_item.resolvable()->dep(zypp::Dep::PROVIDES); + for (CapSet::const_iterator it = capSet.begin(); it != capSet.end(); ++it) { + cout << it->refers().asString() << ": " << it->asString() << endl; + } + + cout << endl << "Requires:" << endl; + capSet = pool_item.resolvable()->dep(zypp::Dep::REQUIRES); + for (CapSet::const_iterator it = capSet.begin(); it != capSet.end(); ++it) { + cout << it->refers().asString() << ": " << it->asString() << endl; + } } diff --git a/src/zypper-info.h b/src/zypper-info.h index c59f8a0..127f0a0 100644 --- a/src/zypper-info.h +++ b/src/zypper-info.h @@ -8,5 +8,5 @@ void printInfo(const std::string & command, const std::vector & arguments); void printPkgInfo(const zypp::PoolItem & pool_item, const zypp::PoolItem & ins_pool_item); - +void printPatchInfo(const zypp::PoolItem & pool_item, const zypp::PoolItem & ins_pool_item); #endif /*ZYPPERINFO_H_*/ -- 2.7.4