ref: refs/heads/master
commit d80e5b1bb53f8bbe13aba6b6d87ffead8de423b5
Author: Marcus Hüwe
Date: Wed Mar 11 16:50:14 2009 +0100
--requires and --recommends added to info command
---
doc/zypper.8 | 12 ++++++++++--
src/Zypper.cc | 18 +++++++++++++++++-
src/info.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 76 insertions(+), 10 deletions(-)
diff --git a/doc/zypper.8 b/doc/zypper.8
index 90691ea..6b5f9ed 100644
--- a/doc/zypper.8
+++ b/doc/zypper.8
@@ -1,4 +1,4 @@
-.TH "zypper" "8" "1.1.0" "zypper" "System Tools"
+.TH "zypper" "8" "1.1.1" "zypper" "System Tools"
.SH "SYNTAX"
.LP
zypper [\fI\-\-global\-opts\fR] <\fBcommand\fR> [\fI\-\-command\-opts\fR] [\fBcommand-arguments\fR]
@@ -152,7 +152,7 @@ since libzypp became so fast thanks to the SAT solver and its tools
.SS Package Management Commands
.TP
-.B info (if) <name> ...
+.B info (if) [options] <name> ...
Displays detailed informaion about the specified packages.
For each specified package, zypper finds the best available version in defined
@@ -167,6 +167,14 @@ option can be used multiple times.
Type of package (default: package). See section \fBPackage Types\fR for list
of available package types.
.TP
+.I \ \ \ \ \-\-requires
+Show also symbols required and pre-required by the package. Available for package and patch type
+only.
+.TP
+.I \ \ \ \ \-\-recommends
+Show also symbols recommended by the package. Available for package and patch
+type only.
+.TP
Examples:
Show information about package 'workrave':
diff --git a/src/Zypper.cc b/src/Zypper.cc
index 8d802e5..91b9c07 100644
--- a/src/Zypper.cc
+++ b/src/Zypper.cc
@@ -1773,6 +1773,8 @@ void Zypper::processCommandOptions()
{"repo", required_argument, 0, 'r'},
// rug compatibility option, we have --repo
{"catalog", required_argument, 0, 'c'},
+ {"requires", no_argument, 0, 0},
+ {"recommends", no_argument, 0, 0},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -1785,7 +1787,9 @@ void Zypper::processCommandOptions()
" Command options:\n"
"-r, --repo Work only with the specified repository.\n"
"-t, --type <type> Type of package (%s).\n"
- " Default: %s."
+ " Default: %s.\n"
+ " --requires Show also requires and prerequires.\n"
+ " --recommends Show also recommends."
), "package, patch, pattern, product", "package");
break;
@@ -3716,6 +3720,18 @@ void Zypper::doCommand()
}
}
+ // XXX: would requires/recommends make sense for pattern etc.?
+ if (copts.count("requires") || copts.count("recommends"))
+ {
+ if (kind != ResKind::package && kind != ResKind::patch)
+ {
+ out().error(boost::str(format(
+ _("Type '%s' does not support %s.")) % kind % "--requires/--recommends"));
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+ }
+
initRepoManager();
init_target(*this);
init_repos(*this);
diff --git a/src/info.cc b/src/info.cc
index a6a3e8c..a3bccb6 100644
--- a/src/info.cc
+++ b/src/info.cc
@@ -128,6 +128,26 @@ void printInfo(Zypper & zypper, const ResKind & kind)
}
}
+static void printRequires(const PoolItem & pi)
+{
+ cout << _("Requires:") << endl;
+ std::list<Capability> capList = std::list<Capability>(pi->prerequires().begin(), pi->prerequires().end());
+ capList.assign(pi->requires().begin(), pi->requires().end());
+ for (std::list<Capability>::const_iterator it = capList.begin(); it != capList.end(); ++it)
+ {
+ cout << *it << endl;
+ }
+}
+
+static void printRecommends(const PoolItem & pi)
+{
+ cout << _("Recommends:") << endl;
+ Capabilities capSet = pi->recommends();
+ for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
+ {
+ cout << *it << endl;
+ }
+}
/**
* Print package information.
@@ -184,6 +204,20 @@ void printPkgInfo(Zypper & zypper, const ui::Selectable & s)
cout << _("Installed Size: ") << theone.resolvable()->installSize() << endl;
printSummaryDesc(theone.resolvable());
+
+ bool requires = zypper.cOpts().count("requires");
+ bool recommends = zypper.cOpts().count("recommends");
+
+ if (requires)
+ printRequires(theone);
+
+ if (recommends)
+ {
+ if (requires)
+ cout << endl; // visual separator
+
+ printRecommends(theone);
+ }
}
/**
@@ -236,16 +270,24 @@ void printPatchInfo(Zypper & zypper, const ui::Selectable & s )
Capabilities capSet = pool_item.resolvable()->dep(zypp::Dep::PROVIDES);
// WhatProvides can be used here. The result can be represented as a table of
// a "Capability" (it->asString()) | "Provided By" (WhatProvides(c))
- for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it) {
- // FIXME cout << it->refers().asString() << ": " << it->asString() << endl;
+ for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
cout << *it << endl;
- }
- cout << endl << _("Requires:") << endl;
- capSet = pool_item.resolvable()->dep(zypp::Dep::REQUIRES);
- for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it) {
- // FIXME cout << it->refers().asString() << ": " << it->asString() << endl;
+ cout << endl << _("Conflicts:") << endl;
+ capSet = pool_item.resolvable()->dep(zypp::Dep::CONFLICTS);
+ for (Capabilities::const_iterator it = capSet.begin(); it != capSet.end(); ++it)
cout << *it << endl;
+
+ if (zypper.cOpts().count("requires"))
+ {
+ cout << endl; // visual separator
+ printRequires(pool_item);
+ }
+
+ if (zypper.cOpts().count("recommends"))
+ {
+ cout << endl; // visual separator
+ printRecommends(pool_item);
}
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org