From 05914586bcb858ab9a78b79397baab98c2e6ea07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Wed, 20 Oct 2010 14:15:09 +0200 Subject: [PATCH] more --force fixes (bnc #483426) - plain pkgname (no EVRA) to try to install the highest version regardless of vendor/deps/locks etc. --- src/RequestFeedback.cc | 9 +++++++++ src/SolverRequester.cc | 11 +++++++++++ src/SolverRequester.h | 6 ++++++ src/Zypper.h | 1 + tests/SolverRequester_test.cc | 2 +- tests/lib/TestSetup.h | 9 +++++++++ 6 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/RequestFeedback.cc b/src/RequestFeedback.cc index 3948b5e..cb605c0 100644 --- a/src/RequestFeedback.cc +++ b/src/RequestFeedback.cc @@ -154,6 +154,14 @@ string SolverRequester::Feedback::asUserString( _objinst->name().c_str(), cmdhint.str().c_str()); } + case NOT_IN_REPOS: + { + return str::form( + _("Package '%s' is not available in your repositories." + " Cannot reinstall, upgrade, or downgrade."), + _objinst->name().c_str()); + } + case SELECTED_IS_OLDER: { ostringstream cmdhint; @@ -252,6 +260,7 @@ void SolverRequester::Feedback::print( case UPD_CANDIDATE_CHANGES_VENDOR: case UPD_CANDIDATE_HAS_LOWER_PRIO: case UPD_CANDIDATE_IS_LOCKED: + case NOT_IN_REPOS: case SELECTED_IS_OLDER: case PATCH_NOT_NEEDED: case PATCH_UNWANTED: diff --git a/src/SolverRequester.cc b/src/SolverRequester.cc index 8052bdb..07d6f5f 100644 --- a/src/SolverRequester.cc +++ b/src/SolverRequester.cc @@ -157,6 +157,15 @@ void SolverRequester::install(const PackageSpec & pkg) PoolItem instobj = get_installed_obj(s); if (instobj) { + if (s->availableEmpty()) + { + if (!_opts.force) + addFeedback(Feedback::ALREADY_INSTALLED, pkg, instobj, instobj); + addFeedback(Feedback::NOT_IN_REPOS, pkg, instobj, instobj); + MIL << s->name() << " not in repos, can't (re)install" << endl; + return; + } + // whether user requested specific repo/version/arch bool userconstraints = pkg.parsed_cap.detail().isVersioned() @@ -171,6 +180,8 @@ void SolverRequester::install(const PackageSpec & pkg) PoolItem best; if (userconstraints) updateTo(pkg, *sit); + else if (_opts.force) + updateTo(pkg, s->highestAvailableVersionObj()); else if ((best = s->updateCandidateObj())) updateTo(pkg, best); else if (changes_vendor && !_opts.allow_vendor_change) diff --git a/src/SolverRequester.h b/src/SolverRequester.h index f7647b5..3d953dc 100644 --- a/src/SolverRequester.h +++ b/src/SolverRequester.h @@ -132,6 +132,12 @@ public: UPD_CANDIDATE_IS_LOCKED, /** + * The installed package is no longer available in repositories. + * => can't reinstall, can't update/downgrade.. + */ + NOT_IN_REPOS, + + /** * Selected object is not the highest available, because of user * restrictions like repo(s), version, architecture. */ diff --git a/src/Zypper.h b/src/Zypper.h index 50ef29e..09a707b 100644 --- a/src/Zypper.h +++ b/src/Zypper.h @@ -171,6 +171,7 @@ public: Out & out(); Config & config() { return _config; } const GlobalOptions & globalOpts() const { return _gopts; } + GlobalOptions & globalOptsNoConst() { return _gopts; } const parsed_opts & cOpts() const { return _copts; } const ZypperCommand & command() const { return _command; } const std::string & commandHelp() const { return _command_help; } diff --git a/tests/SolverRequester_test.cc b/tests/SolverRequester_test.cc index 138f28c..d8cc2e7 100644 --- a/tests/SolverRequester_test.cc +++ b/tests/SolverRequester_test.cc @@ -311,7 +311,7 @@ BOOST_AUTO_TEST_CASE(install10) sr.install(rawargs); BOOST_CHECK(sr.hasFeedback(SolverRequester::Feedback::ALREADY_INSTALLED)); - BOOST_CHECK(sr.hasFeedback(SolverRequester::Feedback::NO_UPD_CANDIDATE)); + BOOST_CHECK(sr.hasFeedback(SolverRequester::Feedback::NOT_IN_REPOS)); } // request : install diffutils diff --git a/tests/lib/TestSetup.h b/tests/lib/TestSetup.h index b90bd3a..011c26e 100644 --- a/tests/lib/TestSetup.h +++ b/tests/lib/TestSetup.h @@ -21,6 +21,8 @@ using boost::unit_test::test_case; #include "zypp/Target.h" #include "zypp/ResPool.h" +#include "Zypper.h" + using std::cin; using std::cout; using std::cerr; @@ -399,6 +401,13 @@ class TestSetup filesystem::clean_dir( _rootdir ); } + + Zypper & zypper = *Zypper::instance(); + zypper.globalOptsNoConst().root_dir = _rootdir.asString(); + zypper.globalOptsNoConst().rm_options = zypp::RepoManagerOptions(_rootdir.asString()); + zypper.globalOptsNoConst().rm_options.knownReposPath = _rootdir / "repos.d"; + + if ( ! sysarch_r.empty() ) ZConfig::instance().setSystemArchitecture( sysarch_r ); USR << "CREATED TESTSETUP below " << _rootdir << endl; -- 2.7.4