From 3d9294674e6633d0f4cf939d61a3536613afcdfd Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Fri, 18 Apr 2008 15:50:32 +0000 Subject: [PATCH] - allow to force repository per-package using: zypper install :packagename (fate #302919) - implies --name, libzypp/solver support needed for --capability - TODO: check the arguments first and report non-existing repos --- src/zypper-misc.cc | 33 +++++++++++++++++++++++---------- src/zypper-misc.h | 6 +++--- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/zypper-misc.cc b/src/zypper-misc.cc index 153b8af..75f10d6 100644 --- a/src/zypper-misc.cc +++ b/src/zypper-misc.cc @@ -84,10 +84,11 @@ bool ProvideProcess::operator()( const PoolItem& provider ) // 2. best arch // 3. best edition - // check the version if it's specified - if (!version.empty() && version != provider->edition().asString()) { - DBG << format ("Skipping version %s (requested: %s)") - % provider->edition().asString() % version << endl; + // check the repository alias if it's specified + if (!_repo.empty() && _repo != provider->repository().info().alias()) + { + DBG << format ("Skipping repository %s (requested: %s)") + % provider->repository().info().alias() % _repo << endl; return true; } @@ -131,10 +132,11 @@ bool ProvideProcess::operator()( const PoolItem& provider ) // TODO edition, arch static void mark_for_install(Zypper & zypper, const ResObject::Kind &kind, - const std::string &name) + const std::string &name, + const std::string & repo = "") { // name and kind match: - ProvideProcess installer (ZConfig::instance().systemArchitecture(), "" /*version*/); + ProvideProcess installer (ZConfig::instance().systemArchitecture(), repo); DBG << "Iterating over [" << kind << "]" << name << endl; invokeOnEach( God->pool().byIdentBegin(kind, name), @@ -240,10 +242,11 @@ static void mark_by_name (Zypper & zypper, bool install_not_remove, const ResObject::Kind &kind, - const string &name ) + const string &name, + const string & repo = "") { if (install_not_remove) - mark_for_install(zypper, kind, name); + mark_for_install(zypper, kind, name, repo); else mark_for_uninstall(zypper, kind, name); } @@ -439,14 +442,24 @@ void install_remove(Zypper & zypper, str.erase(0, 1); } + string::size_type pos; + //! \todo force repo with ':' + if ((pos = str.rfind(':')) != string::npos) + { + repo = str.substr(0, pos); + str = str.substr(pos + 1); + force_by_name = true; // until there is a solver API for this + } - //! \todo force arch with '@' + //! \todo force arch with '.' or '@'??? + if ((pos = str.find('.')) != string::npos) + { } // mark by name by force if (force_by_name) { - mark_by_name (zypper, install_not_remove, kind, str); + mark_by_name (zypper, install_not_remove, kind, str, repo); continue; } diff --git a/src/zypper-misc.h b/src/zypper-misc.h index 2a38726..b09b7e2 100644 --- a/src/zypper-misc.h +++ b/src/zypper-misc.h @@ -91,12 +91,12 @@ struct ProvideProcess zypp::PoolItem item; zypp::PoolItem installed_item; zypp::ResStatus::TransactByValue whoWantsIt; - std::string version; + std::string _repo; zypp::Arch _architecture; - ProvideProcess(zypp::Arch arch, const std::string &vers) + ProvideProcess(zypp::Arch arch, const std::string & repo) : whoWantsIt(zypp::ResStatus::USER) - , version(vers) + , _repo(repo) , _architecture( arch ) { } -- 2.7.4