Author: jkupec Date: Sun Apr 13 17:50:48 2008 New Revision: 9590 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9590&view=rev Log: - allow update of individual packages + support wildcards (bnc #345458, bnc #284725, and abuse of fate #302511 :O) - 'update foo' treat command arguments as repos in rug-compatible mode (fate #302148) - 'update': dummy --download-only and --category options for now (fate #302148) - switch to Resolver::doUpdate for 'zypper update -t not-patch' Modified: trunk/zypper/src/zypper-misc.cc trunk/zypper/src/zypper-misc.h trunk/zypper/src/zypper.cc Modified: trunk/zypper/src/zypper-misc.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=9590&r1=9589&r2=9590&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.cc (original) +++ trunk/zypper/src/zypper-misc.cc Sun Apr 13 17:50:48 2008 @@ -351,7 +351,7 @@ } -void +static void mark_by_name (Zypper & zypper, bool install_not_remove, const ResObject::Kind &kind, @@ -1764,6 +1764,7 @@ static void mark_patch_updates( bool skip_interactive ) { + DBG << "going to mark patches to install" << endl; // search twice: if there are none with affects_pkg_manager, retry on all bool nothing_found = true; for (int attempt = 0; nothing_found && attempt < 2; ++attempt) @@ -1797,24 +1798,87 @@ } } +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; +} + // ---------------------------------------------------------------------------- -//! \todo mechanism for updating the update stack before the rest. -void mark_updates(const ResKindSet & kinds, bool skip_interactive, bool best_effort ) +void mark_updates(Zypper & zypper, const ResKindSet & kinds, bool skip_interactive, bool best_effort ) { -// unsigned kind_size = kinds.size(); ResKindSet localkinds = kinds; + ResKindSet::iterator it; - it = localkinds.find(ResTraits<Patch>::kind); + it = localkinds.find(ResKind::patch); if(it != localkinds.end()) // patches wanted mark_patch_updates(skip_interactive); - Candidates candidates; - find_updates (localkinds, candidates); - if (best_effort) - invokeOnEach (candidates.begin(), candidates.end(), require_item_update); - else - invokeOnEach (candidates.begin(), candidates.end(), mark_item_install); + if (zypper.arguments().empty() || zypper.globalOpts().is_rug_compatible) + { + God->resolver()->doUpdate(); + + /* + Candidates candidates; + find_updates (localkinds, candidates); + if (best_effort) + invokeOnEach (candidates.begin(), candidates.end(), require_item_update); + else + invokeOnEach (candidates.begin(), candidates.end(), mark_item_install); + */ + } + // treat arguments as package names (+allow wildcards) + else if (!zypper.arguments().empty()) + { + Resolver_Ptr solver = God->resolver(); + for_(it, zypper.arguments().begin(), zypper.arguments().end()) + { + PoolQuery q; + q.addAttribute(sat::SolvAttr::name, *it); + q.setMatchGlob(); + q.setInstalledOnly(); + + if (q.empty()) + { + if (it->find_first_of("?*") != string::npos) // wildcards used + zypper.out().info(str::form( + _("No packages matching '%s' are installed."), it->c_str())); + else + zypper.out().info(str::form( + _("Package '%s' is not installed."), it->c_str())); + zypper.setExitCode(ZYPPER_EXIT_INF_CAP_NOT_FOUND); + } + else + for_(solvit, q.selectableBegin(), q.selectableEnd()) + { + ui::Selectable::Ptr s = *solvit; + PoolItem theone = s->theObj(); + if (equalNVRA(*s->installedObj().resolvable(), *theone.resolvable())) + { + DBG << "the One (" << theone << ") is installed, skipping." << endl; + zypper.out().info(str::form( + _("No update candindate for '%s'"), s->name().c_str())); + } + else + { + //s->setCandidate(theone); ? + //s->setStatus(ui::S_Update); ? + Capability c(s->name(), Rel::GT, s->installedObj()->edition(), s->kind()); + solver->addRequire(c); + DBG << *s << " update: adding requirement " << c << endl; + } + } + } + } } // ---------------------------------------------------------------------------- Modified: trunk/zypper/src/zypper-misc.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.h?rev=9590&r1=9589&r2=9590&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.h (original) +++ trunk/zypper/src/zypper-misc.h Sun Apr 13 17:50:48 2008 @@ -57,7 +57,7 @@ * \param best_effort */ void list_updates(Zypper & zypper, - const std::setzypp::Resolvable::Kind & kinds, + const ResKindSet & kinds, bool best_effort); /** \todo remove from this header after xu is dropped */ @@ -70,7 +70,8 @@ * \param skip_interactive whether to skip updates that need user interaction * \param best_effort */ -void mark_updates(const std::setzypp::Resolvable::Kind & kinds, +void mark_updates(Zypper & zypper, + const ResKindSet & kinds, bool skip_interactive, bool best_effort); Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9590&r1=9589&r2=9590&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Sun Apr 13 17:50:48 2008 @@ -1083,6 +1083,10 @@ {"dry-run", no_argument, 0, 'D'}, // rug uses -N shorthand {"dry-run", no_argument, 0, 'N'}, + // dummy for now + {"download-only", no_argument, 0, 'd'}, + // rug-compatibility - dummy for now + {"category", no_argument, 0, 'g'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; @@ -2275,13 +2279,10 @@ return; } - // too many arguments - if (_arguments.size() > 0) - { - report_too_many_arguments(_command_help); - setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS); - return; - } + if (_copts.count("download-only")) + report_dummy_option(out(), "download-only"); + if (_copts.count("category")) + report_dummy_option(out(), "category"); // rug compatibility code // switch on non-interactive mode if no-confirm specified @@ -2315,22 +2316,31 @@ kinds.insert(ResTraits<Patch>::kind); bool best_effort = copts.count( "best-effort" ); - - if (globalOpts().is_rug_compatible && best_effort) { - best_effort = false; - // 'rug' is the name of a program and must not be translated - // 'best-effort' is a program parameter and can not be translated - out().warning( - _("Running as 'rug', can't do 'best-effort' approach to update.")); + if (globalOpts().is_rug_compatible && best_effort) + { + best_effort = false; + out().warning(str::form( + // translators: Running as 'rug', can't do 'best-effort' approach to update. + _("Running as '%s', cannot do '%s' approach to update."), + "rug", "best-effort")); } + init_target(*this); - init_repos(*this); + + // rug compatibility - treat arguments as repos + if (_gopts.is_rug_compatible && !_arguments.empty()) + init_repos(*this, _arguments); + else + init_repos(*this); + if (exitCode() != ZYPPER_EXIT_OK) return; load_resolvables(*this); - bool skip_interactive = copts.count("skip-interactive") || globalOpts().non_interactive; - mark_updates( kinds, skip_interactive, best_effort ); + bool skip_interactive = + copts.count("skip-interactive") || globalOpts().non_interactive; + + mark_updates(*this, kinds, skip_interactive, best_effort); solve_and_commit(*this); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org