Mailinglist Archive: zypp-commit (223 mails)

< Previous Next >
[zypp-commit] r10675 - in /trunk/zypper/src: install.cc install.h
  • From: jkupec@xxxxxxxxxxxxxxxx
  • Date: Mon, 28 Jul 2008 13:22:20 -0000
  • Message-id: <20080728132220.31BC32BD4E@xxxxxxxxxxxxxxxx>
Author: jkupec
Date: Mon Jul 28 15:22:19 2008
New Revision: 10675

URL: http://svn.opensuse.org/viewcvs/zypp?rev=10675&view=rev
Log:
- make install by name case-insensitive (bnc #412496)

Modified:
trunk/zypper/src/install.cc
trunk/zypper/src/install.h

Modified: trunk/zypper/src/install.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/install.cc?rev=10675&r1=10674&r2=10675&view=diff
==============================================================================
--- trunk/zypper/src/install.cc (original)
+++ trunk/zypper/src/install.cc Mon Jul 28 15:22:19 2008
@@ -15,84 +15,25 @@

extern ZYpp::Ptr God;

-// copied from yast2-pkg-bindings:PkgModuleFunctions::DoProvideNameKind
-bool ProvideProcess::operator()( const PoolItem& provider )
-{
- DBG << "Considering " << provider << endl;
- // 1. compatible arch
- // 2. best arch
- // 3. best edition
-
- // 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;
- }
-
- bool is_installed;
- if (provider->isKind(ResKind::package))
- is_installed = provider.status().isInstalled();
- else
- is_installed = provider.isSatisfied();
-
- if (!is_installed)
- {
- // deselect the item if it's already selected,
- // only one item should be selected
- if (provider.status().isToBeInstalled()) {
- DBG << " Deselecting" << endl;
- provider.status().resetTransact(whoWantsIt);
- }
-
- // regarding items which are installable only
- if (!provider->arch().compatibleWith( _architecture )) {
- DBG << format ("provider %s has incompatible arch '%s'")
- % provider->name() % provider->arch().asString() << endl;
- }
- else if (!item) {
- DBG << " First match" << endl;
- item = provider;
- }
- else if (item->arch().compare( provider->arch() ) < 0) {
- DBG << " Better arch" << endl;
- item = provider;
- }
- else if (item->edition().compare( provider->edition() ) < 0) {
- DBG << " Better edition" << endl;
- item = provider;
- }
- }
- else {
- // store encountered target item (installed)
- installed_item = provider;
- if (!item) item = provider;
- }
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-
-// this does only resolvables with this _name_.
-// we could also act on _provides_
-// TODO edition, arch
+// TODO edition, arch ?
static void mark_for_install(Zypper & zypper,
const ResObject::Kind &kind,
const std::string &name,
const std::string & repo = "")
{
// name and kind match:
- ProvideProcess installer (ZConfig::instance().systemArchitecture(), repo);
DBG << "Iterating over [" << kind << "]" << name << endl;
- invokeOnEach(
- God->pool().byIdentBegin(kind, name),
- God->pool().byIdentEnd(kind, name),
- zypp::functor::functorRef<bool,const zypp::PoolItem&> (installer));
+
+ PoolQuery q;
+ q.addAttribute(sat::SolvAttr::name, name);
+ if (!repo.empty())
+ q.addRepo(repo);
+ q.setCaseSensitive(false);
+ q.setMatchExact();

DBG << "... done" << endl;
- if (!installer.item)
+
+ if (q.empty())
{
zypper.out().error(
// translators: meaning a package %s or provider of capability %s
@@ -102,30 +43,34 @@
return;
}

- if (installer.installed_item &&
- installer.installed_item.resolvable()->edition() ==
installer.item.resolvable()->edition() &&
- installer.installed_item.resolvable()->arch() ==
installer.item.resolvable()->arch() &&
+ ui::Selectable::Ptr s = *q.selectableBegin();
+
+ if (s->installedObj() &&
+ s->installedObj().resolvable()->edition() ==
s->candidateObj().resolvable()->edition() &&
+ s->installedObj().resolvable()->arch() ==
s->candidateObj().resolvable()->arch() &&
( ! copts.count("force") ) )
{
// if it is broken install anyway, even if it is installed
- if ( installer.item.isBroken() )
+ if ( s->candidateObj().isBroken() )
{
- installer.item.status().setTransact( true, zypp::ResStatus::USER );
+ s->candidateObj().status().setTransact( true, zypp::ResStatus::USER );
+ }
+ else
+ {
+ zypper.out().info(boost::str(format(
+ // translators: e.g. skipping package 'zypper' (the newest version
already installed)
+ _("skipping %s '%s' (the newest version already installed)"))
+ % kind_to_string_localized(kind,1) % name));
}
-
- zypper.out().info(boost::str(format(
- // translators: e.g. skipping package 'zypper' (the newest version
already installed)
- _("skipping %s '%s' (the newest version already installed)"))
- % kind_to_string_localized(kind,1) % name));
}
else {

//! \todo don't use setToBeInstalled for this purpose but higher level
solver API
- bool result = installer.item.status().setToBeInstalled(
zypp::ResStatus::USER );
+ bool result = s->candidateObj().status().setToBeInstalled(
zypp::ResStatus::USER );
if (!result)
{
// this is because the resolvable is installed and we are forcing.
- installer.item.status().setTransact( true, zypp::ResStatus::USER );
+ s->candidateObj().status().setTransact( true, zypp::ResStatus::USER );
if (!copts.count("force"))
{
zypper.out().error(boost::str(
@@ -623,3 +568,4 @@
mark_by_capability (zypper, install_not_remove, kind, cap);
}
}
+

Modified: trunk/zypper/src/install.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/install.h?rev=10675&r1=10674&r2=10675&view=diff
==============================================================================
--- trunk/zypper/src/install.h (original)
+++ trunk/zypper/src/install.h Mon Jul 28 15:22:19 2008
@@ -11,22 +11,4 @@
bool install_not_remove,
const zypp::ResKind & kind);

-// copied from yast2-pkg-bindings:PkgModuleFunctions::DoProvideNameKind
-struct ProvideProcess
-{
- zypp::PoolItem item;
- zypp::PoolItem installed_item;
- zypp::ResStatus::TransactByValue whoWantsIt;
- std::string _repo;
- zypp::Arch _architecture;
-
- ProvideProcess(zypp::Arch arch, const std::string & repo)
- : whoWantsIt(zypp::ResStatus::USER)
- , _repo(repo)
- , _architecture( arch )
- { }
-
- bool operator()( const zypp::PoolItem& provider );
-};
-
#endif /*INSTALL_H_*/

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages