From 0f8e22858088786589b0fa8e78cf0a2ef4488d97 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Mon, 21 Apr 2008 12:12:09 +0000 Subject: [PATCH] cleanup in ignore dependencies --- zypp/solver/detail/ProblemSolutionIgnore.cc | 104 +++----------------- zypp/solver/detail/ProblemSolutionIgnore.h | 79 ++------------- zypp/solver/detail/Resolver.cc | 54 +--------- zypp/solver/detail/Resolver.h | 29 +----- zypp/solver/detail/SolutionAction.cc | 79 +-------------- zypp/solver/detail/SolutionAction.h | 31 +----- 6 files changed, 34 insertions(+), 342 deletions(-) diff --git a/zypp/solver/detail/ProblemSolutionIgnore.cc b/zypp/solver/detail/ProblemSolutionIgnore.cc index 34ff23297..0cbb3733d 100644 --- a/zypp/solver/detail/ProblemSolutionIgnore.cc +++ b/zypp/solver/detail/ProblemSolutionIgnore.cc @@ -40,112 +40,30 @@ namespace zypp namespace detail { /////////////////////////////////////////////////////////////////// -IMPL_PTR_TYPE(ProblemSolutionIgnoreConflicts); -IMPL_PTR_TYPE(ProblemSolutionIgnoreRequires); -IMPL_PTR_TYPE(ProblemSolutionIgnoreArchitecture); -IMPL_PTR_TYPE(ProblemSolutionIgnoreVendor); -IMPL_PTR_TYPE(ProblemSolutionIgnoreInstalled); +IMPL_PTR_TYPE(ProblemSolutionIgnore); //--------------------------------------------------------------------------- -ProblemSolutionIgnoreRequires::ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability) +ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent, + PoolItem item ) : ProblemSolution (parent, "", "") { - _description = _("Ignore this requirement just here"); - addAction ( new InjectSolutionAction (item, capability, REQUIRES)); -} - -ProblemSolutionIgnoreRequires::ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent, - PoolItemList itemList, - const Capability & capability) - : ProblemSolution (parent, "", "") -{ - _description = _("Generally ignore this requirement"); - for (PoolItemList::const_iterator iter = itemList.begin(); - iter != itemList.end(); iter++) { - addAction ( new InjectSolutionAction (*iter, capability, REQUIRES)); - } -} + // TranslatorExplanation %s = name of package, patch, selection ... + _description = str::form (_("Ignore some dependencies for %s"), item->name().c_str() ); -ProblemSolutionIgnoreArchitecture::ProblemSolutionIgnoreArchitecture( ResolverProblem_Ptr parent, - PoolItem item) - : ProblemSolution (parent, "", "") -{ - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form(_("Install %s although it would change the architecture"), - item->name().c_str()); - // TranslatorExplanation %s = name of package, patch, selection ... - _details = str::form(_("%s provides this dependency, but would change the architecture of the installed item"), - Helper::itemToString (item).c_str()); - addAction ( new InjectSolutionAction (item, ARCHITECTURE)); -} - -ProblemSolutionIgnoreVendor::ProblemSolutionIgnoreVendor( ResolverProblem_Ptr parent, - PoolItem item) - : ProblemSolution (parent, "", "") -{ - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form(_("Install %s although it would change the vendor"), - item->name().c_str()); - // TranslatorExplanation %s = name of package, patch, selection ... - _details = str::form(_("%s provides this dependency, but would change the vendor of the installed item"), - Helper::itemToString (item).c_str()); - addAction ( new InjectSolutionAction (item, VENDOR)); -} +// addAction ( new InjectSolutionAction (item, capability, REQUIRES)); +} -ProblemSolutionIgnoreConflicts::ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItem otherItem) +ProblemSolutionIgnore::ProblemSolutionIgnore( ResolverProblem_Ptr parent, + PoolItemList itemList ) : ProblemSolution (parent, "", "") { - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form (_("Ignore this conflict of %s"), - item->name().c_str()); - addAction (new InjectSolutionAction (item, capability, CONFLICTS, otherItem)); -} - -ProblemSolutionIgnoreConflicts::ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItemList itemList) - : ProblemSolution (parent, "", "") -{ - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form (_("Ignore this conflict of %s"), - item->name().c_str()); + _description = _("Generally ignore of some dependecies"); for (PoolItemList::const_iterator iter = itemList.begin(); iter != itemList.end(); iter++) { - addAction (new InjectSolutionAction (item, capability, CONFLICTS, *iter)); +// addAction ( new InjectSolutionAction (*iter, capability, REQUIRES)); } } - -ProblemSolutionIgnoreObsoletes::ProblemSolutionIgnoreObsoletes( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItem otherItem) - : ProblemSolution (parent, "", "") -{ - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form (_("Ignore the obsolete %s in %s"), - Helper::capToString (capability).c_str(), - otherItem->name().c_str()); - addAction (new InjectSolutionAction (item, capability, OBSOLETES, otherItem)); -} - - -ProblemSolutionIgnoreInstalled::ProblemSolutionIgnoreInstalled( ResolverProblem_Ptr parent, - PoolItem item, - PoolItem otherItem) - : ProblemSolution (parent, "", "") -{ - // TranslatorExplanation %s = name of package, patch, selection ... - _description = str::form (_("Ignore that %s is already set to install"), - item->name().c_str()); - addAction (new InjectSolutionAction (item, Capability(), INSTALLED, otherItem)); -} /////////////////////////////////////////////////////////////////// };// namespace detail diff --git a/zypp/solver/detail/ProblemSolutionIgnore.h b/zypp/solver/detail/ProblemSolutionIgnore.h index 219e9856f..376502341 100644 --- a/zypp/solver/detail/ProblemSolutionIgnore.h +++ b/zypp/solver/detail/ProblemSolutionIgnore.h @@ -37,87 +37,22 @@ namespace zypp /** * Class representing one possible solution to one problem found during resolving - * This problem solution ignores one or more items - * + * This problem solution ignores one or more items by setting his dependencies + * to weak **/ - class ProblemSolutionIgnoreConflicts : public ProblemSolution + class ProblemSolutionIgnore : public ProblemSolution { public: /** * Constructor. **/ - ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItem otherItem); - ProblemSolutionIgnoreConflicts( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItemList itemList); + ProblemSolutionIgnore( ResolverProblem_Ptr parent, + PoolItem item ); + ProblemSolutionIgnore( ResolverProblem_Ptr parent, + PoolItemList itemList); }; - class ProblemSolutionIgnoreRequires : public ProblemSolution - { - public: - - /** - * Constructor. - **/ - ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability); - ProblemSolutionIgnoreRequires( ResolverProblem_Ptr parent, - PoolItemList itemList, - const Capability & capability); - }; - - class ProblemSolutionIgnoreArchitecture : public ProblemSolution - { - public: - - /** - * Constructor. - **/ - ProblemSolutionIgnoreArchitecture( ResolverProblem_Ptr parent, - PoolItem item); - }; - - class ProblemSolutionIgnoreVendor : public ProblemSolution - { - public: - - /** - * Constructor. - **/ - ProblemSolutionIgnoreVendor( ResolverProblem_Ptr parent, - PoolItem item); - }; - - class ProblemSolutionIgnoreObsoletes : public ProblemSolution - { - public: - - /** - * Constructor. - **/ - ProblemSolutionIgnoreObsoletes( ResolverProblem_Ptr parent, - PoolItem item, - const Capability & capability, - PoolItem otherItem); - }; - - class ProblemSolutionIgnoreInstalled : public ProblemSolution - { - public: - - /** - * Constructor. - **/ - ProblemSolutionIgnoreInstalled( ResolverProblem_Ptr parent, - PoolItem item, - PoolItem otherItem); - }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/detail/Resolver.cc b/zypp/solver/detail/Resolver.cc index 076b3a309..495b390aa 100644 --- a/zypp/solver/detail/Resolver.cc +++ b/zypp/solver/detail/Resolver.cc @@ -139,42 +139,9 @@ Resolver::removeExtraConflict (const Capability & capability) } void -Resolver::addIgnoreConflict (const PoolItem item, - const Capability & capability) +Resolver::addWeak (const PoolItem item) { - _ignoreConflicts.insert(make_pair(item, capability)); -} - -void -Resolver::addIgnoreRequires (const PoolItem item, - const Capability & capability) -{ - _ignoreRequires.insert(make_pair(item, capability)); -} - -void -Resolver::addIgnoreObsoletes (const PoolItem item, - const Capability & capability) -{ - _ignoreObsoletes.insert(make_pair(item, capability)); -} - -void -Resolver::addIgnoreInstalledItem (const PoolItem item) -{ - _ignoreInstalledItem.push_back (item); -} - -void -Resolver::addIgnoreArchitectureItem (const PoolItem item) -{ - _ignoreArchitectureItem.push_back (item); -} - -void -Resolver::addIgnoreVendorItem (const PoolItem item) -{ - _ignoreVendorItem.push_back (item); + _addWeak.push_back (item); } //--------------------------------------------------------------------------- @@ -237,21 +204,8 @@ Resolver::undo(void) invokeOnEach ( _pool.begin(), _pool.end(), resfilter::ByTransact( ), // collect transacts from Pool to resolver queue functor::functorRef(info) ); - // These conflict should be ignored of the concering item - _ignoreConflicts.clear(); - // These requires should be ignored of the concering item - _ignoreRequires.clear(); - // These obsoletes should be ignored of the concering item - _ignoreObsoletes.clear(); - // Ignore architecture of the item - _ignoreArchitecture.clear(); - // Ignore the status "installed" of the item - _ignoreInstalledItem.clear(); - // Ignore the architecture of the item - _ignoreArchitectureItem.clear(); - // Ignore the vendor of the item - _ignoreVendorItem.clear(); - + // Regard dependencies of the item weak onl + _addWeak.clear(); return; } diff --git a/zypp/solver/detail/Resolver.h b/zypp/solver/detail/Resolver.h index 6423e6b06..adbd6267f 100644 --- a/zypp/solver/detail/Resolver.h +++ b/zypp/solver/detail/Resolver.h @@ -79,23 +79,8 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable { CapabilitySet _extra_requires; CapabilitySet _extra_conflicts; - typedef std::multimap IgnoreMap; - - // These conflict should be ignored of the concering item - IgnoreMap _ignoreConflicts; - // These requires should be ignored of the concering item - IgnoreMap _ignoreRequires; - // These obsoletes should be ignored of the concering item - IgnoreMap _ignoreObsoletes; - // Ignore architecture of the item - PoolItemList _ignoreArchitecture; - // Ignore the status "installed" of the item - PoolItemList _ignoreInstalledItem; - // Ignore the architecture of the item - PoolItemList _ignoreArchitectureItem; - // Ignore the vendor of the item - PoolItemList _ignoreVendorItem; - + // Regard dependencies of the item weak onl + PoolItemList _addWeak; bool _forceResolve; // remove items which are conflicts with others or // have unfulfilled requirements. @@ -140,15 +125,7 @@ class Resolver : public base::ReferenceCounted, private base::NonCopyable { const CapabilitySet extraRequires () { return _extra_requires; } const CapabilitySet extraConflicts () { return _extra_conflicts; } - void addIgnoreConflict (const PoolItem item, - const Capability & capability); - void addIgnoreRequires (const PoolItem item, - const Capability & capability); - void addIgnoreObsoletes (const PoolItem item, - const Capability & capability); - void addIgnoreInstalledItem (const PoolItem item); - void addIgnoreArchitectureItem (const PoolItem item); - void addIgnoreVendorItem (const PoolItem item); + void addWeak (const PoolItem item); void setForceResolve (const bool force) { _forceResolve = force; } bool forceResolve() { return _forceResolve; } diff --git a/zypp/solver/detail/SolutionAction.cc b/zypp/solver/detail/SolutionAction.cc index 4a9242461..bc9a71df0 100644 --- a/zypp/solver/detail/SolutionAction.cc +++ b/zypp/solver/detail/SolutionAction.cc @@ -102,15 +102,8 @@ ostream & InjectSolutionAction::dumpOn( ostream& os ) const { os << "InjectSolutionAction: "; - os << _capability; - os << ", "; switch (_kind) { - case REQUIRES: os << "Requires"; break; - case CONFLICTS: os << "Conflicts"; break; - case OBSOLETES: os << "Obsoletes"; break; - case INSTALLED: os << "Installed"; break; - case ARCHITECTURE: os << "Architecture"; break; - case VENDOR: os << "Vendor"; break; + case WEAK: os << "Weak"; break; default: os << "Wrong kind"; break; } os << " "; @@ -138,7 +131,6 @@ TransactionSolutionAction::execute(Resolver & resolver) const bool ret = true; switch (action()) { case KEEP: - resolver.addIgnoreInstalledItem( _item ); /*FALLTHRU*/ case INSTALL: if (_item.status().isToBeUninstalled()) @@ -169,72 +161,11 @@ TransactionSolutionAction::execute(Resolver & resolver) const bool InjectSolutionAction::execute(Resolver & resolver) const { - Capabilities depList; - if (_item != PoolItem()) { - depList = _item.resolvable()->dep(Dep::CONFLICTS); - } switch (_kind) { - case CONFLICTS: - // removing conflict in both resolvables - for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) { - if (iter->matches (_capability) == CapMatch::yes ) - { - resolver.addIgnoreConflict (_item, _capability); - } - } - // Obsoletes are conflicts too - depList = _item.resolvable()->dep(Dep::OBSOLETES); - for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) { - if (iter->matches (_capability) == CapMatch::yes ) - { - resolver.addIgnoreConflict (_otherItem, _capability); - } - } - - depList = _otherItem.resolvable()->dep(Dep::CONFLICTS); - for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) { - if (iter->matches (_capability) == CapMatch::yes ) - { - resolver.addIgnoreConflict (_otherItem, _capability); - } - } - // Obsoletes are conflicts too - depList = _otherItem.resolvable()->dep(Dep::OBSOLETES); - for (Capabilities::const_iterator iter = depList.begin(); iter != depList.end(); iter++) { - if (iter->matches (_capability) == CapMatch::yes ) - { - resolver.addIgnoreConflict (_otherItem, _capability); - } - } - - break; - case REQUIRES: - // removing the requires dependency from the item - if (_item == PoolItem()) { - // this was a requirement via Resolver::addExtraCapability - // so we have to delete it. - resolver.removeExtraRequire (_capability); - } else { - resolver.addIgnoreRequires (_item, _capability); - } - break; - case ARCHITECTURE: - // This item is for ALL architectures available - resolver.addIgnoreArchitectureItem (_item); - break; - case VENDOR: - // This item is for ALL vendor available - resolver.addIgnoreVendorItem (_item); - break; - case OBSOLETES: - // removing the obsoletes dependency from the item - resolver.addIgnoreObsoletes (_otherItem, _capability); - break; - case INSTALLED: - // ignoring already installed items - resolver.addIgnoreInstalledItem (_item); - resolver.addIgnoreInstalledItem (_otherItem); - break; + case WEAK: + // set item dependencies to weak + resolver.addWeak (_item); + break; default: ERR << "No valid InjectSolutionAction kind found" << endl; return false; diff --git a/zypp/solver/detail/SolutionAction.h b/zypp/solver/detail/SolutionAction.h index b2d83ae75..8ca9b2c0a 100644 --- a/zypp/solver/detail/SolutionAction.h +++ b/zypp/solver/detail/SolutionAction.h @@ -104,17 +104,12 @@ namespace zypp /** - * Type of ignoring dependencies, architectures and vendor + * Type of ignoring; currently only WEAK **/ typedef enum { - REQUIRES, - CONFLICTS, - OBSOLETES, - INSTALLED, - ARCHITECTURE, - VENDOR + WEAK } InjectSolutionKind; @@ -130,25 +125,10 @@ namespace zypp public: InjectSolutionAction( PoolItem item, - const Capability & capability, const InjectSolutionKind & kind) : SolutionAction(), - _item( item ), _capability( capability ), - _kind( kind ), _otherItem() {} - - InjectSolutionAction( PoolItem item, - const InjectSolutionKind & kind) - : SolutionAction(), - _item( item ), _capability(), - _kind( kind ), _otherItem() {} - - InjectSolutionAction( PoolItem item, - const Capability & capability, - const InjectSolutionKind & kind, - PoolItem otherItem) - : SolutionAction(), - _item( item ), _capability( capability ), - _kind( kind ), _otherItem( otherItem ) {} + _item( item ), + _kind( kind ) {} // ---------------------------------- I/O virtual std::ostream & dumpOn( std::ostream & str ) const; @@ -156,7 +136,6 @@ namespace zypp { return action.dumpOn (str); } // ---------------------------------- accessors - const Capability & capability() const { return _capability; }; const PoolItem item() const { return _item; } // ---------------------------------- methods @@ -164,9 +143,7 @@ namespace zypp protected: PoolItem _item; - const Capability _capability; const InjectSolutionKind _kind; - PoolItem _otherItem; }; -- 2.34.1