Author: mvidner
Date: Fri Jul 27 19:21:51 2007
New Revision: 6273
URL: http://svn.opensuse.org/viewcvs/zypp?rev=6273&view=rev
Log:
- Implemented capabilities for installing and removing, allowing to
install by provided tags and files (F#301956) or a specific
version (F#302186): zypper in 'clamav = 0.90-0.1'; zypper rm
/bin/vi; zypper in libcurl.so.3; zypper in 'perl(Time::ParseDate)'
- Added --name,-n to install and remove to use the old selection
method in case the new one does not work.
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/package/zypper.changes
trunk/zypper/src/zypper-misc.cc
trunk/zypper/src/zypper-misc.h
trunk/zypper/src/zypper.cc
trunk/zypper/zypper.spec.cmake
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Fri Jul 27 19:21:51 2007
@@ -49,8 +49,16 @@
Displays full info for the specified packages.
.TP
-.B install (in) <name> ...
+.B install (in) <capability> ...
Install resolvables.
+
+Capability is: NAME, or "NAME OP EDITION", where OP is < <= = >= > and
+EDITION is VERSION[-RELEASE].
+
+Names are not only package names but any symbols provided by packages:
+/bin/vi, libcurl.so.3, perl(Time::ParseDate). Just remember to quote to protect the
+special characters from the shell.
+
.TP
\fI\-c, \-\-catalog\fR <catalog>
Only from this catalog (FIXME not implemented yet)
@@ -58,6 +66,9 @@
\fI\-t, \-\-type\fR
Type of resolvable (default: package)
.TP
+.I \-n, \-\-name
+Select resolvables by older method, considering just names, not capabilities.
+.TP
.I \-y, \-\-no\-confirm
Don't require user confirmation to proceed with installation.
.TP
@@ -78,15 +89,21 @@
.BR update .
.TP
-.B remove (rm) <name> ...
+.B remove (rm) <capability> ...
Remove resolvables.
.TP
\fI\-t, -\-type\fR
Type of resolvable (default: package)
.TP
+.I \-n, \-\-name
+Select resolvables by older method, considering just names, not capabilities.
+.TP
.I \-y, \-\-no-confirm
Don't require user confirmation.
+Capability is usually a plain name, for details see the install
+command.
+
.TP
.B update (up) [options]
Update all installed resolvables with newer versions, where applicable.
Modified: trunk/zypper/package/zypper.changes
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/package/zypper.changes?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/package/zypper.changes (original)
+++ trunk/zypper/package/zypper.changes Fri Jul 27 19:21:51 2007
@@ -1,4 +1,14 @@
-------------------------------------------------------------------
+Fri Jul 27 19:06:58 CEST 2007 - mvidner@suse.cz
+
+- Implemented capabilities for installing and removing, allowing to
+ install by provided tags and files (F#301956) or a specific
+ version (F#302186): zypper in 'clamav = 0.90-0.1'; zypper rm
+ /bin/vi; zypper in libcurl.so.3; zypper in 'perl(Time::ParseDate)'
+- Added --name,-n to install and remove to use the old selection
+ method in case the new one does not work.
+
+-------------------------------------------------------------------
Thu Jul 26 17:19:59 CEST 2007 - jkupec@suse.cz
- output clean-up (#216042)
Modified: trunk/zypper/src/zypper-misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.cc (original)
+++ trunk/zypper/src/zypper-misc.cc Fri Jul 27 19:21:51 2007
@@ -128,6 +128,18 @@
}
+// on error print a message and return noCap
+Capability safe_parse_cap (const ResObject::Kind &kind, const string & capstr) {
+ Capability cap;
+ try {
+ cap = CapFactory().parse (kind, capstr);
+ }
+ catch (const Exception& e) {
+ ZYPP_CAUGHT(e);
+ cerr << format (_("Cannot parse capability '%s'.")) % capstr << endl;
+ }
+ return cap;
+}
// this does only resolvables with this _name_.
// we could also act on _provides_
@@ -135,27 +147,6 @@
void mark_for_install( const ResObject::Kind &kind,
const std::string &name )
{
- if (name.find_first_of ("=<>") != string::npos) {
- // use resolver. (or use it always?)
- // Resolver.h
- Capability cap;
- try {
- cap = CapFactory().parse (kind, name);
- }
- catch (const Exception& e) {
- ZYPP_CAUGHT(e);
- cerr << "Cannot parse requirement: '" << name << "'" << endl;
- }
-
- if (cap != Capability::noCap) {
- Resolver_Ptr resolver = zypp::getZYpp()->resolver();
- cerr_vv << "Adding requirement " << cap << endl;
- resolver->addRequire (cap);
- }
-
- return;
- }
-
const ResPool &pool = God->pool();
// name and kind match:
@@ -235,6 +226,50 @@
}
}
+void mark_by_name (bool install_not_delete,
+ const ResObject::Kind &kind,
+ const string &name )
+{
+ if (install_not_delete)
+ mark_for_install(kind, name);
+ else
+ mark_for_uninstall(kind, name);
+}
+
+// don't try NAME-EDITION yet, could be confused by
+// dbus-1-x11, java-1_4_2-gcj-compat, ...
+/*
+bool mark_by_name_edition (...)
+ static const regex rx_name_edition("(.*?)-([0-9].*)");
+
+ smatch m;
+ if (! is_cap && regex_match (capstr, m, rx_name_edition)) {
+ capstr = m.str(1) + " = " + m.str(2);
+ is_cap = true;
+ }
+
+*/
+
+void mark_by_capability (bool install_not_delete,
+ const ResObject::Kind &kind,
+ const string &capstr )
+{
+ Capability cap = safe_parse_cap (kind, capstr);
+
+ if (cap != Capability::noCap) {
+ Resolver_Ptr resolver = zypp::getZYpp()->resolver();
+ if (install_not_delete) {
+ cerr_vv << "Adding requirement " << cap << endl;
+ resolver->addRequire (cap);
+ }
+ else {
+ cerr_vv << "Adding conflict " << cap << endl;
+ resolver->addConflict (cap);
+ }
+ }
+}
+
+
// debugging
static
ostream& operator << (ostream & stm, ios::iostate state)
Modified: trunk/zypper/src/zypper-misc.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/src/zypper-misc.h (original)
+++ trunk/zypper/src/zypper-misc.h Fri Jul 27 19:21:51 2007
@@ -21,11 +21,23 @@
*/
void cond_init_target();
+/// Parse a capability string. On error print a message and return noCap
+zypp::Capability safe_parse_cap (const zypp::ResObject::Kind &kind,
+ const std::string &capstr);
+
zypp::ResObject::Kind string_to_kind (const std::string &skind);
void mark_for_install( const zypp::ResObject::Kind &kind,
const std::string &name );
void mark_for_uninstall( const zypp::ResObject::Kind &kind,
const std::string &name );
+
+void mark_by_name (bool install_not_delete,
+ const zypp::ResObject::Kind &kind,
+ const std::string &name );
+void mark_by_capability (bool install_not_delete,
+ const zypp::ResObject::Kind &kind,
+ const std::string &capstr );
+
int show_summary();
//std::string calculate_token();
Modified: trunk/zypper/src/zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/src/zypper.cc (original)
+++ trunk/zypper/src/zypper.cc Fri Jul 27 19:21:51 2007
@@ -264,6 +264,7 @@
static struct option install_options[] = {
{"catalog", required_argument, 0, 'c'},
{"type", required_argument, 0, 't'},
+ {"name", no_argument, 0, 'n'},
{"no-confirm", no_argument, 0, 'y'},
{"auto-agree-with-licenses", no_argument, 0, 'l'},
{"help", no_argument, 0, 'h'},
@@ -278,6 +279,7 @@
" Command options:\n"
"\t--catalog,-c\t\t\tOnly from this catalog (under development)\n"
"\t--type,-t \tType of resolvable (package, patch, pattern, product) (default: package)\n"
+ "\t--name,-n\t\t\tSelect resolvables by plain name, not by capability\n"
"\t--no-confirm,-y\t\t\tDo not require user confirmation to proceed with installation\n"
"\t--auto-agree-with-licenses,-l\tAutomatically say 'yes' to third party license confirmation prompt.\n"
"\t\t\t\t\tSee man zypper for more details.\n"
@@ -286,6 +288,7 @@
else if (command == ZypperCommand::REMOVE) {
static struct option remove_options[] = {
{"type", required_argument, 0, 't'},
+ {"name", no_argument, 0, 'n'},
{"no-confirm", no_argument, 0, 'y'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
@@ -298,6 +301,7 @@
"\n"
" Command options:\n"
"\t--type,-t \tType of resolvable (package, patch, pattern, product) (default: package)\n"
+ "\t--name,-n\t\t\tSelect resolvables by plain name, not by capability\n"
"\t--no-confirm,-y\t\t\tDo not require user confirmation\n"
);
}
@@ -963,16 +967,16 @@
cond_init_target ();
cond_load_resolvables();
+ bool install_not_remove = command == ZypperCommand::INSTALL;
+ bool just_name = copts.count("name"); // compatibility method
for ( vector<string>::const_iterator it = arguments.begin(); it != arguments.end(); ++it ) {
- if (command == ZypperCommand::INSTALL) {
- mark_for_install(kind, *it);
- }
- else {
- mark_for_uninstall(kind, *it);
- }
+ if (just_name)
+ mark_by_name (install_not_remove, kind, *it);
+ else
+ mark_by_capability (install_not_remove, kind, *it);
}
- solve_and_commit (copts.count("no-confirm") || gSettings.non_interactive);
+ solve_and_commit (copts.count("no-confirm") || gSettings.non_interactive, !just_name);
return ZYPPER_EXIT_OK;
}
Modified: trunk/zypper/zypper.spec.cmake
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/zypper.spec.cmake?rev=6273&r1=6272&r2=6273&view=diff
==============================================================================
--- trunk/zypper/zypper.spec.cmake (original)
+++ trunk/zypper/zypper.spec.cmake Fri Jul 27 19:21:51 2007
@@ -11,7 +11,7 @@
# norootforbuild
Name: @PACKAGE@
-BuildRequires: libzypp-devel >= 3.11.9 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1
+BuildRequires: libzypp-devel >= 3.12.0 boost-devel >= 1.33.1 gettext-devel >= 0.15 readline-devel >= 5.1
BuildRequires: gcc-c++ >= 4.2 cmake >= 2.4.6 pkg-config >= 0.20
Requires: procps
License: GPL
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org