From: Ján Kupec Date: Tue, 13 Apr 2010 11:33:13 +0000 (+0200) Subject: install9 test case added X-Git-Tag: 1.4.2~1^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=446c67db06115251e38499fd5e5e8d8c310d439b;p=platform%2Fupstream%2Fzypper.git install9 test case added --- diff --git a/src/RequestFeedback.cc b/src/RequestFeedback.cc index 31bb676..b5499f8 100644 --- a/src/RequestFeedback.cc +++ b/src/RequestFeedback.cc @@ -105,12 +105,23 @@ string SolverRequester::Feedback::asUserString( case UPD_CANDIDATE_USER_RESTRICTED: { PoolItem highest = asSelectable()(_objsel)->highestAvailableVersionObj(); - PoolItem installed = asSelectable()(_objsel)->installedObj(); return str::form( _("There is an update candidate '%s' for '%s', but it does not match" " specified version, architecture, or repository."), poolitem_user_string(highest).c_str(), - poolitem_user_string(installed).c_str()); + poolitem_user_string(_objinst).c_str()); + } + + case UPD_CANDIDATE_CHANGES_VENDOR: + { + PoolItem highest = asSelectable()(_objinst)->highestAvailableVersionObj(); + ostringstream cmdhint; + cmdhint << "zypper install " << poolitem_user_string(highest); + + return str::form( + _("There is an update candidate for '%s', but it is from different" + " vendor. Use '%s' to install this candidate."), + _objinst->name().c_str(), cmdhint.str().c_str()); } case SET_TO_INSTALL: @@ -160,6 +171,8 @@ void SolverRequester::Feedback::print( case NO_INSTALLED_PROVIDER: case ALREADY_INSTALLED: case NO_UPD_CANDIDATE: + case UPD_CANDIDATE_USER_RESTRICTED: + case UPD_CANDIDATE_CHANGES_VENDOR: out.info(asUserString(opts)); break; case SET_TO_INSTALL: diff --git a/src/SolverRequester.cc b/src/SolverRequester.cc index bc47441..cf9f4d5 100644 --- a/src/SolverRequester.cc +++ b/src/SolverRequester.cc @@ -103,13 +103,26 @@ void SolverRequester::install(const Capability & cap, const string & repoalias) q.addRepo(repoalias); // get the best matching items and tag them for installation. + // FIXME this ignores vendor lock - we need some way to do --from which + // would respect vendor lock: e.g. a new Selectable::updateCandidateObj(Options&) PoolItemBest bestMatches(q.begin(), q.end()); if (!bestMatches.empty()) { for_(sit, bestMatches.begin(), bestMatches.end()) { - if (asSelectable()(*sit)->hasInstalledObj()) - updateTo(cap, repoalias, *sit); + Selectable::Ptr s(asSelectable()(*sit)); + if (s->hasInstalledObj()) + { + // whether user requested specific repo/version/arch + bool userconstraints = + cap.detail().isVersioned() || cap.detail().hasArch() + || !_opts.from_repos.empty() || !repoalias.empty(); + PoolItem best = s->updateCandidateObj(); + if (userconstraints || !best) + updateTo(cap, repoalias, *sit); + else + updateTo(cap, repoalias, best); + } else if (_requested_inst) { setToInstall(*sit); @@ -127,13 +140,12 @@ void SolverRequester::install(const Capability & cap, const string & repoalias) WAR << "'" << cap << "' not found" << endl; return; } + + addFeedback(Feedback::NOT_FOUND_NAME_TRYING_CAPS, cap, repoalias); } // try by capability - if (!_opts.force_by_cap) - addFeedback(Feedback::NOT_FOUND_NAME_TRYING_CAPS, cap, repoalias); - // is there a provider for the requested capability? sat::WhatProvides q(cap); if (q.empty()) @@ -390,7 +402,7 @@ void SolverRequester::updateTo( #warning TODO handle pseudoinstalled objects } - DBG << "chosen: " << candidate << endl; + DBG << "selected: " << candidate << endl; DBG << "best: " << theone << endl; DBG << "highest: " << highest << endl; DBG << "installed: " << installed << endl; @@ -452,69 +464,6 @@ void SolverRequester::updateTo( // the highest version is already there if (identical(installed, highest) || highest->edition() < installed->edition()) addFeedback(Feedback::NO_UPD_CANDIDATE, cap, repoalias, candidate, installed); - - // there is higher version available than the selected candidate - // this can happen because of repo priorities, locks, vendor lock, and - // because of CLI restrictions: repos/arch/version - // (bnc #522223) - else - { - // whether user requested specific repo/version/arch - bool userconstraints = - cap.detail().isVersioned() || cap.detail().hasArch() - || !_opts.from_repos.empty() || !repoalias.empty(); - if (userconstraints) - { - addFeedback(Feedback::UPD_CANDIDATE_USER_RESTRICTED, cap, repoalias, candidate, installed); - DBG << "Newer object exists, but has different repo/arch/version: " << highest << endl; - } - - // update candidate locked - else if (s->status() == ui::S_Protected || highest.status().isLocked()) - { - 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 - else if (highest->vendor() != installed->vendor()) - { - DBG << "Newer object with different vendor exists: " << highest - << " (" << highest->vendor() << ")" - << ". Installed vendor: " << installed->vendor() << endl; - - ostringstream cmdhint; - cmdhint << "zypper install " << highest->name() - << "-" << highest->edition() << "." << highest->arch(); - - zypper.out().info(str::form( - _("There is an update candidate for '%s', but it is from different" - " vendor. Use '%s' to install this candidate."), - s->name().c_str(), cmdhint.str().c_str())); - } - - // update candidate is from low-priority (higher priority number) repo - else if (highest->repoInfo().priority() > installed->repoInfo().priority()) - { - DBG << "Newer object exists in lower-priority repo: " << highest << endl; - - ostringstream cmdhint; - cmdhint << "zypper install " << highest->name() - << "-" << highest->edition() << "." << highest->arch(); - - zypper.out().info(str::form( - _("There is an update candidate for '%s', but it comes from repository" - " with lower priority. Use '%s' to install this candidate."), - s->name().c_str(), cmdhint.str().c_str())); - } - } } else if (installed->edition() > candidate->edition()) { @@ -531,10 +480,59 @@ void SolverRequester::updateTo( zypper.out().info(str::form( _("Use '%s' to force installation of the package."), "--force")); } - // there is also higher version than candidate, but that won't be installed. - else if (!identical(candidate, highest)) + + // there is higher version available than the selected candidate + // this can happen because of repo priorities, locks, vendor lock, and + // because of CLI restrictions: repos/arch/version (bnc #522223) + if (!identical(candidate, highest) && highest->edition() > installed->edition()) { + // whether user requested specific repo/version/arch + bool userconstraints = + cap.detail().isVersioned() || cap.detail().hasArch() + || !_opts.from_repos.empty() || !repoalias.empty(); + if (userconstraints) + { + addFeedback(Feedback::UPD_CANDIDATE_USER_RESTRICTED, cap, repoalias, candidate, installed); + DBG << "Newer object exists, but has different repo/arch/version: " << highest << endl; + } + + // update candidate locked + else if (s->status() == ui::S_Protected || highest.status().isLocked()) + { + 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 + else if (highest->vendor() != installed->vendor()) + { + addFeedback(Feedback::UPD_CANDIDATE_CHANGES_VENDOR, cap, repoalias, candidate, installed); + DBG << "Newer object with different vendor exists: " << highest + << " (" << highest->vendor() << ")" + << ". Installed vendor: " << installed->vendor() << endl; + } + + // update candidate is from low-priority (higher priority number) repo + else if (highest->repoInfo().priority() > installed->repoInfo().priority()) + { + DBG << "Newer object exists in lower-priority repo: " << highest << endl; + + ostringstream cmdhint; + cmdhint << "zypper install " << highest->name() + << "-" << highest->edition() << "." << highest->arch(); + + zypper.out().info(str::form( + _("There is an update candidate for '%s', but it comes from repository" + " with lower priority. Use '%s' to install this candidate."), + s->name().c_str(), cmdhint.str().c_str())); + } } } diff --git a/src/SolverRequester.h b/src/SolverRequester.h index 4f9216f..895d5fd 100644 --- a/src/SolverRequester.h +++ b/src/SolverRequester.h @@ -102,7 +102,7 @@ public: /** Selected object is already installed. */ ALREADY_INSTALLED, NO_UPD_CANDIDATE, - UPD_CANDIDATE_CHANGES_VERSION, + UPD_CANDIDATE_CHANGES_VENDOR, UPD_CANDIDATE_HAS_LOWER_PRIO, UPD_CANDIDATE_IS_LOCKED, /** diff --git a/tests/SolverRequester_test.cc b/tests/SolverRequester_test.cc index fb9e8e4..da103fc 100644 --- a/tests/SolverRequester_test.cc +++ b/tests/SolverRequester_test.cc @@ -33,11 +33,12 @@ BOOST_AUTO_TEST_CASE(setup) { MIL << "============setup===========" << endl; TestSetup test(Arch_x86_64); - // fake target from the whole 11.1 repo + // fake target from a subset of the online 11.1 repo test.loadTargetRepo(TESTS_SRC_DIR "/data/openSUSE-11.1_subset"); - test.loadRepo(TESTS_SRC_DIR "/data/openSUSE-11.1"); - test.loadRepo(TESTS_SRC_DIR "/data/openSUSE-11.1_updates"); - test.loadRepo(TESTS_SRC_DIR "/data/misc"); + test.loadRepo(TESTS_SRC_DIR "/data/openSUSE-11.1", "main"); + test.loadRepo(TESTS_SRC_DIR "/data/openSUSE-11.1_updates", "upd"); + test.loadRepo(TESTS_SRC_DIR "/data/misc", "misc"); + test.loadRepo(TESTS_SRC_DIR "/data/OBS_zypp_svn-11.1", "zypp"); } /////////////////////////////////////////////////////////////////////////// @@ -119,7 +120,7 @@ BOOST_AUTO_TEST_CASE(install5) MIL << "<============install5===============>" << endl; vector rawargs; - rawargs.push_back("info"); + rawargs.push_back("login"); SolverRequester sr; sr.install(rawargs); @@ -188,6 +189,25 @@ BOOST_AUTO_TEST_CASE(install8) BOOST_CHECK(sr.requires().empty()); } +// request : install 'info' +// response: Already installed. Update candidate info-4.13-1.1 is available +// but has different vendor +BOOST_AUTO_TEST_CASE(install9) +{ + MIL << "<============install9===============>" << endl; + + vector rawargs; + rawargs.push_back("info"); + SolverRequester sr; + + sr.install(rawargs); + + BOOST_CHECK(sr.hasFeedback(SolverRequester::Feedback::SET_TO_INSTALL)); + BOOST_CHECK_EQUAL(sr.toInstall().size(), 1); + BOOST_CHECK(hasPoolItem(sr.toInstall(), "info", Edition("4.12-1.111"), Arch_x86_64)); + BOOST_CHECK(sr.hasFeedback(SolverRequester::Feedback::UPD_CANDIDATE_CHANGES_VENDOR)); +} + /////////////////////////////////////////////////////////////////////////// diff --git a/tests/data/misc/repodata/primary.xml.gz b/tests/data/misc/repodata/primary.xml.gz index ef89aa6..683a9aa 100644 Binary files a/tests/data/misc/repodata/primary.xml.gz and b/tests/data/misc/repodata/primary.xml.gz differ diff --git a/tests/data/misc/repodata/repomd.xml b/tests/data/misc/repodata/repomd.xml index 11ad9ba..4f5b7bc 100644 --- a/tests/data/misc/repodata/repomd.xml +++ b/tests/data/misc/repodata/repomd.xml @@ -1,10 +1,9 @@ - - eade5d174d1be528d6c799a029dea97a5f67b412 - 1271074957.0 - 0955db069bfb747dd0a76399adf31af909b07a36 + 71a0027b2ac4239ce27fbfa4302cc39dd03de234 + 1271084467.0 + 85af54786e9ab0699bea6c6abf7b3eb24cbcd48e diff --git a/tests/data/openSUSE-11.1_subset/repodata/primary.xml.gz b/tests/data/openSUSE-11.1_subset/repodata/primary.xml.gz index 1164e5d..6797095 100644 Binary files a/tests/data/openSUSE-11.1_subset/repodata/primary.xml.gz and b/tests/data/openSUSE-11.1_subset/repodata/primary.xml.gz differ diff --git a/tests/data/openSUSE-11.1_subset/repodata/repomd.xml b/tests/data/openSUSE-11.1_subset/repodata/repomd.xml index e149809..8eacc74 100644 --- a/tests/data/openSUSE-11.1_subset/repodata/repomd.xml +++ b/tests/data/openSUSE-11.1_subset/repodata/repomd.xml @@ -2,8 +2,8 @@ - 98741c2871c433e2a52d97cef546df015f8735a2 - 1271025991.0 - 109aeeca4c9555fbfdc0f5052a8349a92c89d3c2 + a318a8d6852d31d4c901d18647601a38babfd51d + 1271158179.0 + 2d6d80ffe4acb757ab64bba66cdf8341821814d0