From f6b23478def76a4a2a6b6083f54e08dd0656cf80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Fri, 16 Apr 2010 16:09:44 +0200 Subject: [PATCH] Feedback::SELECTED_IS_OLDER and UPD_CANDIDATE_IS_LOCKED --- src/RequestFeedback.cc | 30 ++++++++++++++++++++++++++++++ src/SolverRequester.cc | 26 ++++---------------------- src/SolverRequester.h | 14 ++++++++++++-- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/RequestFeedback.cc b/src/RequestFeedback.cc index 001bc81..b1188a5 100644 --- a/src/RequestFeedback.cc +++ b/src/RequestFeedback.cc @@ -142,6 +142,34 @@ string SolverRequester::Feedback::asUserString( _objinst->name().c_str(), cmdhint.str().c_str()); } + case UPD_CANDIDATE_IS_LOCKED: + { + PoolItem highest = asSelectable()(_objinst)->highestAvailableVersionObj(); + ostringstream cmdhint; + cmdhint << "zypper removelock " << highest->name(); + + return str::form( + _("There is an update candidate for '%s', but it is locked." + " Use '%s' to unlock it."), + _objinst->name().c_str(), cmdhint.str().c_str()); + } + + case SELECTED_IS_OLDER: + { + ostringstream msg; + msg << str::form(_( + "The selected package '%s' from repository '%s' has lower" + " version than the installed one."), + resolvable_user_string(*_objsel.resolvable()).c_str(), + Zypper::instance()->config().show_alias ? + _objsel->repoInfo().alias().c_str() : + _objsel->repoInfo().name().c_str()); + msg << str::form( + // translators: %s = "--force" + _("Use '%s' to force installation of the package."), "--force"); + return msg.str(); + } + case SET_TO_INSTALL: if (opts.force) return str::form( @@ -193,6 +221,8 @@ void SolverRequester::Feedback::print( case UPD_CANDIDATE_USER_RESTRICTED: case UPD_CANDIDATE_CHANGES_VENDOR: case UPD_CANDIDATE_HAS_LOWER_PRIO: + case UPD_CANDIDATE_IS_LOCKED: + case SELECTED_IS_OLDER: out.info(asUserString(opts)); break; case SET_TO_INSTALL: diff --git a/src/SolverRequester.cc b/src/SolverRequester.cc index 90928b0..2c63371 100644 --- a/src/SolverRequester.cc +++ b/src/SolverRequester.cc @@ -424,8 +424,6 @@ void SolverRequester::updateTo( return; } -#warning get rid of zypper here - Zypper & zypper = *Zypper::instance(); Selectable::Ptr s = asSelectable()(selected); // the best object without repository, arch, or version restriction @@ -507,18 +505,9 @@ void SolverRequester::updateTo( } else if (installed->edition() > selected->edition()) { - zypper.out().info( - str::form(_( - "The selected package '%s-%s.%s' from repository '%s' has lower" - " version than the installed one."), - selected->name().c_str(), - selected->edition().asString().c_str(), - selected->arch().asString().c_str(), - zypper.config().show_alias ? - selected->repoInfo().alias().c_str() : - selected->repoInfo().name().c_str())); - zypper.out().info(str::form( - _("Use '%s' to force installation of the package."), "--force")); + addFeedback(Feedback::SELECTED_IS_OLDER, cap, repoalias, selected, installed); + MIL << "Selected is older than the installed." + " Will not downgrade unless --force is used" << endl; } // there is higher version available than the selected candidate @@ -539,15 +528,8 @@ void SolverRequester::updateTo( // update candidate locked if (s->status() == ui::S_Protected || highest.status().isLocked()) { + addFeedback(Feedback::UPD_CANDIDATE_IS_LOCKED, cap, repoalias, selected, installed); DBG << "Newer object exists, but is locked: " << highest << endl; - - ostringstream cmdhint; - cmdhint << "zypper removelock " << highest->name(); - - zypper.out().info(str::form( - _("There is an update candidate for '%s', but it is locked." - " Use '%s' to unlock it."), - s->name().c_str(), cmdhint.str().c_str())); } // update candidate has different vendor diff --git a/src/SolverRequester.h b/src/SolverRequester.h index b7bc597..77e3a0f 100644 --- a/src/SolverRequester.h +++ b/src/SolverRequester.h @@ -88,8 +88,10 @@ public: public: enum Id { - /** Given combination of arguments and options makes no sense or the - * functionality is not defined and implemented */ + /** + * Given combination of arguments and options makes no sense or the + * functionality is not defined and implemented + */ INVALID_REQUEST, /** The search for the string in object names failed, but will try caps */ @@ -99,6 +101,7 @@ public: /** Removal or update was requested, but there's no installed item. */ NOT_INSTALLED, + /** Removal by capability requested, but no provider is installed. */ NO_INSTALLED_PROVIDER, @@ -108,6 +111,7 @@ public: UPD_CANDIDATE_CHANGES_VENDOR, UPD_CANDIDATE_HAS_LOWER_PRIO, UPD_CANDIDATE_IS_LOCKED, + /** * Selected object is not the highest available, because of user * restrictions like repo(s), version, architecture. @@ -115,6 +119,12 @@ public: UPD_CANDIDATE_USER_RESTRICTED, INSTALLED_LOCKED, + /** + * Selected object is older that the installed. Won't allow downgrade + * unless --force is used. + */ + SELECTED_IS_OLDER, + // zypp requests SET_TO_INSTALL, -- 2.7.4