From: Martin Vidner Date: Fri, 27 Jul 2007 17:21:51 +0000 (+0000) Subject: - Implemented capabilities for installing and removing, allowing to X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~243 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21667542aa67c348340644a08d51a09746e1f3da;p=platform%2Fupstream%2Fzypper.git - 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. --- diff --git a/doc/zypper.8 b/doc/zypper.8 index 40b97ca..ab5605e 100644 --- a/doc/zypper.8 +++ b/doc/zypper.8 @@ -49,8 +49,16 @@ A resolvable is a package, patch, pattern, language, or a product. Displays full info for the specified packages. .TP -.B install (in) ... +.B install (in) ... 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 Only from this catalog (FIXME not implemented yet) @@ -58,6 +66,9 @@ Only from this catalog (FIXME not implemented yet) \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 @@ See also the NOTE at .BR update . .TP -.B remove (rm) ... +.B remove (rm) ... 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. diff --git a/package/zypper.changes b/package/zypper.changes index 2716458..0b24b3a 100644 --- a/package/zypper.changes +++ b/package/zypper.changes @@ -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) diff --git a/src/zypper-misc.cc b/src/zypper-misc.cc index 40c5d26..c38029b 100644 --- a/src/zypper-misc.cc +++ b/src/zypper-misc.cc @@ -128,6 +128,18 @@ static std::string xml_escape( const std::string &text ) } +// 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 @@ static std::string xml_escape( const std::string &text ) 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_for_uninstall( const ResObject::Kind &kind, } } +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) diff --git a/src/zypper-misc.h b/src/zypper-misc.h index fd15c15..dbc6156 100644 --- a/src/zypper-misc.h +++ b/src/zypper-misc.h @@ -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(); diff --git a/src/zypper.cc b/src/zypper.cc index 3bd50cb..2b8a331 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -264,6 +264,7 @@ int one_command(const ZypperCommand & command, int argc, char **argv) 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 @@ int one_command(const ZypperCommand & command, int argc, char **argv) " 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 @@ int one_command(const ZypperCommand & command, int argc, char **argv) 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 @@ int one_command(const ZypperCommand & command, int argc, char **argv) "\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 @@ int one_command(const ZypperCommand & command, int argc, char **argv) cond_init_target (); cond_load_resolvables(); + bool install_not_remove = command == ZypperCommand::INSTALL; + bool just_name = copts.count("name"); // compatibility method for ( vector::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; } diff --git a/zypper.spec.cmake b/zypper.spec.cmake index 13b1b45..f425a0c 100644 --- a/zypper.spec.cmake +++ b/zypper.spec.cmake @@ -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