Author: jkupec
Date: Mon Apr 14 19:34:16 2008
New Revision: 9620
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9620&view=rev
Log:
- pattern content with Dependency (Recommended/Suggested) column added
for pattern-info (fate #301930)
Modified:
trunk/zypper/src/zypper-info.cc
trunk/zypper/src/zypper-info.h
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-utils.cc
trunk/zypper/src/zypper-utils.h
Modified: trunk/zypper/src/zypper-info.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-info.cc?rev=9620&r1=9619&r2=9620&view=diff
==============================================================================
--- trunk/zypper/src/zypper-info.cc (original)
+++ trunk/zypper/src/zypper-info.cc Mon Apr 14 19:34:16 2008
@@ -5,11 +5,14 @@
#include "zypp/ZYpp.h"
#include "zypp/base/Algorithm.h"
#include "zypp/Patch.h"
+#include "zypp/Pattern.h"
#include "zypp/Product.h"
+#include "zypp/PoolQuery.h"
#include "zypper.h"
#include "zypper-main.h"
#include "zypper-misc.h"
+#include "zypper-tabulator.h"
#include "zypper-info.h"
using namespace std;
@@ -37,7 +40,7 @@
/**
*
*/
-void printInfo(const Zypper & zypper, const Resolvable::Kind & kind)
+void printInfo(const Zypper & zypper, const ResKind & kind)
{
ResPool pool = God->pool();
@@ -47,27 +50,37 @@
nameit != zypper.arguments().end(); ++nameit )
{
- // find the resolvable among installed
+ // find the resolvable among installed
+ /*
PoolItem installed;
for_( it, pool.byIdentBegin( kind, *nameit ),
pool.byIdentEnd( kind, *nameit ) )
{
if (it->status().isInstalled()) { installed = *it; break; }
}
-
+*/
// find installation candidate
- ProvideProcess installer (ZConfig::instance().systemArchitecture(), "" /*version*/);
+// ProvideProcess installer (ZConfig::instance().systemArchitecture(), "" /*version*/);
+ PoolQuery q;
+ q.addKind(kind);
+ q.addAttribute(sat::SolvAttr::name, *nameit);
+ /*
invokeOnEach( pool.byIdentBegin( kind, *nameit ),
pool.byIdentEnd( kind, *nameit ),
zypp::functor::functorRef (installer) );
-
- if (!installer.item) {
- // TranslatorExplanation E.g. "package zypper not found."
- cout << "\n" << format(_("%s %s not found."))
+*/
+
+ //if (!installer.item) {
+ if (q.empty())
+ {
+ // TranslatorExplanation E.g. "package 'zypper' not found."
+ cout << "\n" << format(_("%s '%s' not found."))
% kind_to_string_localized(kind, 1) % *nameit
<< endl;
}
- else {
+ else
+ {
+ ui::Selectable::constPtr s = *q.selectableBegin();
// print info
// TranslatorExplanation E.g. "Information for package zypper:"
cout << endl << format(_("Information for %s %s:"))
@@ -76,13 +89,13 @@
cout << endl << endl;
if (kind == ResTraits<Package>::kind)
- printPkgInfo(zypper, installer.item, installed);
+ printPkgInfo(zypper, *s);
else if (kind == ResTraits<Patch>::kind)
- printPatchInfo(zypper, installer.item, installed);
+ printPatchInfo(zypper, *s);
else if (kind == ResTraits<Pattern>::kind)
- printPatternInfo(zypper, installer.item, installed);
+ printPatternInfo(zypper, *s);
else if (kind == ResTraits<Product>::kind)
- printProductInfo(zypper, installer.item, installed);
+ printProductInfo(zypper, *s);
else
// TranslatorExplanation %s = resolvable type (package, patch, pattern, etc - untranslated).
cout << format(_("Info for type '%s' not implemented.")) % kind << endl;
@@ -110,30 +123,35 @@
</pre>
*
*/
-void printPkgInfo(const Zypper & zypper,
- const PoolItem & pool_item, const PoolItem & ins_pool_item)
+void printPkgInfo(const Zypper & zypper, const ui::Selectable & s)
{
+ PoolItem theone = s.theObj();
+ PoolItem installed = s.installedObj();
cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
- << pool_item.resolvable()->repository().info().name() << endl;
+ << theone.resolvable()->repository().info().name() << endl;
- printNVA(pool_item.resolvable());
+ printNVA(installed ? installed.resolvable() : theone.resolvable());
- cout << _("Installed: ") << (!ins_pool_item ? "No" : "Yes") << endl;
+ cout << _("Installed: ") << (installed ? _("Yes") : _("No")) << endl;
+ //! \todo fix this - arch?
cout << _("Status: ");
- if (ins_pool_item &&
- ins_pool_item.resolvable()->edition() >= pool_item.resolvable()->edition())
+ if (installed &&
+ installed.resolvable()->edition() >= theone.resolvable()->edition())
+ {
cout << _("up-to-date") << endl;
- else if (ins_pool_item) {
- cout << _("out-of-date (version ") << ins_pool_item.resolvable()->edition()
+ }
+ else if (installed)
+ {
+ cout << _("out-of-date (version ") << installed.resolvable()->edition()
<< _(" installed) ") << endl; // TODO use sformat for this for proper translation
}
else
cout << _("not installed") << endl;
- cout << _("Installed Size: ") << pool_item.resolvable()->installsize() << endl;
+ cout << _("Installed Size: ") << theone.resolvable()->installsize() << endl;
- printSummaryDesc(pool_item.resolvable());
+ printSummaryDesc(theone.resolvable());
}
/**
@@ -160,11 +178,14 @@
</pre>
*
*/
-void printPatchInfo(const Zypper & zypper, const PoolItem & pool_item, const PoolItem & ins_pool_item) {
+void printPatchInfo(const Zypper & zypper, const ui::Selectable & s )
+{
+ const PoolItem & pool_item = s.theObj();
+ const PoolItem & ins_pool_item = s.installedObj();
printNVA(pool_item.resolvable());
cout << _("Status: "); // TODO debug
- bool i = ins_pool_item ? true : false;
+ bool i = bool(ins_pool_item);
if (pool_item.isBroken ())
cout << (i ? _("broken"): _("satisfied"));
cout << endl;
@@ -199,6 +220,15 @@
}
}
+static string string_weak_status(const ResStatus & rs)
+{
+ if (rs.isRecommended())
+ return _("Recommended");
+ if (rs.isSuggested())
+ return _("Suggested");
+ return "";
+}
+
/**
* Print pattern information.
* <p>
@@ -217,9 +247,11 @@
</pre>
*
*/
-void printPatternInfo(const Zypper & zypper,
- const PoolItem & pool_item, const PoolItem & ins_pool_item)
+void printPatternInfo(const Zypper & zypper, const ui::Selectable & s)
{
+ const PoolItem & pool_item = s.theObj();
+ const PoolItem & ins_pool_item = s.installedObj();
+
cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
<< pool_item.resolvable()->repository().info().name() << endl;
@@ -228,6 +260,36 @@
cout << _("Installed: ") << (!ins_pool_item ? "No" : "Yes") << endl;
printSummaryDesc(pool_item.resolvable());
+
+ if (zypper.globalOpts().is_rug_compatible)
+ return;
+
+ // show contents
+ Table t;
+ TableHeader th;
+ th << _("S") << _("Name") << _("Type") << _("Dependency");
+ t << th;
+
+ //God->resolver()->solve();
+
+ Pattern::constPtr pattern = asKind<Pattern>(pool_item.resolvable());
+ Pattern::Contents contents = pattern->contents();
+ for_(sit, contents.selectableBegin(), contents.selectableEnd())
+ {
+ const ui::Selectable & s = **sit;
+ TableRow tr;
+
+ tr << (s.installedEmpty() ? "" : "i");
+ tr << s.name() << s.kind().asString() << string_weak_status(s.theObj().status());
+
+ t << tr;
+ }
+
+ cout << _("Contents") << ":";
+ if (t.empty())
+ cout << " " << _("(empty)") << endl;
+ else
+ cout << endl << endl << t;
}
/**
@@ -248,9 +310,11 @@
</pre>
*
*/
-void printProductInfo(const Zypper & zypper,
- const PoolItem & pool_item, const PoolItem & ins_pool_item)
+void printProductInfo(const Zypper & zypper, const ui::Selectable & s)
{
+ const PoolItem & pool_item = s.theObj();
+ const PoolItem & ins_pool_item = s.installedObj();
+
cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
<< pool_item.resolvable()->repository().info().name() << endl;
Modified: trunk/zypper/src/zypper-info.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-info.h?rev=9620&r1=9619&r2=9620&view=diff
==============================================================================
--- trunk/zypper/src/zypper-info.h (original)
+++ trunk/zypper/src/zypper-info.h Mon Apr 14 19:34:16 2008
@@ -2,26 +2,19 @@
#define ZYPPERINFO_H_
#include "zypp/PoolItem.h"
-#include "zypp/Resolvable.h"
+#include "zypp/ResKind.h"
+#include "zypp/ui/Selectable.h"
#include "zypper.h"
-void printInfo(const Zypper & zypper, const zypp::Resolvable::Kind & kind);
+void printInfo(const Zypper & zypper, const zypp::ResKind & kind);
-void printPkgInfo(const Zypper & zypper,
- const zypp::PoolItem & pool_item,
- const zypp::PoolItem & ins_pool_item);
-
-void printPatchInfo(const Zypper & zypper,
- const zypp::PoolItem & pool_item,
- const zypp::PoolItem & ins_pool_item);
-
-void printPatternInfo(const Zypper & zypper,
- const zypp::PoolItem & pool_item,
- const zypp::PoolItem & ins_pool_item);
-
-void printProductInfo(const Zypper & zypper,
- const zypp::PoolItem & pool_item,
- const zypp::PoolItem & ins_pool_item);
+void printPkgInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+
+void printPatchInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+
+void printPatternInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
+
+void printProductInfo(const Zypper & zypper, const zypp::ui::Selectable & s);
#endif /*ZYPPERINFO_H_*/
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=9620&r1=9619&r2=9620&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Mon Apr 14 19:34:16 2008
@@ -48,20 +48,6 @@
*/
static bool confirm_licenses(Zypper & zypper);
-static bool
-equalNVRA(const Resolvable & lhs, const Resolvable & rhs)
-{
- if (lhs.name() != rhs.name())
- return false;
- if (lhs.kind() != rhs.kind())
- return false;
- if (lhs.edition() != rhs.edition())
- return false;
- if (lhs.arch() != rhs.arch())
- return false;
- return true;
-}
-
// converts a user-supplied kind to a zypp kind object
// returns an empty one if not recognized
ResObject::Kind string_to_kind (const string &skind)
Modified: trunk/zypper/src/zypper-utils.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-utils.cc?rev=9620&r1=9619&r2=9620&view=diff
==============================================================================
--- trunk/zypper/src/zypper-utils.cc (original)
+++ trunk/zypper/src/zypper-utils.cc Mon Apr 14 19:34:16 2008
@@ -137,6 +137,21 @@
// ----------------------------------------------------------------------------
+bool equalNVRA(const Resolvable & lhs, const Resolvable & rhs)
+{
+ if (lhs.name() != rhs.name())
+ return false;
+ if (lhs.kind() != rhs.kind())
+ return false;
+ if (lhs.edition() != rhs.edition())
+ return false;
+ if (lhs.arch() != rhs.arch())
+ return false;
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
bool looks_like_url (const string& s)
{
/*
Modified: trunk/zypper/src/zypper-utils.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-utils.h?rev=9620&r1=9619&r2=9620&view=diff
==============================================================================
--- trunk/zypper/src/zypper-utils.h (original)
+++ trunk/zypper/src/zypper-utils.h Mon Apr 14 19:34:16 2008
@@ -31,6 +31,8 @@
std::string kind_to_string_localized(
const zypp::Resolvable::Kind & kind, unsigned long count);
+bool equalNVRA(const zypp::Resolvable & lhs, const zypp::Resolvable & rhs);
+
/**
* Creates a Url out of \a urls_s. If the url_s looks looks_like_url()
* Url(url_s) is returned. Otherwise if \a url_s represends a valid path to
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org