+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Dependency.cc
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * Definition of 'dependency'
- * contains name-op-spec
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include <y2util/stringutil.h>
-
-#include <zypp/solver/detail/Dependency.h>
-#include <zypp/solver/detail/OrDependency.h>
-#include <zypp/Arch.h>
-#include <zypp/Edition.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- using namespace std;
-
- IMPL_DERIVED_POINTER(Dependency,Spec);
-
-
- string
- Dependency::asString ( void ) const
- {
- return toString (*this);
- }
-
-
- string
- Dependency::toString ( const Dependency & dependency )
- {
- string res;
-
- res += dependency.name();
- if (dependency.relation() != Rel::ANY) {
- res += " ";
- res += dependency.relation().asString();
- res += " ";
-
- res += dependency.edition().asString();
- }
- if (dependency.orDep()) res += " [OR]";
- if (dependency.preDep()) res += " [PRE]";
-
- return res;
- }
-
-
- string
- Dependency::toString (const CDependencyList & dl)
- {
- string res("[");
- for (CDependencyList::const_iterator iter = dl.begin(); iter != dl.end(); iter++) {
- if (iter != dl.begin()) res += ", ";
- res += (*iter)->asString();
- }
- return res + "]";
- }
-
-
-
-
- ostream &
- Dependency::dumpOn( ostream & str ) const
- {
- str << asString();
- return str;
- }
-
-
- ostream&
- operator<<( ostream& os, const Dependency& dependency)
- {
- return os << dependency.asString();
- }
-
- //---------------------------------------------------------------------------
-
- Dependency::Dependency (const string & name, const Rel & relation, const Resolvable::Kind & kind,
- constChannelPtr channel,
- int epoch, const string & version, const string & release, const Arch & arch,
- bool or_dep, bool pre_dep)
- : Spec (kind, name, epoch, version, release, arch)
- , _relation (relation)
- , _channel (channel)
- , _or_dep (or_dep)
- , _pre_dep (pre_dep)
- {
- }
-
-
- Dependency::Dependency (const string & name, const Rel & relation, const Resolvable::Kind & kind,
- constChannelPtr channel, const Edition & edition, bool or_dep, bool pre_dep)
- : Spec (kind, name, edition)
- , _relation (relation)
- , _channel (channel)
- , _or_dep (or_dep)
- , _pre_dep (pre_dep)
- {
- }
-
-
- Dependency::Dependency (OrDependencyPtr or_dep)
- : Spec (ResTraits<zypp::Package>::kind, or_dep->name())
- , _relation (Rel::ANY)
- , _channel (NULL)
- , _or_dep (false)
- , _pre_dep (true)
- {
- or_dep->addCreatedProvide (this);
- }
-
-
- Dependency::Dependency (constXmlNodePtr node)
- : Spec (ResTraits<zypp::Package>::kind, "")
- , _relation (Rel::ANY)
- , _channel (new Channel(CHANNEL_TYPE_ANY))
- , _or_dep (false)
- , _pre_dep (false)
- {
- const char *tmp;
-
- if (!node->equals("dep")) {
- fprintf (stderr, "Dependency::Dependency bad node\n");
- abort();
- }
-
- setName(node->getProp ("name"));
- tmp = node->getProp ("op", NULL);
- if (tmp) {
- _relation = Rel(tmp);
- setEpoch (node->getIntValueDefault ("epoch", Edition::noepoch));
- setVersion (node->getProp ("version"));
- setRelease (node->getProp ("release"));
- }
-
- tmp = node->getProp ("arch", NULL);
- if (tmp) {
- setArch ( Arch(node->getProp ("arch")));
- } else {
- setArch ( Arch());
- }
- #if 0
- tmp = node->getProp ("kind", NULL);
- if (tmp) {
- setKind (Kind (node->getProp ("kind")));
- }
- #endif
- /* FIXME: should get channel from XML */
- /* FIXME: should get arch from XML */
- }
-
-
- Dependency::~Dependency()
- {
- }
-
- //---------------------------------------------------------------------------
-
- DependencyPtr parseXml (constXmlNodePtr node)
- {
- if (node->equals("dep")) {
- return new Dependency (node);
- } else if (node->equals("or")) {
- CDependencyList or_dep_list;
-
- node = node->children();
-
- while (node) {
- if (node->isElement()) {
- or_dep_list.push_back (new Dependency (node));
- }
-
- node = node->next();
- }
-
- OrDependencyPtr or_dep = OrDependency::fromDependencyList(or_dep_list);
- return new Dependency (or_dep);
- }
-
- fprintf (stderr, "Unhandled dependency [%s]\n", node->name());
-
- return NULL;
- }
-
-
- bool
- Dependency::verifyRelation (constDependencyPtr prov) const
- {
- int compare_ret = 0;
- if (getenv ("SPEW_DEP")) fprintf (stderr, "Dependency::verifyRelation(dep: %s, prov: %s)", asString().c_str(), prov->asString().c_str());
- /* No dependency can be met by a different token name */
- if (name() != prov->name()) {
- if (getenv ("SPEW_DEP")) fprintf (stderr, "-> wrong name\n");
- return false;
- }
-
- /* No dependency can be met by a different type */
- if (kind() != prov->kind()) {
- if (getenv ("SPEW_DEP")) fprintf (stderr, "-> wrong kind(dep: %s, prov: %s)\n", kind().asString().c_str(), prov->kind().asString().c_str());
- return false;
- }
-
- /* WARNING: RC_RELATION_NONE is NOT handled */
-
- /* No specific version in the req, so return */
- if (_relation == Rel::ANY) {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " (any) -> true\n");
- return true;
- }
-
- /* No specific version in the prov. In RPM this means it will satisfy
- * any version, but debian it will not satisfy a versioned dep */
- if (prov->relation() == Rel::ANY) {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " provides (any) matches GVersion -> true\n");
- return true;
- }
-
- if (!channel()->equals (prov->channel()))
- {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " wrong channel -> false\n");
- return false;
- }
-
- SpecPtr newdepspec;
- SpecPtr newprovspec;
-
- if (epoch() >= 0 && prov->epoch() >= 0) {
- /* HACK: This sucks, but I don't know a better way to compare elements one at a time */
- newdepspec = new Spec(kind(), "", epoch());
- newprovspec = new Spec(prov->kind(), "", prov->epoch());
- compare_ret = Spec::compare (newprovspec, newdepspec);
- } else if (prov->epoch() > 0 ) {
- //VERSION_PROP_IGNORE_ABSENT_EPOCHS
- compare_ret = 0;
- } else if (epoch() > 0 ) {
- compare_ret = Edition::noepoch;
- }
- if (getenv ("SPEW_DEP")) fprintf (stderr, "epoch(%d), prov->epoch(%d) -> compare_ret %d\n", epoch(), prov->epoch(), compare_ret);
- if (compare_ret == 0) {
- if (!(release().empty() || prov->release().empty())) {
- newdepspec = new Spec(kind(), "", Edition::noepoch, version(), release());
- newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version(), prov->release());
- } else {
- newdepspec = new Spec(kind(), "", Edition::noepoch, version());
- newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version());
- }
- compare_ret = Spec::compare (newprovspec, newdepspec);
- }
- if (getenv ("SPEW_DEP")) fprintf (stderr, " (compare result -> %d)", compare_ret);
-
- if (compare_ret < 0
- && ((prov->relation() == Rel::GT || prov->relation() == Rel::GE )
- || (_relation == Rel::LT || _relation == Rel::LE )))
- {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " -> true\n");
- return true;
- } else if (compare_ret > 0
- && ((prov->relation() == Rel::LT || prov->relation() == Rel::LE )
- || (_relation == Rel::GT || _relation == Rel::GE )))
- {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " -> true\n");
- return true;
- } else if (compare_ret == 0
- && (((prov->relation() == Rel::EQ || prov->relation() == Rel::GE || prov->relation() == Rel::LE)
- && (_relation == Rel::EQ || _relation == Rel::GE || _relation == Rel::LE))
- || ((prov->relation() == Rel::LT) && (_relation == Rel::LT))
- || ((prov->relation() == Rel::GT) && (_relation == Rel::GT))))
- {
- if (getenv ("SPEW_DEP")) fprintf (stderr, " -> true\n");
- return true;
- }
- if (getenv ("SPEW_DEP")) fprintf (stderr, " -> false\n");
- return false;
- }
-
- //---------------------------------------------------------------------------
-
- #if 0
- xmlNode *
- rc_resItem_dep_or_slist_to_xml_node (RCResItemDepSList *dep)
- {
- xmlNode *or_node;
- const RCResItemDepSList *dep_iter;
-
- or_node = xmlNewNode (NULL, "or");
-
- dep_iter = dep;
- while (dep_iter) {
- RCResItemDep *dep_item = (RCResItemDep *)(dep_iter->data);
- xmlAddChild (or_node, rc_resItem_dep_to_xml_node (dep_item));
- dep_iter = dep_iter->next;
- }
-
- return or_node;
- } /* rc_resItem_dep_or_slist_to_xml_node */
-
- xmlNode *
- rc_resItem_dep_to_xml_node (RCResItemDep *dep_item)
- {
- RCResItemSpec *spec = (RCResItemSpec *) dep_item;
- xmlNode *dep_node;
-
- if (rc_resItem_dep_is_or (dep_item)) {
- RCResItemDepSList *dep_or_slist;
- dep_or_slist = rc_dep_string_to_or_dep_slist
- (rc_resItem_spec_get_name (spec));
- dep_node = rc_resItem_dep_or_slist_to_xml_node (dep_or_slist);
- rc_resItem_dep_slist_free (dep_or_slist);
- return dep_node;
- }
-
- dep_node = xmlNewNode (NULL, "dep");
-
- xmlSetProp (dep_node, "name", rc_resItem_spec_get_name (spec));
-
- if (rc_resItem_dep_get_relation (dep_item) != Relation::Any) {
- xmlSetProp (dep_node, "op",
- rc_resItem_relation_to_string (
- rc_resItem_dep_get_relation (dep_item), false));
-
- if (rc_resItem_spec_has_epoch (spec)) {
- gchar *tmp;
-
- tmp = g_strdup_printf ("%d", rc_resItem_spec_get_epoch (spec));
- xmlSetProp (dep_node, "epoch", tmp);
- g_free (tmp);
- }
-
- if (spec->version) {
- xmlSetProp (dep_node, "version", spec->version);
- }
-
- if (spec->release) {
- xmlSetProp (dep_node, "release", spec->release);
- }
- }
-
- return (dep_node);
- } /* rc_resItem_dep_to_xml_node */
-
- #endif
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Dependency.h
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _Dependency_h
-#define _Dependency_h
-
-#include <list>
-#include <iosfwd>
-#include <string.h>
-
-#include <y2util/Ustring.h>
-
-#include <zypp/solver/detail/Channel.h>
-#include <zypp/solver/detail/DependencyPtr.h>
-#include <zypp/solver/detail/OrDependencyPtr.h>
-#include <zypp/solver/detail/Spec.h>
-#include <zypp/solver/detail/XmlNode.h>
-#include <zypp/ResObject.h>
-#include <zypp/Rel.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
-
- typedef std::list <DependencyPtr> DependencyList;
- typedef std::list <constDependencyPtr> CDependencyList;
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Dependency
- /**
- *
- **/
-
- class Dependency : public Spec {
- REP_BODY(Dependency);
-
- private:
- Rel _relation;
- constChannelPtr _channel;
- bool _or_dep;
- bool _pre_dep;
-
- public:
-
- Dependency (const std::string & name,
- const Rel & relation,
- const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
- constChannelPtr channel = NULL,
- int epoch = Edition::noepoch,
- const std::string & version = "",
- const std::string & release = "",
- const Arch & arch = Arch(),
- bool or_dep = false,
- bool pre_dep = false);
-
- Dependency (const std::string & name,
- const Rel & relation,
- const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
- constChannelPtr channel = NULL,
- const zypp::Edition & edition = zypp::Edition(),
- bool or_dep = false,
- bool pre_dep = false);
-
- Dependency (OrDependencyPtr or_dep); //RCResItemDep *rc_dep_or_new_provide (RCDepOr *dor);
-
- Dependency (constXmlNodePtr node); //RCResItemDep *rc_xml_node_to_resItem_dep (const xmlNode *node);
-
- virtual ~Dependency();
-
- // ---------------------------------- I/O
-
- const xmlNodePtr asXmlNode (void) const; // xmlNode *rc_resItem_dep_to_xml_node (RCResItemDep *dep_item);
-
- static std::string toString ( const Dependency & dep );
-
- static std::string toString ( const CDependencyList & deplist );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- friend std::ostream& operator<<( std::ostream & str, const Dependency & dep);
-
- std::string asString ( void ) const;
-
- // ---------------------------------- accessors
-
- const Rel & relation() const { return _relation; }
- constChannelPtr channel (void) const { return _channel; }
-
- bool orDep (void) const { return _or_dep; }
- void setOrDep (bool or_dep) { _or_dep = or_dep; }
-
- bool preDep (void) const { return _pre_dep; }
- void setPreDep (bool pre_dep) { _pre_dep = pre_dep; }
-
- // ---------------------------------- methods
-
- DependencyPtr parseXml (constXmlNodePtr node);
- bool verifyRelation (constDependencyPtr prov) const;
- };
-
- // xmlNode *rc_resItem_dep_or_slist_to_xml_node (RCResItemDepSList *dep);
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _Dependency_h
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* DependencyPtr.h
- *
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _DependencyPtr_h
-#define _DependencyPtr_h
-
-#include <y2util/RepDef.h>
-#include <zypp/solver/detail/SpecPtr.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- // CLASS NAME : DependencyPtr
- // CLASS NAME : constDependencyPtr
- ///////////////////////////////////////////////////////////////////
- DEFINE_DERIVED_POINTER(Dependency,Spec);
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _DependencyPtr_h
Subscription.h \
ResItem.h \
ResItemPtr.h \
- Dependency.h \
- DependencyPtr.h \
ResItemAndDependency.h \
ResItemAndDependencyPtr.h \
- OrDependency.h \
- OrDependencyPtr.h \
Package.h \
PackagePtr.h \
PackageUpdate.h \
Channel.cc \
Subscription.cc \
ResItem.cc \
- Dependency.cc \
ResItemAndDependency.cc \
- OrDependency.cc \
XmlNode.cc \
Importance.cc \
Section.cc \
#include <zypp/solver/detail/World.h>
#include <zypp/Rel.h>
+#include <zypp/CapFactory.h>
+#include <zypp/CapSet.h>
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
}
// Check the dep
- if ((_dependency == NULL) ^ (lock._dependency == NULL))
- return false;
- if (_dependency && lock._dependency) {
- if (!( ((constSpecPtr) _dependency)->equals((constSpecPtr) lock._dependency))
- || (_dependency->relation() != lock._dependency->relation())
- || (_dependency->kind() != lock._dependency->kind()))
- {
- return false;
- }
- }
+ if ( _dependency != lock._dependency)
+ return false;
return true;
}
constChannelPtr channel = resItem->channel ();
if (channel != NULL && !_channel_id.empty()) {
- if (! channel->hasEqualId (_channel_id)) {
- return false;
- }
+ if (! channel->hasEqualId (_channel_id)) {
+ return false;
+ }
}
name = resItem->name ();
- // FIXME, implement regexp
- #if 0
+ // FIXME, implement regexp
+#if 0
if (match->_pattern_spec
- && ! g_pattern_match_string (match->pattern_spec, name)) {
- return false;
+ && ! g_pattern_match_string (match->pattern_spec, name)) {
+ return false;
}
- #endif
-
- /* FIXME: ResItems don't have ResItemUpdate right now */
- /* if (match->importance != RC_IMPORTANCE_INVALID && */
- /* !rc_resItem_is_installed (resItem)) { */
- /* RCResItemUpdate *up = rc_resItem_get_latest_update (pkg); */
- /* if (up) { */
- /* if (match->importance_gteq ? up->importance > match->importance */
- /* : up->importance < match->importance) */
- /* return FALSE; */
- /* } */
- /* } */
-
- if (_dependency) {
- DependencyPtr dependency;
- bool check;
-
- dependency = new Dependency (resItem->name(), Rel::EQ, ResTraits<zypp::Package>::kind, resItem->channel(), resItem->edition());
- check = _dependency->verifyRelation (dependency);
- return check;
- }
-
- return true;
+#endif
+
+ /* FIXME: ResItems don't have ResItemUpdate right now */
+ /* if (match->importance != RC_IMPORTANCE_INVALID && */
+ /* !rc_resItem_is_installed (resItem)) { */
+ /* RCResItemUpdate *up = rc_resItem_get_latest_update (pkg); */
+ /* if (up) { */
+ /* if (match->importance_gteq ? up->importance > match->importance */
+ /* : up->importance < match->importance) */
+ /* return FALSE; */
+ /* } */
+ /* } */
+ CapFactory factory;
+ Capability dependency;
+ bool check;
+
+ dependency = factory.parse ( resItem->kind(),
+ resItem->name(),
+ Rel::EQ,
+ resItem->edition(),
+ resItem->arch());
+ check = _dependency.matches (dependency);
+ return check;
}
///////////////////////////////////////////////////////////////////
private:
std::string _channel_id;
- constDependencyPtr _dependency;
+ Capability _dependency;
std::string _name_glob;
// GPatternSpec *_pattern_spec;
void setChannel (constChannelPtr channel) { _channel_id = channel->id(); }
void setChannelId (const std::string & channel_id) { _channel_id = channel_id; }
- constDependencyPtr dependency () const { return _dependency; }
- void setDependency (constDependencyPtr dependency) { _dependency = dependency; }
+ const Capability & dependency () const { return _dependency; }
+ void setDependency (const Capability & dependency) { _dependency = dependency; }
const std::string & glob () const { return _name_glob; }
void setGlob (const std::string & glob_str) { _name_glob = glob_str; }
constResItemPtr
- MultiWorld::findResItemWithConstraint (constChannelPtr channel, const char *name, constDependencyPtr constraint, bool is_and) const
+ MultiWorld::findResItemWithConstraint (constChannelPtr channel, const char *name, const Capability & constraint, bool is_and) const
{
constResItemPtr resItem;
for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) {
// iterater over resItems with dependency
int
- MultiWorld::foreachProvidingResItem (constDependencyPtr dep, ResItemAndSpecFn fn, void *data)
+ MultiWorld::foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) {
}
int
- MultiWorld::foreachRequiringResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data)
+ MultiWorld::foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) {
}
int
- MultiWorld::foreachConflictingResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data)
+ MultiWorld::foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) {
#include <zypp/solver/detail/ServiceWorldPtr.h>
#include <zypp/solver/detail/World.h>
#include <zypp/solver/detail/Pending.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
virtual constResItemPtr findInstalledResItem (constResItemPtr resItem);
virtual constResItemPtr findResItem (constChannelPtr channel, const char *name) const;
- virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, constDependencyPtr constraint, bool is_and) const;
+ virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, const Capability & constraint, bool is_and) const;
// Iterate over resItems
// Iterate across provides or requirement
- virtual int foreachProvidingResItem (constDependencyPtr dep, ResItemAndSpecFn fn, void *data);
- virtual int foreachRequiringResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data);
- virtual int foreachConflictingResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
// locks
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* OrDependency.cc
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * Definition of 'or dependency'
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include <y2util/stringutil.h>
-
-#include <zypp/solver/detail/OrDependency.h>
-#include <zypp/solver/detail/Dependency.h>
-
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- using namespace std;
-
- IMPL_BASE_POINTER(OrDependency);
-
- OrDependency::OrDependencyTable OrDependency::_or_dep_table;
-
- //---------------------------------------------------------------------------
-
- string
- OrDependency::asString ( void ) const
- {
- return toString (*this);
- }
-
-
- string
- OrDependency::toString ( const OrDependency & dependency )
- {
- string res ("<ordependency/>");
-
- return res;
- }
-
-
- ostream &
- OrDependency::dumpOn( ostream & str ) const
- {
- str << asString();
- return str;
- }
-
-
- ostream&
- operator<<( ostream & os, const OrDependency & dependency)
- {
- return os << dependency.asString();
- }
-
- //---------------------------------------------------------------------------
-
- OrDependency::OrDependency (string & dep, const CDependencyList & split_ors)
- : _or_dep (dep)
- , _split_ors (split_ors)
- , _ref(1)
- {
- }
-
-
- OrDependency::OrDependency (constXmlNodePtr node)
- {
- }
-
-
- OrDependency::~OrDependency()
- {
- }
-
-
- //---------------------------------------------------------------------------
-
- OrDependencyPtr
- OrDependency::fromDependencyList (const CDependencyList & deplist)
- {
- string depstr = dependencyListToString(deplist);
-
- OrDependencyTable::iterator pos = _or_dep_table.find(depstr);
- if (pos != _or_dep_table.end()) {
- (*pos).second->incRef();
- return (*pos).second;
- }
-
- OrDependencyPtr or_dep = new OrDependency (depstr, deplist);
- _or_dep_table[depstr] = or_dep;
- return or_dep;
- }
-
-
- OrDependencyPtr
- OrDependency::fromString (const char *dep)
- {
- string depstr = string (dep);
-
- OrDependencyTable::iterator pos = _or_dep_table.find(depstr);
- if (pos != _or_dep_table.end()) {
- (*pos).second->incRef();
- return (*pos).second;
- }
-
- CDependencyList deplist = stringToDependencyList (dep);
- OrDependencyPtr or_dep = new OrDependency (depstr, deplist);
- _or_dep_table[depstr] = or_dep;
- return or_dep;
-
- }
-
-
- string
- OrDependency::dependencyListToString (const CDependencyList & deplist)
- {
- string str ("(||");
-
- for (CDependencyList::const_iterator dep = deplist.begin(); dep != deplist.end(); dep++) {
- if (dep != deplist.begin())
- str += "|";
-
- str += (*dep)->name();
-
- Rel relation = (*dep)->relation();
-
- if (relation != Rel::ANY) {
- str += "&";
- str += relation.asString();
- str += "&";
-
- if ((*dep)->epoch() >= 0) {
- str += stringutil::form("%d:", (*dep)->epoch());
- }
-
- str += (*dep)->version();
-
- string rel = (*dep)->release();
- if (!rel.empty()) {
- str += "-";
- str += rel;
- }
- }
-
- }
-
- str += ")";
-
- return str;
- }
-
-
- CDependencyList
- OrDependency::stringToDependencyList (const char *s)
- {
- const char *p, *zz;
- CDependencyList out_dep;
- bool have_more = true;
-
- if (strncmp (s, "(||", 3)) {
- fprintf (stderr, "'%s' is not a 'munged or' string!\n", s);
- return out_dep;
- }
-
- s += 3;
-
- zz = strchr (s, ')');
-
- if (!zz)
- return out_dep;
-
- /* s now points to the start of the first thing */
- do {
- char *z;
- SpecPtr spec;
- char *name;
- Rel relation = Rel::ANY;
- zypp::Edition edition;
-
- /* grab the name */
-
- z = strchr (s, '|');
- p = strchr (s, '&');
-
- if (!z) {
- have_more = false;
- }
- else {
- /* We don't want to get a p from a later element. */
- if (p > z)
- p = NULL;
- }
-
- name = strndup (s, p ? p - s : (z ? z - s : zz - s));
-
- if (p) {
- char *e;
- char op[4];
- char *vstr;
-
- /* We need to parse version things */
- p++;
- e = strchr (p, '&');
- if (!e || e-p > 3) {
- /* Bad. */
- fprintf (stderr, "Couldn't parse ver str [%s]\n", p);
- }
-
- /* text between p and e is an operator */
- strncpy (op, p, e - p);
- op[e - p] = 0;
- relation = Rel(op);
-
- e++;
- if (z) {
- p = z;
- } else {
- p = zz;
- }
-
- /* e .. p is the epoch:version-release */
- vstr = strndup (e, p - e);
-
- Edition edition(vstr);
-
- free ((void *)vstr);
-
- }
-
-
- DependencyPtr dep = new Dependency (name, relation, ResTraits<zypp::Package>::kind, NULL, edition );
-
- out_dep.push_back (dep);
- free ((void *)name);
-
- s = z + 1;
-
- if (p == zz)
- have_more = false;
- } while (have_more);
-
- return out_dep;
- }
-
-
- void
- OrDependency::addCreatedProvide (constDependencyPtr dep)
- {
- _created_provides.push_back (dep);
- }
-
-
- constDependencyPtr
- OrDependency::find (const char *dep)
- {
- string depstr (dep);
-
- OrDependencyTable::iterator pos = _or_dep_table.find(depstr);
- if (pos != _or_dep_table.end()) {
- return new Dependency ((*pos).second);
- }
-
- return NULL;
- }
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* OrDependency.h
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _OrDependency_h
-#define _OrDependency_h
-
-#include <list>
-#include <map>
-#include <iosfwd>
-#include <string.h>
-
-#include <y2util/Ustring.h>
-
-#include <zypp/solver/detail/OrDependencyPtr.h>
-#include <zypp/solver/detail/Dependency.h>
-#include <zypp/solver/detail/XmlNode.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : OrDependency
- /**
- *
- **/
-
- class OrDependency : public CountedRep {
- REP_BODY(OrDependency);
-
- private:
- typedef std::map<std::string, OrDependencyPtr> OrDependencyTable;
-
- static OrDependencyTable _or_dep_table;
-
- std::string _or_dep;
- CDependencyList _split_ors;
- CDependencyList _created_provides;
- int _ref;
-
- OrDependency (std::string & dep, const CDependencyList & split_ors);
-
- static std::string dependencyListToString (const CDependencyList & deplist);
- static CDependencyList stringToDependencyList (const char *s);
-
- void incRef() { _ref++; }
- void decRef() { _ref--; }
-
- public:
-
- OrDependency (constXmlNodePtr node);
-
- virtual ~OrDependency();
-
- // ---------------------------------- I/O
-
- const xmlNodePtr asXmlNode (void) const;
-
- static std::string toString ( const OrDependency & ordep );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- friend std::ostream& operator<<( std::ostream&, const OrDependency & ordep );
-
- std::string asString ( void ) const;
-
- // ---------------------------------- accessors
-
- const char *name (void) const { return _or_dep.c_str(); }
- void addCreatedProvide (constDependencyPtr dep);
-
- // ---------------------------------- methods
-
- static OrDependencyPtr fromDependencyList (const CDependencyList & deplist);
- static OrDependencyPtr fromString (const char *dep);
- static constDependencyPtr find (const char *dep);
- };
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-#endif // _OrDependency_h
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* OrDependencyPtr.h
- *
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _OrDependencyPtr_h
-#define _OrDependencyPtr_h
-
-#include <y2util/RepDef.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- // CLASS NAME : OrDependencyPtr
- // CLASS NAME : constOrDependencyPtr
- ///////////////////////////////////////////////////////////////////
- DEFINE_BASE_POINTER(OrDependency);
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _DependencyPtr_h
#include <zypp/Package.h>
#include <zypp/detail/PackageImpl.h>
#include <zypp/solver/detail/PackageUpdate.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/World.h>
#include <zypp/solver/detail/XmlNode.h>
+#include <zypp/CapFactory.h>
+#include <zypp/CapSet.h>
+
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
IMPL_DERIVED_POINTER(Package,ResItem);
struct DepTable {
- CDependencyList requires;
- CDependencyList provides;
- CDependencyList conflicts;
- CDependencyList obsoletes;
- CDependencyList children;
- CDependencyList suggests;
- CDependencyList recommends;
+ CapSet requires;
+ CapSet provides;
+ CapSet conflicts;
+ CapSet obsoletes;
+ CapSet children;
+ CapSet suggests;
+ CapSet recommends;
};
//---------------------------------------------------------------------------
+
+ static Capability
+ parseXmlDep (constXmlNodePtr node) {
+ const char *tmp;
+ string epoch,version,release,name = "";
+ Arch arch = Arch_noarch;
+ Rel relation;
+ CapFactory factory;
+
+ if (!node->equals("dep")) {
+ fprintf (stderr, "parseXmlDep bad node\n");
+ abort();
+ }
+
+ name = node->getProp ("name");
+ tmp = node->getProp ("op", NULL);
+ if (tmp) {
+ relation = Rel(tmp);
+ epoch = node->getIntValueDefault ("epoch", Edition::noepoch);
+ version = node->getProp ("version");
+ release = node->getProp ("release");
+ }
+ tmp = node->getProp ("arch", NULL);
+ if (tmp) {
+ arch = Arch(node->getProp ("arch"));
+ } else {
+ arch = Arch();
+ }
+
+ return factory.parse ( ResTraits<zypp::Package>::kind,
+ name,
+ relation,
+ Edition (version, release, epoch),
+ arch);
+ }
+
static void
extract_dep_info (constXmlNodePtr iter, struct DepTable & dep_table)
{
continue;
}
- dep_table.requires.push_back(new Dependency (iter2));
+ dep_table.requires.insert(parseXmlDep (iter2));
iter2 = iter2->next();
}
continue;
}
- dep_table.recommends.push_back (new Dependency (iter2));
+ dep_table.recommends.insert (parseXmlDep (iter2));
iter2 = iter2->next();
}
continue;
}
- dep_table.suggests.push_back (new Dependency (iter2));
+ dep_table.suggests.insert (parseXmlDep (iter2));
iter2 = iter2->next();
}
continue;
}
- DependencyPtr dep = new Dependency (iter2);
+ Capability dep = parseXmlDep(iter2);
if (! all_are_obs) {
this_is_obs = false;
}
if (all_are_obs || this_is_obs) {
- dep_table.obsoletes.push_back (dep);
+ dep_table.obsoletes.insert (dep);
} else {
- dep_table.conflicts.push_back (dep);
+ dep_table.conflicts.insert (dep);
}
iter2 = iter2->next();
continue;
}
- dep_table.obsoletes.push_back (new Dependency (iter2));
+ dep_table.obsoletes.insert (parseXmlDep (iter2));
iter2 = iter2->next();
}
continue;
}
- dep_table.provides.push_back (new Dependency (iter2));
+ dep_table.provides.insert (parseXmlDep (iter2));
iter2 = iter2->next();
}
continue;
}
- dep_table.children.push_back (new Dependency (iter2));
+ dep_table.children.insert (parseXmlDep (iter2));
iter2 = iter2->next();
}
}
// treat them as normal requires
//
#warning Children are handled as requires
- CDependencyList::const_iterator iter;
+ CapSet::const_iterator iter;
for (iter = dep_table.children.begin(); iter != dep_table.children.end(); iter++)
{
- dep_table.requires.push_back (*iter);
+ dep_table.requires.insert (*iter);
}
}
// check if we're already listed in the provides
// if not, provide ourself
-
- CDependencyList::const_iterator piter;
+ CapFactory factory;
+ Capability selfdep = factory.parse ( ResTraits<zypp::Package>::kind,
+ name,
+ Rel::EQ,
+ Edition( version, release, zypp::str::numstring(epoch)),
+ arch);
+
+
+ CapSet::const_iterator piter;
for (piter = dep_table.provides.begin(); piter != dep_table.provides.end(); piter++) {
- if ((*piter)->relation() == Rel::EQ
- && ((*piter)->name() == name))
+ if ((*piter) == selfdep)
{
break;
}
}
if (piter == dep_table.provides.end()) { // no self provide found, construct one
- constDependencyPtr selfdep = new Dependency (name, Rel::EQ, ResTraits<zypp::Package>::kind, this->channel(), Edition( version, release, zypp::str::numstring(epoch) ));
- if (getenv ("RC_SPEW")) fprintf (stderr, "Adding self-provide [%s]\n", selfdep->asString().c_str());
- dep_table.provides.push_front (selfdep);
+ if (getenv ("RC_SPEW")) fprintf (stderr, "Adding self-provide [%s]\n", selfdep.asString().c_str());
+ dep_table.provides.insert (selfdep);
}
- setRequires (dep_table.requires);
- setProvides (dep_table.provides);
- setConflicts (dep_table.conflicts);
- setObsoletes (dep_table.obsoletes);
- setSuggests (dep_table.suggests);
- setRecommends (dep_table.recommends);
-
+ Dependencies deps;
+ deps.setRequires (dep_table.requires);
+ deps.setProvides (dep_table.provides);
+ deps.setConflicts (dep_table.conflicts);
+ deps.setObsoletes (dep_table.obsoletes);
+ deps.setSuggests (dep_table.suggests);
+ deps.setRecommends (dep_table.recommends);
+ setDependencies (deps);
+
if (!_history.empty()) {
/* If possible, we grab the version info from the most
version = update->package()->version();
release = update->package()->release();
- } else {
+ }
+#if 0 //Is this really needed ?
+ else {
/* Otherwise, try to find where the package provides itself,
and use that version info. */
if (!provides().empty())
- for (CDependencyList::const_iterator iter = provides().begin(); iter != provides().end(); iter++) {
+ for (CapSet::const_iterator iter = provides().begin(); iter != provides().end(); iter++) {
if ((*iter)->relation() == Rel::EQ &&
((*iter)->name() == name))
{
}
}
}
+#endif
Edition _edition( version, release, zypp::str::numstring(epoch) );
shared_ptr<zypp::detail::PackageImpl> pkgImpl;
#include <zypp/solver/detail/ResolverContextPtr.h>
#include <zypp/solver/detail/ResolverInfo.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
/////////////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/QueueItemBranchPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
/////////////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/ResolverInfoConflictsWith.h>
#include <zypp/solver/detail/ResolverInfoMisc.h>
#include <zypp/solver/detail/ResolverInfoObsoletes.h>
+#include <zypp/CapFactory.h>
+#include <zypp/CapSet.h>
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
QueueItemConflict::toString ( const QueueItemConflict & item)
{
string res = "[Conflict: ";
- res += item._dep->asString();
+ res += item._dep.asString();
res += ", Triggered by ";
res += item._conflicting_resItem->asString();
if (item._actually_an_obsolete) res += ", Obsolete !";
//---------------------------------------------------------------------------
- QueueItemConflict::QueueItemConflict (WorldPtr world, constDependencyPtr dep, constResItemPtr resItem)
+ QueueItemConflict::QueueItemConflict (WorldPtr world, const Capability & dep, constResItemPtr resItem)
: QueueItem (QUEUE_ITEM_TYPE_CONFLICT, world)
, _dep (dep)
, _conflicting_resItem (resItem)
static bool
- upgrade_candidates_cb (constResItemPtr resItem, constSpecPtr spec, void *data)
+ upgrade_candidates_cb (constResItemPtr resItem, const Capability & cap, void *data)
{
- //fprintf (stderr, "upgrade_candidates_cb(%s,%s)\n", resItem->asString().c_str(), spec->asString().c_str());
+ //fprintf (stderr, "upgrade_candidates_cb(%s,%s)\n", resItem->asString().c_str(), cap.asString().c_str());
UpgradeCandidateInfo *info = (UpgradeCandidateInfo *)data;
if (info->context->getStatus (resItem) == RESOLVABLE_STATUS_UNINSTALLED) {
info->upgrades.push_back (resItem);
typedef struct {
WorldPtr world;
constResItemPtr conflicting_resItem;
- constDependencyPtr dep;
+ const Capability dep;
ResolverContextPtr context;
QueueItemList & new_items;
static bool
- conflict_process_cb (constResItemPtr resItem, constSpecPtr spec, void *data)
+ conflict_process_cb (constResItemPtr resItem, const Capability & cap, void *data)
{
ConflictProcessInfo *info = (ConflictProcessInfo *)data;
ResItemStatus status;
- string pkg_str, spec_str, msg;
+ string pkg_str, cap_str, msg;
ResolverInfoPtr log_info;
+ CapFactory factory;
- if (getenv ("RC_SPEW")) fprintf (stderr, "conflict_process_cb (resolvable[%s], spec[%s], info [%s]\n", resItem->asString().c_str(), spec->asString().c_str(), info->conflicting_resItem->asString().c_str());
- if (getenv ("RC_SPEW")) fprintf (stderr, "conflict_process_cb (resolvable equals spec: %s, info->dep [%s]\n", resItem->equals(spec->kind(), spec->name(), spec->edition()) ? "YES" : "NO", info->dep->asString().c_str());
+ if (getenv ("RC_SPEW")) fprintf (stderr, "conflict_process_cb (resolvable[%s], cap[%s], info [%s]\n", resItem->asString().c_str(), cap.asString().c_str(), info->conflicting_resItem->asString().c_str());
+ if (getenv ("RC_SPEW")) fprintf (stderr, "conflict_process_cb (info->dep [%s]\n", info->dep.asString().c_str());
/* We conflict with ourself. For the purpose of installing ourself, we
* just ignore it, but it's Debian's way of saying that one and only one
* resItem with this provide may exist on the system at a time. */
if (info->conflicting_resItem
- && resItem->equals (info->conflicting_resItem)) {
- return true;
+ && resItem->equals (info->conflicting_resItem)) {
+ return true;
}
/* FIXME: This should probably be a GVersion capability. */
* as the resItem that's providing it. This, of course, only
* applies to RPM, since it's the only one with obsoletes right
* now. */
+ Capability capTest = factory.parse ( resItem->kind(),
+ resItem->name(),
+ Rel::EQ,
+ resItem->edition(),
+ resItem->arch());
if (info->actually_an_obsolete
- && !(resItem->equals(spec->kind(), spec->name(), spec->edition())))
+ && capTest != cap)
{
- return true;
+ return true;
}
pkg_str = resItem->asString();
- spec_str = spec->asString();
+ cap_str = cap.asString();
status = info->context->getStatus (resItem);
switch (status) {
- case RESOLVABLE_STATUS_INSTALLED:
- case RESOLVABLE_STATUS_TO_BE_INSTALLED_SOFT: {
- QueueItemUninstallPtr uninstall;
- ResolverInfoPtr log_info;
+ case RESOLVABLE_STATUS_INSTALLED:
+ case RESOLVABLE_STATUS_TO_BE_INSTALLED_SOFT: {
+ QueueItemUninstallPtr uninstall;
+ ResolverInfoPtr log_info;
- #if PHI
- // maybe an upgrade can resolve the conflict ?
- // check if other resItem is available which upgrades
+#if PHI
+ // maybe an upgrade can resolve the conflict ?
+ // check if other resItem is available which upgrades
- // find non-installed packages which provide the conflicting name
+ // find non-installed packages which provide the conflicting name
- UpgradeCandidateInfo upgrade_info;
- upgrade_info.context = info->context;
+ UpgradeCandidateInfo upgrade_info;
+ upgrade_info.context = info->context;
- DependencyPtr maybe_upgrade_dep = new Dependency (resItem->name(), Rel::ANY, ResTraits<zypp::Package>::kind, new Channel (CHANNEL_TYPE_NONSYSTEM), Edition::noepoch);
- info->world->foreachProvidingResItem (maybe_upgrade_dep, upgrade_candidates_cb, (void *)&upgrade_info);
+ Capability maybe_upgrade_dep = factory.parse ( resItem->kind(),
+ resItem->name(),
+ Rel::ANY,
+ Edition::noepoch,
+ resItem->arch());
+
+ info->world->foreachProvidingResItem (maybe_upgrade_dep, upgrade_candidates_cb, (void *)&upgrade_info);
- #endif
+#endif
- uninstall = new QueueItemUninstall (info->world, resItem, "conflict");
- uninstall->setDependency (info->dep);
+ uninstall = new QueueItemUninstall (info->world, resItem, "conflict");
+ uninstall->setDependency (info->dep);
- if (info->actually_an_obsolete) {
- uninstall->setDueToObsolete ();
- log_info = new ResolverInfoObsoletes (resItem, info->conflicting_resItem);
- } else {
- uninstall->setDueToConflict ();
- log_info = new ResolverInfoConflictsWith (resItem, info->conflicting_resItem);
- }
+ if (info->actually_an_obsolete) {
+ uninstall->setDueToObsolete ();
+ log_info = new ResolverInfoObsoletes (resItem, info->conflicting_resItem);
+ } else {
+ uninstall->setDueToConflict ();
+ log_info = new ResolverInfoConflictsWith (resItem, info->conflicting_resItem);
+ }
- uninstall->addInfo (log_info);
+ uninstall->addInfo (log_info);
- #if PHI
- if (upgrade_info.upgrades.empty ()) {
- #endif
+#if PHI
+ if (upgrade_info.upgrades.empty ()) {
+#endif
- info->new_items.push_back (uninstall);
+ info->new_items.push_back (uninstall);
- #if PHI
- }
- else {
- // there are upgrade candidates for the conflicting resItem
- // branch to: 1. uninstall, 2. upgrade (for each upgrading resItem)
+#if PHI
+ }
+ else {
+ // there are upgrade candidates for the conflicting resItem
+ // branch to: 1. uninstall, 2. upgrade (for each upgrading resItem)
- QueueItemBranchPtr branch = new QueueItemBranch (info->world);
+ QueueItemBranchPtr branch = new QueueItemBranch (info->world);
- branch->addItem (uninstall); // try uninstall
+ branch->addItem (uninstall); // try uninstall
- for (CResItemList::const_iterator iter = upgrade_info.upgrades.begin(); iter != upgrade_info.upgrades.end(); iter++) {
- QueueItemInstallPtr upgrade = new QueueItemInstall (info->world, *iter);
- upgrade->setUpgrades (resItem);
- branch->addItem (upgrade); // try upgrade
- }
- info->new_items.push_back (branch);
- }
- #endif
+ for (CResItemList::const_iterator iter = upgrade_info.upgrades.begin(); iter != upgrade_info.upgrades.end(); iter++) {
+ QueueItemInstallPtr upgrade = new QueueItemInstall (info->world, *iter);
+ upgrade->setUpgrades (resItem);
+ branch->addItem (upgrade); // try upgrade
+ }
+ info->new_items.push_back (branch);
+ }
+#endif
- break;
- }
+ break;
+ }
- case RESOLVABLE_STATUS_TO_BE_INSTALLED: {
- msg = string ("A conflict over ") + info->dep_str + " (" + spec_str + ") requires the removal of the to-be-installed resolvable " + pkg_str;
+ case RESOLVABLE_STATUS_TO_BE_INSTALLED: {
+ msg = string ("A conflict over ") + info->dep_str + " (" + cap_str + ") requires the removal of the to-be-installed resolvable " + pkg_str;
- ResolverInfoMiscPtr misc_info = new ResolverInfoMisc (resItem,RESOLVER_INFO_PRIORITY_VERBOSE, msg);
+ ResolverInfoMiscPtr misc_info = new ResolverInfoMisc (resItem,RESOLVER_INFO_PRIORITY_VERBOSE, msg);
- misc_info->flagAsError ();
- if (info->conflicting_resItem) {
- misc_info->addRelatedResItem (info->conflicting_resItem);
- }
- info->context->addInfo (misc_info);
+ misc_info->flagAsError ();
+ if (info->conflicting_resItem) {
+ misc_info->addRelatedResItem (info->conflicting_resItem);
+ }
+ info->context->addInfo (misc_info);
- break;
- }
+ break;
+ }
- case RESOLVABLE_STATUS_UNINSTALLED: {
- info->context->setStatus (resItem, RESOLVABLE_STATUS_TO_BE_UNINSTALLED);
- msg = string ("Marking ") + pkg_str + " as uninstallable due to conflicts over " + info->dep_str + " (" + spec_str + ")";
- if (!(info->pkg_str.empty())) {
- msg += " from ";
- msg += info->pkg_str;
- }
+ case RESOLVABLE_STATUS_UNINSTALLED: {
+ info->context->setStatus (resItem, RESOLVABLE_STATUS_TO_BE_UNINSTALLED);
+ msg = string ("Marking ") + pkg_str + " as uninstallable due to conflicts over " + info->dep_str + " (" + cap_str + ")";
+ if (!(info->pkg_str.empty())) {
+ msg += " from ";
+ msg += info->pkg_str;
+ }
- ResolverInfoMiscPtr misc_info = new ResolverInfoMisc (NULL, RESOLVER_INFO_PRIORITY_VERBOSE, msg);
+ ResolverInfoMiscPtr misc_info = new ResolverInfoMisc (NULL, RESOLVER_INFO_PRIORITY_VERBOSE, msg);
- misc_info->addRelatedResItem (resItem);
- if (info->conflicting_resItem) {
- misc_info->addRelatedResItem(info->conflicting_resItem);
- }
- info->context->addInfo (misc_info);
+ misc_info->addRelatedResItem (resItem);
+ if (info->conflicting_resItem) {
+ misc_info->addRelatedResItem(info->conflicting_resItem);
+ }
+ info->context->addInfo (misc_info);
- break;
- }
+ break;
+ }
- case RESOLVABLE_STATUS_TO_BE_UNINSTALLED:
- case RESOLVABLE_STATUS_TO_BE_UNINSTALLED_DUE_TO_OBSOLETE:
- /* This is the easy case -- we do nothing. */
- break;
+ case RESOLVABLE_STATUS_TO_BE_UNINSTALLED:
+ case RESOLVABLE_STATUS_TO_BE_UNINSTALLED_DUE_TO_OBSOLETE:
+ /* This is the easy case -- we do nothing. */
+ break;
- default:
- abort();
+ default:
+ abort();
}
return true;
info.pkg_str = _conflicting_resItem->asString();
}
- if (_dep->relation().asString() != "ANY")
- {
- info.dep_str = _dep->relation().asString() + " " + ((constSpecPtr)_dep)->asString();
- }
- else
- {
- info.dep_str = " " + ((constSpecPtr)_dep)->asString();
- }
+ info.dep_str = _dep.asString();
world()->foreachProvidingResItem (_dep, conflict_process_cb, (void *)&info);
{
int cmp = this->compare (item); // assures equal type
if (cmp != 0)
- return cmp;
+ return cmp;
constQueueItemConflictPtr conflict = item;
- cmp = Spec::compare ((constSpecPtr) _dep, ((constSpecPtr)(conflict->dependency())));
- if (cmp)
- return cmp;
-
- return _dep->relation() == conflict->dependency()->relation();
+ if ( _dep != conflict->dependency())
+ cmp = -1;
+
+ return cmp;
}
///////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/QueueItemConflictPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
REP_BODY(QueueItemConflict);
private:
- constDependencyPtr _dep;
+ const Capability _dep;
constResItemPtr _conflicting_resItem;
bool _actually_an_obsolete;
public:
- QueueItemConflict (WorldPtr world, constDependencyPtr dep, constResItemPtr resItem);
+ QueueItemConflict (WorldPtr world, const Capability & dep, constResItemPtr resItem);
virtual ~QueueItemConflict();
// ---------------------------------- I/O
// ---------------------------------- accessors
- constDependencyPtr dependency (void) const { return _dep; }
+ const Capability & dependency (void) const { return _dep; }
bool actuallyAnObsolete (void) const { return _actually_an_obsolete; }
void setActuallyAnObsolete (void) { _actually_an_obsolete = true; }
#include <zypp/solver/detail/QueueItemGroupPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
/////////////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/ResItem.h>
#include <zypp/solver/detail/World.h>
#include <zypp/solver/detail/ResItemAndDependency.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
string ret = "[Install: ";
ret += item._resItem->asString();
if (item._upgrades != NULL) {
- ret += ", Upgrades ";
- ret += item._upgrades->asString();
+ ret += ", Upgrades ";
+ ret += item._upgrades->asString();
}
if (!item._deps_satisfied_by_this_install.empty()) {
- ret += ", Satisfies ";
- ret += Dependency::toString(item._deps_satisfied_by_this_install);
+ ret += ", Satisfies [";
+ for (CapSet::const_iterator iter = item._deps_satisfied_by_this_install.begin();
+ iter != item._deps_satisfied_by_this_install.end(); iter++) {
+ if (iter != item._deps_satisfied_by_this_install.begin()) ret += ", ";
+ ret += (*iter).asString();
+ }
+ ret += "]";
}
if (!item._needed_by.empty()) {
- ret += ", Needed by ";
- ret += ResItem::toString(item._needed_by);
+ ret += ", Needed by ";
+ ret += ResItem::toString(item._needed_by);
}
if (item._explicitly_requested) ret += ", Explicit !";
ret += "]";
// Handle system resItem's that conflict with us -> uninstall them
static bool
- build_conflict_list (constResItemPtr resItem, constDependencyPtr dep, void *data)
+ build_conflict_list (constResItemPtr resItem, const Capability & dep, void *data)
{
CResItemList *rl = (CResItemList *)data;
rl->push_front (resItem);
string msg;
ResItemStatus status = context->getStatus (resItem);
- CDependencyList deps;
+ CapSet deps;
CResItemList conflicts;
/* If we are trying to upgrade resItem A with resItem B and they both have the
/* Construct require items for each of the resItem's requires that is still unsatisfied. */
deps = resItem->requires();
- for (CDependencyList::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
- constDependencyPtr dep = *iter;
+ for (CapSet::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
+ const Capability dep = *iter;
if (!context->requirementIsMet (dep, false)) {
- if (getenv("RC_SPEW")) fprintf (stderr, "this requires %s\n", dep->asString().c_str());
+ if (getenv("RC_SPEW")) fprintf (stderr, "this requires %s\n", dep.asString().c_str());
QueueItemRequirePtr req_item = new QueueItemRequire (world(), dep);
req_item->addResItem (resItem);
qil.push_front (req_item);
/* Construct conflict items for each of the resItem's conflicts. */
deps = resItem->conflicts();
- for (CDependencyList::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
- constDependencyPtr dep = *iter;
- if (getenv("RC_SPEW")) fprintf (stderr, "this conflicts with '%s'\n", dep->asString().c_str());
+ for (CapSet::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
+ const Capability dep = *iter;
+ if (getenv("RC_SPEW")) fprintf (stderr, "this conflicts with '%s'\n", dep.asString().c_str());
QueueItemConflictPtr conflict_item = new QueueItemConflict (world(), dep, resItem);
qil.push_front (conflict_item);
}
/* Construct conflict items for each of the resItem's obsoletes. */
deps = resItem->obsoletes();
- for (CDependencyList::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
- constDependencyPtr dep = *iter;
- if (getenv("RC_SPEW")) fprintf (stderr, "this obsoletes %s\n", dep->asString().c_str());
+ for (CapSet::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
+ const Capability dep = *iter;
+ if (getenv("RC_SPEW")) fprintf (stderr, "this obsoletes %s\n", dep.asString().c_str());
QueueItemConflictPtr conflict_item = new QueueItemConflict (world(), dep, resItem);
conflict_item->setActuallyAnObsolete();
qil.push_front (conflict_item);
/* Construct uninstall items for system resItem's that conflict with us. */
deps = resItem->provides();
- for (CDependencyList::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
- constDependencyPtr dep = *iter;
+ for (CapSet::const_iterator iter = deps.begin(); iter != deps.end(); iter++) {
+ const Capability dep = *iter;
world()->foreachConflictingResItem (dep, build_conflict_list, &conflicts);
}
((QueueItemPtr)new_install)->copy((constQueueItemPtr)this);
new_install->_upgrades = _upgrades;
- new_install->_deps_satisfied_by_this_install = CDependencyList(_deps_satisfied_by_this_install.begin(), _deps_satisfied_by_this_install.end());
+ new_install->_deps_satisfied_by_this_install = CapSet(_deps_satisfied_by_this_install.begin(), _deps_satisfied_by_this_install.end());
new_install->_needed_by = CResItemList (_needed_by.begin(), _needed_by.end());
new_install->_channel_priority = _channel_priority;
new_install->_other_penalty = _other_penalty;
//---------------------------------------------------------------------------
void
- QueueItemInstall::addDependency (constDependencyPtr dep)
+ QueueItemInstall::addDependency (const Capability & dep)
{
- _deps_satisfied_by_this_install.push_front (dep);
+ _deps_satisfied_by_this_install.insert (dep);
}
#include <zypp/solver/detail/QueueItemInstallPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
private:
constResItemPtr _resItem;
constResItemPtr _upgrades;
- CDependencyList _deps_satisfied_by_this_install;
+ CapSet _deps_satisfied_by_this_install;
CResItemList _needed_by;
int _channel_priority;
int _other_penalty;
virtual bool isRedundant (ResolverContextPtr context) const { return false; }
virtual bool isSatisfied (ResolverContextPtr context) const;
- void addDependency (constDependencyPtr dep);
- void addNeededBy (constResItemPtr resItem);
+ void addDependency (const Capability & dep);
+ void addNeededBy (const constResItemPtr resItem);
};
#include <zypp/solver/detail/ResolverInfoMisc.h>
#include <zypp/solver/detail/ResolverInfoNeededBy.h>
#include <zypp/solver/detail/World.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
QueueItemRequire::toString ( const QueueItemRequire & item)
{
string ret = "[Require: ";
- ret += item._dep->asString();
+ ret += item._dep.asString();
if (item._requiring_resItem != NULL) {
ret += ", Required by ";
ret += item._requiring_resItem->asString();
//---------------------------------------------------------------------------
- QueueItemRequire::QueueItemRequire (WorldPtr world, constDependencyPtr dep)
+ QueueItemRequire::QueueItemRequire (WorldPtr world, const Capability & dep)
: QueueItem (QUEUE_ITEM_TYPE_REQUIRE, world)
, _dep (dep)
, _requiring_resItem (NULL)
typedef struct {
constResItemPtr resItem;
- constSpecPtr dep;
+ const Capability *dep;
ResolverContextPtr context;
WorldPtr world;
CResItemList providers;
static bool
- require_process_cb (constResItemPtr resItem, constSpecPtr spec, void *data)
+ require_process_cb (constResItemPtr resItem, const Capability & cap, void *data)
{
RequireProcessInfo *info = (RequireProcessInfo *)data;
ResItemStatus status;
status = info->context->getStatus (resItem);
- //fprintf (stderr, "require_process_cb(res: %s, spec %s, status %s)\n", resItem->asString().c_str(), spec->asString().c_str(), ResolverContext::toString(status).c_str());
+ //fprintf (stderr, "require_process_cb(res: %s, spec %s, status %s)\n", resItem->asString().c_str(), cap.asString().c_str(), ResolverContext::toString(status).c_str());
//fprintf (stderr, "require_process_cb(info->dep: %s)\n", info->dep ? info->dep->asString().c_str() : "(null)");
//fprintf (stderr, "require_process_cb(resItemIsPossible -> %d)\n", info->context->resItemIsPossible (resItem));
/* info->dep is set for resItem set childern only. If it is set
allow only exactly required version */
if (info->dep != NULL
- && !info->dep->equals(spec)) {
+ && *(info->dep) != cap) {
return true;
}
static bool
- no_installable_providers_info_cb (constResItemPtr resItem, constSpecPtr spec, void *data)
+ no_installable_providers_info_cb (constResItemPtr resItem, const Capability & cap, void *data)
{
RequireProcessInfo *info = (RequireProcessInfo *)data;
ResItemStatus status;
status = info->context->getStatus (resItem);
if (resItem_status_is_to_be_uninstalled (status)) {
- msg_str = resItem->name() + " provides " + spec->asString() + ", but is scheduled to be uninstalled.";
+ msg_str = resItem->name() + " provides " + cap.asString() + ", but is scheduled to be uninstalled.";
} else if (info->context->isParallelInstall (resItem)) {
- msg_str = resItem->name() + " provides " + spec->asString() + ", but another version of that resItem is already installed.";
+ msg_str = resItem->name() + " provides " + cap.asString() + ", but another version of that resItem is already installed.";
} else if (! info->context->resItemIsPossible (resItem)) {
- msg_str = resItem->name() + " provides " + spec->asString() + ", but it is uninstallable. Try installing it on its own for more details.";
+ msg_str = resItem->name() + " provides " + cap.asString() + ", but it is uninstallable. Try installing it on its own for more details.";
} else if (info->world->resItemIsLocked (resItem)) {
- msg_str = resItem->name() + " provides " + spec->asString() + ", but it is locked.";
+ msg_str = resItem->name() + " provides " + cap.asString() + ", but it is locked.";
}
if (!msg_str.empty()) {
RequireProcessInfo info;
info.resItem = _requiring_resItem;
- info.dep = _is_child ? _dep : NULL;
+ info.dep = _is_child ? &_dep : NULL;
info.context = context;
info.world = world();
info.uniq = new UniqTable(); //FIXME: op: g_hash_table_new (rc_resItem_spec_hash, rc_resItem_spec_equal);
if (_upgraded_resItem == NULL) {
ResolverInfoPtr err_info;
- msg = string ("There are no ") + (_remove_only ? "alternative installed" : "installable") + " providers of " + _dep->asString();
+ msg = string ("There are no ") + (_remove_only ? "alternative installed" : "installable") + " providers of " + _dep.asString();
if (_requiring_resItem != NULL) {
msg += " for ";
msg += _requiring_resItem->asString();
req_str = _requiring_resItem->asString();
up_str = _upgraded_resItem->asString();
- label = string ("for requiring ") + _dep->asString() + " for " + req_str + " when upgrading " + up_str;
+ label = string ("for requiring ") + _dep.asString() + " for " + req_str + " when upgrading " + up_str;
branch_item->setLabel (label);
//fprintf (stderr, "Branching: %s\n", label.c_str());
for (CResItemList::const_iterator iter = upgrade_list.begin(); iter != upgrade_list.end(); iter++) {
// FIXME: should we also look at conflicts here?
if (explore_uninstall_branch) {
- CDependencyList requires = upgrade_resItem->requires();
- CDependencyList::const_iterator iter = requires.begin();
+ CapSet requires = upgrade_resItem->requires();
+ CapSet::const_iterator iter = requires.begin();
for (; iter != requires.end(); iter++) {
- constDependencyPtr req = *iter;
+ const Capability req = *iter;
if (! context->requirementIsMet (req, false)) {
break;
}
new_items.push_front (branch_item);
} else {
// We can't do anything to resolve the missing requirement, so we fail.
- string msg = string ("Can't satisfy requirement '") + _dep->asString() + "'";
+ string msg = string ("Can't satisfy requirement '") + _dep.asString() + "'";
context->addErrorString (NULL, msg);
}
{
int cmp = this->compare (item); // assures equal type
if (cmp != 0)
- return cmp;
+ return cmp;
constQueueItemRequirePtr require = item;
-
- cmp = Spec::compare ((constSpecPtr) _dep, ((constSpecPtr)(require->dependency())));
- if (cmp)
- return cmp;
-
- return _dep->relation() == require->dependency()->relation();
+
+ if (_dep != require->dependency())
+ {
+ cmp = -1;
+ }
+ return cmp;
}
///////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/QueueItemRequirePtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
+#include <zypp/Capability.h>
#include <zypp/solver/detail/Channel.h>
/////////////////////////////////////////////////////////////////////////
REP_BODY(QueueItemRequire);
private:
- constDependencyPtr _dep;
+ const Capability _dep;
constResItemPtr _requiring_resItem;
constResItemPtr _upgraded_resItem;
constResItemPtr _lost_resItem;
public:
- QueueItemRequire (WorldPtr world, constDependencyPtr dep);
+ QueueItemRequire (WorldPtr world, const Capability & dep);
virtual ~QueueItemRequire();
// ---------------------------------- I/O
// ---------------------------------- accessors
- constDependencyPtr dependency (void) const { return _dep; }
+ const Capability & dependency (void) const { return _dep; }
void setRemoveOnly (void) { _remove_only = true; }
void setUpgradedResItem (constResItemPtr upgraded_resItem) { _upgraded_resItem = upgraded_resItem; }
#include <zypp/solver/detail/ResolverContext.h>
#include <zypp/solver/detail/ResolverInfoMissingReq.h>
#include <zypp/solver/detail/World.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
static bool
- unlink_check_cb (constResItemPtr resItem, constDependencyPtr dep, void *data)
+ unlink_check_cb (constResItemPtr resItem, const Capability & dep, void *data)
{
UnlinkCheckInfo *info = (UnlinkCheckInfo *)data;
static bool
- uninstall_process_cb (constResItemPtr resItem, constDependencyPtr dep, void *data)
+ uninstall_process_cb (constResItemPtr resItem, const Capability & dep, void *data)
{
UninstallProcessInfo *info = (UninstallProcessInfo *)data;
info.context = context;
info.cancel_unlink = false;
- CDependencyList provides = _resItem->provides();
- for (CDependencyList::const_iterator iter = provides.begin(); iter != provides.end() && ! info.cancel_unlink; iter++) {
+ CapSet provides = _resItem->provides();
+ for (Capset::const_iterator iter = provides.begin(); iter != provides.end() && ! info.cancel_unlink; iter++) {
world()->foreachRequiringResItem (*iter, unlink_check_cb, &info);
}
context->addInfo (info);
}
- CDependencyList provides = _resItem->provides();
- for (CDependencyList::const_iterator iter = provides.begin(); iter != provides.end(); iter++) {
+ CapSet provides = _resItem->provides();
+ for (CapSet::const_iterator iter = provides.begin(); iter != provides.end(); iter++) {
UninstallProcessInfo info;
info.world = world();
#include <zypp/solver/detail/QueueItemUninstallPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
+#include <zypp/Capability.h>
#include <zypp/solver/detail/Channel.h>
/////////////////////////////////////////////////////////////////////////
private:
constResItemPtr _resItem;
const std::string _reason;
- constDependencyPtr _dep_leading_to_uninstall;
+ Capability _dep_leading_to_uninstall;
constResItemPtr _upgraded_to;
bool _explicitly_requested;
// ---------------------------------- accessors
- void setDependency (constDependencyPtr dep) { _dep_leading_to_uninstall = dep; }
+ void setDependency (const Capability & dep) { _dep_leading_to_uninstall = dep; }
void setExplicitlyRequested (void) { _explicitly_requested = true; }
void setRemoveOnly (void) { _remove_only = true; }
void setUpgradedTo (constResItemPtr resItem) { _upgraded_to = resItem; }
IMPL_BASE_POINTER(ResItem);
//---------------------------------------------------------------------------
-
+
+ string
+ capSetToString (const CapSet & dl)
+ {
+ string res("[");
+ for (CapSet::const_iterator iter = dl.begin(); iter != dl.end(); iter++) {
+ if (iter != dl.begin()) res += ", ";
+ res += (*iter).asString();
+ }
+ return res + "]";
+ }
+
+
string
ResItem::asString ( bool full ) const
{
if (!resItem.requires().empty()) {
res += ", Requires: ";
- res += Dependency::toString(resItem.requires());
+ res += capSetToString(resItem.requires());
}
if (!resItem.provides().empty()) {
res += ", Provides: ";
- res += Dependency::toString(resItem.provides());
+ res += capSetToString(resItem.provides());
}
if (!resItem.conflicts().empty()) {
res += ", Conflicts: ";
- res += Dependency::toString(resItem.conflicts());
+ res += capSetToString(resItem.conflicts());
}
if (!resItem.obsoletes().empty()) {
res += ", Obsoletes: ";
- res += Dependency::toString(resItem.obsoletes());
+ res += capSetToString(resItem.obsoletes());
}
if (!resItem.suggests().empty()) {
res += ", Suggests: ";
- res += Dependency::toString(resItem.suggests());
+ res += capSetToString(resItem.suggests());
}
if (!resItem.recommends().empty()) {
res += ", Recommends: ";
- res += Dependency::toString(resItem.recommends());
+ res += capSetToString(resItem.recommends());
}
if (!resItem.freshens().empty()) {
res += ", Freshens: ";
- res += Dependency::toString(resItem.freshens());
+ res += capSetToString(resItem.freshens());
}
return res;
}
#include <zypp/solver/detail/ResItemPtr.h>
#include <zypp/solver/detail/StoreWorldPtr.h>
-#include <zypp/solver/detail/Dependency.h>
+#include <zypp/CapSet.h>
#include <zypp/solver/detail/Channel.h>
#include <zypp/ResObject.h>
#include <zypp/Edition.h>
+#include <zypp/Dependencies.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
typedef bool (*ResItemFn) (ResItemPtr r, void *data);
typedef bool (*CResItemFn) (constResItemPtr r, void *data);
typedef bool (*ResItemPairFn) (constResItemPtr r1, constResItemPtr r2, void *data);
- typedef bool (*ResItemAndSpecFn) (constResItemPtr r, constSpecPtr spec, void *data);
- typedef bool (*ResItemAndDepFn) (constResItemPtr r, constDependencyPtr dep, void *data);
+ typedef bool (*ResItemAndDepFn) (constResItemPtr r, const Capability & dep, void *data);
///////////////////////////////////////////////////////////////////
//
size_t _file_size;
size_t _installed_size;
- CDependencyList _requires;
- CDependencyList _provides;
- CDependencyList _conflicts;
- CDependencyList _obsoletes;
-
- CDependencyList _suggests;
- CDependencyList _recommends;
- CDependencyList _freshens;
-
protected:
// ---------------------------------- accessors
size_t installedSize() const { return _installed_size; }
void setInstalledSize (size_t installed_size) { _installed_size = installed_size; }
- const CDependencyList & requires() const { return _requires; }
- void setRequires (const CDependencyList & requires) { _requires = requires; }
-
- const CDependencyList & provides() const { return _provides; }
- void setProvides (const CDependencyList & provides) { _provides = provides; }
-
- const CDependencyList & conflicts() const { return _conflicts; }
- void setConflicts (const CDependencyList & conflicts) { _conflicts = conflicts; }
-
- const CDependencyList & obsoletes() const { return _obsoletes; }
- void setObsoletes (const CDependencyList & obsoletes) { _obsoletes = obsoletes; }
-
- const CDependencyList & suggests() const { return _suggests; }
- void setSuggests (const CDependencyList & suggests) { _suggests = suggests; }
-
- const CDependencyList & recommends() const { return _recommends; }
- void setRecommends (const CDependencyList & recommends) { _recommends = recommends; }
-
- const CDependencyList & freshens() const { return _freshens; }
- void setFreshens (const CDependencyList & freshens) { _freshens = freshens; }
+ const CapSet & requires() const { return _resObject->deps().requires(); }
+ const CapSet & provides() const { return _resObject->deps().provides(); }
+ const CapSet & conflicts() const { return _resObject->deps().conflicts(); }
+ const CapSet & obsoletes() const { return _resObject->deps().obsoletes(); }
+ const CapSet & suggests() const { return _resObject->deps().suggests(); }
+ const CapSet & recommends() const { return _resObject->deps().recommends(); }
+ const CapSet & freshens() const { return _resObject->deps().freshens(); }
+
+ void setDependencies (const Dependencies & dependencies) { _resObject->setDeps(dependencies); }
+
// Spec definitions
//---------------------------------------------------------------------------
- ResItemAndDependency::ResItemAndDependency (constResItemPtr resItem, constDependencyPtr dependency)
+ ResItemAndDependency::ResItemAndDependency (constResItemPtr resItem, const Capability & dependency)
: _resItem(resItem)
, _dependency(dependency)
{
string res ("{");
res += r_and_d._resItem->asString(full);
res += ", ";
- res += r_and_d._dependency->asString();
+ res += r_and_d._dependency.asString();
res += "}";
return res;
}
/* FIXME: rc_resItem_dep_verify_relation already checks the channel */
bool
- ResItemAndDependency::verifyRelation (constDependencyPtr dep) const
+ ResItemAndDependency::verifyRelation (const Capability & dep) const
{
#if PHI
// don't check the channel, thereby honoring conflicts from installed resItems to to-be-installed resItems
- return dep->verifyRelation (_dependency);
+ return dep.matches (_dependency);
#else
- if (!dep->verifyRelation (_dependency)) {
+ if (!dep.matches (_dependency)) {
return false;
}
+#if 0
if (getenv ("SPEW_DEP")) fprintf (stderr, "ResItemAndDependency::verifyRelation _resItem->channel() %s, dep->channel() %s\n", _resItem->channel()->asString().c_str(), dep->channel()->asString().c_str());
return _resItem->channel()->equals (dep->channel());
+#else
+ return true;
+#endif
#endif
}
#include <zypp/solver/detail/ResItemAndDependencyPtr.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
private:
constResItemPtr _resItem;
- constDependencyPtr _dependency;
+ const Capability _dependency;
public:
- ResItemAndDependency (constResItemPtr resItem, constDependencyPtr dependency);
+ ResItemAndDependency (constResItemPtr resItem, const Capability & dependency);
~ResItemAndDependency () {}
// ---------------------------------- I/O
// ---------------------------------- accessors
constResItemPtr resItem() const { return _resItem; }
- constDependencyPtr dependency() const { return _dependency; }
+ const Capability & dependency() const { return _dependency; }
// ---------------------------------- methods
- bool verifyRelation (constDependencyPtr dep) const;
+ bool verifyRelation (const Capability & dep) const;
};
///////////////////////////////////////////////////////////////////
}
void
- Resolver::addExtraDependency (constDependencyPtr dependency)
+ Resolver::addExtraDependency (const Capability & dependency)
{
_extra_deps.push_front (dependency);
}
void
- Resolver::addExtraConflict (constDependencyPtr dependency)
+ Resolver::addExtraConflict (const Capability & dependency)
{
_extra_conflicts.push_front (dependency);
}
initial_queue->addResItemToVerify (*iter);
}
- for (CDependencyList::const_iterator iter = _extra_deps.begin(); iter != _extra_deps.end(); iter++) {
+ for (CapSet::const_iterator iter = _extra_deps.begin(); iter != _extra_deps.end(); iter++) {
initial_queue->addExtraDependency (*iter);
}
- for (CDependencyList::const_iterator iter = _extra_conflicts.begin(); iter != _extra_conflicts.end(); iter++) {
+ for (CapSet::const_iterator iter = _extra_conflicts.begin(); iter != _extra_conflicts.end(); iter++) {
initial_queue->addExtraConflict (*iter);
}
#include <zypp/solver/detail/ResolverPtr.h>
#include <zypp/solver/detail/ResolverQueue.h>
#include <zypp/solver/detail/ResItem.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
CResItemList _resItems_to_remove;
CResItemList _resItems_to_verify;
- CDependencyList _extra_deps;
- CDependencyList _extra_conflicts;
+ CapSet _extra_deps;
+ CapSet _extra_conflicts;
ResolverQueueList _pending_queues;
ResolverQueueList _pruned_queues;
void addResItemToVerify (constResItemPtr resItem);
- void addExtraDependency (constDependencyPtr dependency);
- void addExtraConflict (constDependencyPtr dependency);
+ void addExtraDependency (const CapSet & dependency);
+ void addExtraConflict (const CapSet & dependency);
void verifySystem (void);
void resolveDependencies (void);
#include <zypp/solver/detail/ResolverContext.h>
#include <zypp/solver/detail/ResolverInfoMisc.h>
#include <zypp/solver/detail/World.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
bool
- ResolverContext::requirementIsMet (constDependencyPtr dependency, bool is_child)
+ ResolverContext::requirementIsMet (const Capability & dependency, bool is_child)
{
RequirementMetInfo info;
bool
- ResolverContext::requirementIsPossible (constDependencyPtr dep)
+ ResolverContext::requirementIsPossible (const Capability & dep)
{
RequirementMetInfo info;
bool
ResolverContext::resItemIsPossible (constResItemPtr resItem)
{
- CDependencyList requires = resItem->requires();
- for (CDependencyList::iterator iter = requires.begin(); iter != requires.end(); iter++) {
+ CapSet requires = resItem->requires();
+ for (CapSet::iterator iter = requires.begin(); iter != requires.end(); iter++) {
if (! requirementIsPossible (*iter)) {
return false;
}
#include <zypp/solver/detail/ResolverInfo.h>
#include <zypp/solver/detail/ResItem.h>
#include <zypp/solver/detail/Channel.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
void spew (void);
void spewInfo (void);
- bool requirementIsMet (constDependencyPtr dep, bool is_child);
- bool requirementIsPossible (constDependencyPtr dep);
+ bool requirementIsMet (const Capability & dep, bool is_child);
+ bool requirementIsPossible (const Capability & dep);
bool resItemIsPossible (constResItemPtr resItem);
bool isParallelInstall (constResItemPtr resItem);
//---------------------------------------------------------------------------
- ResolverInfoMissingReq::ResolverInfoMissingReq (constResItemPtr resItem, constDependencyPtr missing_req)
+ ResolverInfoMissingReq::ResolverInfoMissingReq (constResItemPtr resItem, const Capability & missing_req)
: ResolverInfo (RESOLVER_INFO_TYPE_MISSING_REQ, resItem, RESOLVER_INFO_PRIORITY_USER)
, _missing_req (missing_req)
{
#include <zypp/solver/detail/ResolverInfoMissingReqPtr.h>
#include <zypp/solver/detail/ResolverInfo.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
private:
- constDependencyPtr _missing_req;
+ const Capability _missing_req;
public:
- ResolverInfoMissingReq (constResItemPtr resItem, constDependencyPtr missing_req);
+ ResolverInfoMissingReq (constResItemPtr resItem, const Capability & missing_req);
virtual ~ResolverInfoMissingReq();
// ---------------------------------- I/O
#include <zypp/solver/detail/QueueItemRequire.h>
#include <zypp/solver/detail/QueueItemUninstall.h>
#include <zypp/solver/detail/ResolverContext.h>
+#include <zypp/CapSet.h>
#include <y2util/stringutil.h>
world = _context->world ();
- CDependencyList requires = resItem->requires();
- for (CDependencyList::const_iterator iter = requires.begin(); iter != requires.end(); iter++) {
+ CapSet requires = resItem->requires();
+ for (CapSet::const_iterator iter = requires.begin(); iter != requires.end(); iter++) {
QueueItemRequirePtr item = new QueueItemRequire (world, *iter);
item->addResItem (resItem);
addItem (item);
}
- CDependencyList conflicts = resItem->conflicts();
- for (CDependencyList::const_iterator iter = conflicts.begin(); iter != conflicts.end(); iter++) {
+ CapSet conflicts = resItem->conflicts();
+ for (CapSet::const_iterator iter = conflicts.begin(); iter != conflicts.end(); iter++) {
QueueItemConflictPtr item = new QueueItemConflict (world, *iter, resItem);
addItem (item);
}
void
- ResolverQueue::addExtraDependency (constDependencyPtr dep)
+ ResolverQueue::addExtraDependency (const Capability & dep)
{
QueueItemRequirePtr item = new QueueItemRequire (_context->world(), dep);
addItem (item);
void
- ResolverQueue::addExtraConflict (constDependencyPtr dep)
+ ResolverQueue::addExtraConflict (const Capability & dep)
{
QueueItemConflictPtr item = new QueueItemConflict (_context->world(), dep, NULL);
addItem (item);
#include <zypp/solver/detail/ResolverContextPtr.h>
#include <zypp/solver/detail/QueueItem.h>
#include <zypp/solver/detail/ResItemPtr.h>
-#include <zypp/solver/detail/DependencyPtr.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
void addResItemToInstall (constResItemPtr resItem);
void addResItemToRemove (constResItemPtr resItem, bool remove_only_mode);
void addResItemToVerify (constResItemPtr resItem);
- void addExtraDependency (constDependencyPtr dep);
- void addExtraConflict (constDependencyPtr dep);
+ void addExtraDependency (const Capability & dep);
+ void addExtraConflict (const Capability & dep);
void addItem (QueueItemPtr item);
bool isEmpty () const { return _items.empty(); }
#include <zypp/solver/detail/ResItemAndDependency.h>
#include <zypp/solver/detail/debug.h>
#include <zypp/Arch.h>
+#include <zypp/CapSet.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
_resItems_by_name.insert (ResItemTable::value_type (resItem->name(), resItem));
/* StoreWorld all of the resItem's provides in a hash by name. */
- for (CDependencyList::const_iterator i = resItem->provides().begin(); i != resItem->provides().end(); i++) {
+ for (CapSet::const_iterator i = resItem->provides().begin(); i != resItem->provides().end(); i++) {
r_and_d = new ResItemAndDependency (resItem, *i);
- _provides_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency()->name(), r_and_d));
+ _provides_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency().name(), r_and_d));
}
/* StoreWorld all of the resItem's requires in a hash by name. */
- for (CDependencyList::const_iterator i = resItem->requires().begin(); i != resItem->requires().end(); i++) {
+ for (CapSet::const_iterator i = resItem->requires().begin(); i != resItem->requires().end(); i++) {
r_and_d = new ResItemAndDependency (resItem, *i);
- _requires_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency()->name(), r_and_d));
+ _requires_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency().name(), r_and_d));
}
/* "Recommends" are treated as requirements. */
#warning Recommends are treated as requirements
- for (CDependencyList::const_iterator i = resItem->recommends().begin(); i != resItem->recommends().end(); i++) {
+ for (CapSet::const_iterator i = resItem->recommends().begin(); i != resItem->recommends().end(); i++) {
r_and_d = new ResItemAndDependency (resItem, *i);
- _requires_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency()->name(), r_and_d));
+ _requires_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency().name(), r_and_d));
}
/* StoreWorld all of the resItem's conflicts in a hash by name. */
- for (CDependencyList::const_iterator i = resItem->conflicts().begin(); i != resItem->conflicts().end(); i++) {
+ for (CapSet::const_iterator i = resItem->conflicts().begin(); i != resItem->conflicts().end(); i++) {
r_and_d = new ResItemAndDependency (resItem, *i);
- _conflicts_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency()->name(), r_and_d));
+ _conflicts_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency().name(), r_and_d));
}
finished:
constResItemPtr
- StoreWorld::findResItemWithConstraint (constChannelPtr channel, const char *name, constDependencyPtr constraint, bool is_and) const
+ StoreWorld::findResItemWithConstraint (constChannelPtr channel, const char *name, const Capability & constraint, bool is_and) const
{
fprintf (stderr, "StoreWorld::findResItemWithConstraint() not implemented\n");
return 0;
typedef std::map<constResItemPtr, constResItemAndDependencyPtr> InstalledTable;
int
- StoreWorld::foreachProvidingResItem (constDependencyPtr dep, ResItemAndSpecFn fn, void *data)
+ StoreWorld::foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
InstalledTable installed;
//fprintf (stderr, "StoreWorld::foreachProvidingResItem(%s)\n", dep->asString().c_str());
- for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep->name()); iter != _provides_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep.name()); iter != _provides_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
constResItemPtr res = r_and_d->resItem();
//fprintf (stderr, "StoreWorld::foreachProvidingResItem(): %s\n", res->asString(true).c_str());
}
}
- for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep->name()); iter != _provides_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep.name()); iter != _provides_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
if (r_and_d && r_and_d->verifyRelation (dep)) {
}
int
- StoreWorld::foreachRequiringResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data)
+ StoreWorld::foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
InstalledTable installed;
- for (ResItemAndDependencyTable::const_iterator iter = _requires_by_name.lower_bound(dep->name()); iter != _requires_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _requires_by_name.lower_bound(dep.name()); iter != _requires_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
constResItemPtr res = r_and_d->resItem();
if (res != NULL && res->isInstalled ()) {
}
}
- for (ResItemAndDependencyTable::const_iterator iter = _requires_by_name.lower_bound(dep->name()); iter != _requires_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _requires_by_name.lower_bound(dep.name()); iter != _requires_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
- if (r_and_d && r_and_d->dependency()->verifyRelation (dep)) {
+ if (r_and_d && r_and_d->dependency().matches (dep)) {
/* Skip dups if one of them in installed. */
if (r_and_d->resItem()->isInstalled()
int
- StoreWorld::foreachConflictingResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data)
+ StoreWorld::foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data)
{
int count = 0;
InstalledTable installed;
//fprintf (stderr, "StoreWorld::foreachConflictingResItem (%s)\n", dep->name().c_str());
- for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep->name()); iter != _conflicts_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep.name()); iter != _conflicts_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
constResItemPtr res = r_and_d->resItem();
//fprintf (stderr, "==> %s\n", res->asString().c_str());
}
}
- for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep->name()); iter != _conflicts_by_name.upper_bound(dep->name()); iter++) {
+ for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep.name()); iter != _conflicts_by_name.upper_bound(dep.name()); iter++) {
constResItemAndDependencyPtr r_and_d = iter->second;
if (r_and_d)
#include <zypp/solver/detail/World.h>
#include <zypp/solver/detail/ResItem.h>
#include <zypp/solver/detail/Match.h>
-
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
// Iterate across provides or requirement
- virtual int foreachProvidingResItem (constDependencyPtr dep, ResItemAndSpecFn fn, void *data);
- virtual int foreachRequiringResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data);
- virtual int foreachConflictingResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
+ virtual int foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data);
// Channels
virtual constResItemPtr findInstalledResItem (constResItemPtr resItem);
virtual constResItemPtr findResItem (constChannelPtr channel, const char *name) const;
- virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, constDependencyPtr constraint, bool is_and) const;
+ virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, const Capability & constraint, bool is_and) const;
virtual ChannelPtr guessResItemChannel (constResItemPtr resItem) const;
};
#include <zypp/solver/detail/Packman.h>
#include <zypp/solver/detail/Package.h>
#include <zypp/solver/detail/PackageUpdate.h>
+#include <zypp/Capability.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
typedef void (*WorldClearLockFn) (constWorldPtr world);
typedef int (*WorldForeachResItemFn) (constWorldPtr world, const char *name, constChannelPtr channel, ResItemFn callback, void *user_data);
- typedef int (*WorldForeachPackageSpecFn) (constWorldPtr world, constDependencyPtr dep, ResItemAndSpecFn callback, void *user_data);
- typedef int (*WorldForeachPackageDepFn) (constWorldPtr world, constDependencyPtr dep, ResItemAndDepFn callback, void *user_data);
+ typedef int (*WorldForeachPackageDepFn) (constWorldPtr world, const Capability & dep, ResItemAndDepFn callback, void *user_data);
typedef void (*WorldSerializeFn) (constWorldPtr world, constXmlNodePtr root);
typedef void (*WorldUnserializeFn) (constWorldPtr world, constXmlNodePtr node);
virtual constResItemPtr findInstalledResItem (constResItemPtr resItem) = 0;
virtual constResItemPtr findResItem (constChannelPtr channel, const char *name) const = 0;
- virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, constDependencyPtr constraint, bool is_and) const = 0;
+ virtual constResItemPtr findResItemWithConstraint (constChannelPtr channel, const char *name, const Capability & constraint, bool is_and) const = 0;
virtual ChannelPtr guessResItemChannel (constResItemPtr resItem) const = 0;
// Iterate across resItems
// Iterate across provides or requirement
- virtual int foreachProvidingResItem (constDependencyPtr dep, ResItemAndSpecFn fn, void *user_data) = 0;
- virtual int foreachRequiringResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *user_data) = 0;
- virtual int foreachConflictingResItem (constDependencyPtr dep, ResItemAndDepFn fn, void *user_data) = 0;
+ virtual int foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *user_data) = 0;
+ virtual int foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *user_data) = 0;
+ virtual int foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *user_data) = 0;
// upgrades
// provider
- bool getSingleProvider (constDependencyPtr dep, constChannelPtr channel, constResItemPtr *resItem);
+ bool getSingleProvider (const Capability & dep, constChannelPtr channel, constResItemPtr *resItem);
// Transacting
#include <ctype.h>
#include <assert.h>
#include <zypp/solver/detail/XmlParser.h>
-#include <zypp/solver/detail/Dependency.h>
-#include <zypp/solver/detail/OrDependency.h>
#include <zypp/solver/detail/PackageUpdate.h>
#include <zypp/solver/detail/utils.h>
#include <zypp/solver/detail/debug.h>
#include <zypp/ResObject.h>
+#include <zypp/CapFactory.h>
+#include <zypp/CapSet.h>
+#include <zypp/Dependencies.h>
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
+ namespace solver
+ { /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ namespace detail
+ { ///////////////////////////////////////////////////////////////////
- using namespace std;
-
- //---------------------------------------------------------------------------
-
- static DependencyPtr
- parse_dep_attrs(bool *is_obsolete, const xmlChar **attrs)
- {
- int i;
- bool op_present = false;
- /* Temporary variables dependent upon the presense of an 'op' attribute */
- const char *name = NULL;
- int epoch = Edition::noepoch;
- string version;
- string release;
- string arch = "";
- Rel relation = Rel::ANY;
-
- *is_obsolete = false;
-
- for (i = 0; attrs[i]; i++) {
- const char *attr = (const char *)attrs[i++];
- const char *value = (const char *)attrs[i];
-
- if (!strcasecmp(attr, "name")) name = value;
- else if (!strcasecmp(attr, "op")) { op_present = true; relation = Rel(value); }
- else if (!strcasecmp(attr, "epoch")) epoch = atoi (value);
- else if (!strcasecmp(attr, "version")) version = value;
- else if (!strcasecmp(attr, "release")) release = value;
- else if (!strcasecmp(attr, "arch")) arch = value;
- else if (!strcasecmp (attr, "obsoletes")) *is_obsolete = true;
- else {
- if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Unknown attribute: %s = %s", attr, value);
- }
-
- }
-
- /* FIXME: should get Channel from XML */
- /* FIXME: should get Kind from XML */
- if ( std::strlen(arch.c_str()) > 0)
- {
- return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, Arch(arch));
- }
- else
- {
- return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, Arch_noarch);
- }
- }
-
-
- //---------------------------------------------------------------------------
- // SAX callbacks
-
- static void
- sax_start_document(void *ptr)
- {
- XmlParser *ctx = (XmlParser *)ptr;
- if (ctx->processing()) return;
-
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start document");
-
- ctx->setProcessing (true);
- }
-
-
- static void
- sax_end_document(void *ptr)
- {
- XmlParser *ctx = (XmlParser *)ptr;
- if (!ctx->processing()) return;
-
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End document");
-
- ctx->setProcessing (false);
- }
-
-
- static void
- sax_start_element(void *ptr, const xmlChar *name, const xmlChar **attrs)
- {
- XmlParser *ctx = (XmlParser *)ptr;
-
- ctx->releaseBuffer();
-
- #if 0
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start element (%s)", (const char *)name);
-
- if (attrs) {
- for (int i = 0; attrs[i]; i += 2) {
- if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, " - Attribute (%s=%s)", (const char *)attrs[i], (const char *)attrs[i+1]);
- }
- }
- #endif
- if (!strcmp((const char *)name, "channel") || !strcmp((const char *)name, "subchannel")) {
- /* Unneeded container tags. Ignore */
- return;
- }
-
- return ctx->startElement ((const char *)name, attrs);
-
- }
-
-
- static void
- sax_end_element(void *ptr, const xmlChar *name)
- {
- XmlParser *ctx = (XmlParser *)ptr;
-
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End element (%s)", (const char *)name);
+ using namespace std;
+
+ //---------------------------------------------------------------------------
+
+ static Capability
+ parse_dep_attrs(bool *is_obsolete, const xmlChar **attrs)
+ {
+ CapFactory factory;
+ int i;
+ bool op_present = false;
+ /* Temporary variables dependent upon the presense of an 'op' attribute */
+ const char *name = NULL;
+ int epoch = Edition::noepoch;
+ string version;
+ string release;
+ string arch = "";
+ Rel relation = Rel::ANY;
+
+ *is_obsolete = false;
+
+ for (i = 0; attrs[i]; i++) {
+ const char *attr = (const char *)attrs[i++];
+ const char *value = (const char *)attrs[i];
+
+ if (!strcasecmp(attr, "name")) name = value;
+ else if (!strcasecmp(attr, "op")) { op_present = true; relation = Rel(value); }
+ else if (!strcasecmp(attr, "epoch")) epoch = atoi (value);
+ else if (!strcasecmp(attr, "version")) version = value;
+ else if (!strcasecmp(attr, "release")) release = value;
+ else if (!strcasecmp(attr, "arch")) arch = value;
+ else if (!strcasecmp (attr, "obsoletes")) *is_obsolete = true;
+ else {
+ if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Unknown attribute: %s = %s", attr, value);
+ }
+
+ }
+
+ /* FIXME: should get Channel from XML */
+ /* FIXME: should get Kind from XML */
+ if ( std::strlen(arch.c_str()) > 0)
+ {
+ return factory.parse ( ResTraits<zypp::Package>::kind,
+ name,
+ relation,
+ Edition (version, release, epoch),
+ Arch(arch));
+ }
+ else
+ {
+ return factory.parse ( ResTraits<zypp::Package>::kind,
+ name,
+ relation,
+ Edition (version, release, epoch),
+ Arch_noarch);
+ }
+ }
+
+
+ //---------------------------------------------------------------------------
+ // SAX callbacks
+
+ static void
+ sax_start_document(void *ptr)
+ {
+ XmlParser *ctx = (XmlParser *)ptr;
+ if (ctx->processing()) return;
+
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start document");
+
+ ctx->setProcessing (true);
+ }
+
+
+ static void
+ sax_end_document(void *ptr)
+ {
+ XmlParser *ctx = (XmlParser *)ptr;
+ if (!ctx->processing()) return;
+
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End document");
+
+ ctx->setProcessing (false);
+ }
+
+
+ static void
+ sax_start_element(void *ptr, const xmlChar *name, const xmlChar **attrs)
+ {
+ XmlParser *ctx = (XmlParser *)ptr;
+
+ ctx->releaseBuffer();
+
+#if 0
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Start element (%s)", (const char *)name);
+
+ if (attrs) {
+ for (int i = 0; attrs[i]; i += 2) {
+ if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, " - Attribute (%s=%s)", (const char *)attrs[i], (const char *)attrs[i+1]);
+ }
+ }
+#endif
+ if (!strcmp((const char *)name, "channel") || !strcmp((const char *)name, "subchannel")) {
+ /* Unneeded container tags. Ignore */
+ return;
+ }
+
+ return ctx->startElement ((const char *)name, attrs);
+
+ }
+
+
+ static void
+ sax_end_element(void *ptr, const xmlChar *name)
+ {
+ XmlParser *ctx = (XmlParser *)ptr;
+
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* End element (%s)", (const char *)name);
- if (!strcmp((const char *)name, "channel") || !strcmp((const char *)name, "subchannel")) {
- /* Unneeded container tags. Ignore */
- name = NULL;
- }
-
- return ctx->endElement ((const char *)name);
- }
-
-
- static void
- sax_characters(void *ptr, const xmlChar *ch, int len)
- {
- XmlParser *ctx = (XmlParser *)ptr;
-
- ctx->toBuffer ((const char *)ch, len);
- return;
- }
-
-
- static void
- sax_warning(void *ptr, const char *msg, ...)
- {
- va_list args;
- char tmp[2048];
-
- va_start(args, msg);
-
- if (vsnprintf(tmp, 2048, msg, args) >= 2048) fprintf (stderr, "vsnprintf overflow\n");
- rc_debug (RC_DEBUG_LEVEL_WARNING, "* SAX Warning: %s", tmp);
-
- va_end(args);
- }
-
-
- static void
- sax_error(void *ptr, const char *msg, ...)
- {
- va_list args;
- char tmp[2048];
-
- va_start(args, msg);
-
- if (vsnprintf(tmp, 2048, msg, args) >= 2048) fprintf (stderr, "vsnprintf overflow\n");
- rc_debug (RC_DEBUG_LEVEL_ERROR, "* SAX Error: %s", tmp);
-
- va_end(args);
- }
-
-
- static xmlSAXHandler sax_handler = {
- NULL, /* internalSubset */
- NULL, /* isStandalone */
- NULL, /* hasInternalSubset */
- NULL, /* hasExternalSubset */
- NULL, /* resolveEntity */
- NULL, /* getEntity */
- NULL, /* entityDecl */
- NULL, /* notationDecl */
- NULL, /* attributeDecl */
- NULL, /* elementDecl */
- NULL, /* unparsedEntityDecl */
- NULL, /* setDocumentLocator */
- sax_start_document, /* startDocument */
- sax_end_document, /* endDocument */
- sax_start_element, /* startElement */
- sax_end_element, /* endElement */
- NULL, /* reference */
- sax_characters, /* characters */
- NULL, /* ignorableWhitespace */
- NULL, /* processingInstruction */
- NULL, /* comment */
- sax_warning, /* warning */
- sax_error, /* error */
- sax_error /* fatalError */
- };
-
- //---------------------------------------------------------------------------
-
- XmlParser::XmlParser (constChannelPtr channel)
- : _channel (channel)
- , _processing (false)
- , _xml_context (NULL)
- , _state (PARSER_TOPLEVEL)
- , _current_package_stored(true)
- , _current_update (NULL)
- , _toplevel_dep_list (NULL)
- , _current_dep_list (NULL)
- , _text_buffer (NULL)
- , _text_buffer_size (0)
- {
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Context created (%p)", this);
- }
-
-
- XmlParser::~XmlParser()
- {
- releaseBuffer ();
- }
-
- //---------------------------------------------------------------------------
-
- string
- XmlParser::asString ( void ) const
- {
- return toString (*this);
- }
-
-
- string
- XmlParser::toString ( const XmlParser & context )
- {
- return "<XmlParser/>";
- }
-
-
- ostream &
- XmlParser::dumpOn( ostream & str ) const
- {
- str << asString();
- return str;
- }
-
-
- ostream&
- operator<<( ostream& os, const XmlParser& context)
- {
- return os << context.asString();
- }
-
- //---------------------------------------------------------------------------
-
- void
- XmlParser::toBuffer (const char *data, size_t size)
- {
- _text_buffer = (char *)realloc (_text_buffer, _text_buffer_size + size + 1);
- strncpy (_text_buffer + _text_buffer_size, (char *)data, size);
- _text_buffer_size += size;
- _text_buffer[_text_buffer_size] = 0;
-
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser[%p]::toBuffer(%.32s...,%ld)\n", this, data, (long)size);
- }
-
-
- void
- XmlParser::releaseBuffer ()
- {
- if (_text_buffer)
- free (_text_buffer);
- _text_buffer = NULL;
- _text_buffer_size = 0;
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser[%p]::releaseBuffer()\n", this);
- }
-
-
- void
- XmlParser::parseChunk(const char *xmlbuf, size_t size)
- {
- if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::parseChunk(%.32s...,%ld)\n", xmlbuf, (long)size);
-
- xmlSubstituteEntitiesDefault(true);
+ if (!strcmp((const char *)name, "channel") || !strcmp((const char *)name, "subchannel")) {
+ /* Unneeded container tags. Ignore */
+ name = NULL;
+ }
+
+ return ctx->endElement ((const char *)name);
+ }
+
+
+ static void
+ sax_characters(void *ptr, const xmlChar *ch, int len)
+ {
+ XmlParser *ctx = (XmlParser *)ptr;
+
+ ctx->toBuffer ((const char *)ch, len);
+ return;
+ }
+
+
+ static void
+ sax_warning(void *ptr, const char *msg, ...)
+ {
+ va_list args;
+ char tmp[2048];
+
+ va_start(args, msg);
+
+ if (vsnprintf(tmp, 2048, msg, args) >= 2048) fprintf (stderr, "vsnprintf overflow\n");
+ rc_debug (RC_DEBUG_LEVEL_WARNING, "* SAX Warning: %s", tmp);
+
+ va_end(args);
+ }
+
+
+ static void
+ sax_error(void *ptr, const char *msg, ...)
+ {
+ va_list args;
+ char tmp[2048];
+
+ va_start(args, msg);
+
+ if (vsnprintf(tmp, 2048, msg, args) >= 2048) fprintf (stderr, "vsnprintf overflow\n");
+ rc_debug (RC_DEBUG_LEVEL_ERROR, "* SAX Error: %s", tmp);
+
+ va_end(args);
+ }
+
+
+ static xmlSAXHandler sax_handler = {
+ NULL, /* internalSubset */
+ NULL, /* isStandalone */
+ NULL, /* hasInternalSubset */
+ NULL, /* hasExternalSubset */
+ NULL, /* resolveEntity */
+ NULL, /* getEntity */
+ NULL, /* entityDecl */
+ NULL, /* notationDecl */
+ NULL, /* attributeDecl */
+ NULL, /* elementDecl */
+ NULL, /* unparsedEntityDecl */
+ NULL, /* setDocumentLocator */
+ sax_start_document, /* startDocument */
+ sax_end_document, /* endDocument */
+ sax_start_element, /* startElement */
+ sax_end_element, /* endElement */
+ NULL, /* reference */
+ sax_characters, /* characters */
+ NULL, /* ignorableWhitespace */
+ NULL, /* processingInstruction */
+ NULL, /* comment */
+ sax_warning, /* warning */
+ sax_error, /* error */
+ sax_error /* fatalError */
+ };
+
+ //---------------------------------------------------------------------------
+
+ XmlParser::XmlParser (constChannelPtr channel)
+ : _channel (channel)
+ , _processing (false)
+ , _xml_context (NULL)
+ , _state (PARSER_TOPLEVEL)
+ , _current_package_stored(true)
+ , _current_update (NULL)
+ , _toplevel_dep_list (NULL)
+ , _current_dep_list (NULL)
+ , _text_buffer (NULL)
+ , _text_buffer_size (0)
+ {
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "* Context created (%p)", this);
+ }
+
+
+ XmlParser::~XmlParser()
+ {
+ releaseBuffer ();
+ }
+
+ //---------------------------------------------------------------------------
+
+ string
+ XmlParser::asString ( void ) const
+ {
+ return toString (*this);
+ }
+
+
+ string
+ XmlParser::toString ( const XmlParser & context )
+ {
+ return "<XmlParser/>";
+ }
+
+
+ ostream &
+ XmlParser::dumpOn( ostream & str ) const
+ {
+ str << asString();
+ return str;
+ }
+
+
+ ostream&
+ operator<<( ostream& os, const XmlParser& context)
+ {
+ return os << context.asString();
+ }
+
+ //---------------------------------------------------------------------------
+
+ void
+ XmlParser::toBuffer (const char *data, size_t size)
+ {
+ _text_buffer = (char *)realloc (_text_buffer, _text_buffer_size + size + 1);
+ strncpy (_text_buffer + _text_buffer_size, (char *)data, size);
+ _text_buffer_size += size;
+ _text_buffer[_text_buffer_size] = 0;
+
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser[%p]::toBuffer(%.32s...,%ld)\n", this, data, (long)size);
+ }
+
+
+ void
+ XmlParser::releaseBuffer ()
+ {
+ if (_text_buffer)
+ free (_text_buffer);
+ _text_buffer = NULL;
+ _text_buffer_size = 0;
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser[%p]::releaseBuffer()\n", this);
+ }
+
+
+ void
+ XmlParser::parseChunk(const char *xmlbuf, size_t size)
+ {
+ if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::parseChunk(%.32s...,%ld)\n", xmlbuf, (long)size);
+
+ xmlSubstituteEntitiesDefault(true);
- if (!_xml_context) {
- _xml_context = xmlCreatePushParserCtxt(&sax_handler, this, NULL, 0, NULL);
- }
+ if (!_xml_context) {
+ _xml_context = xmlCreatePushParserCtxt(&sax_handler, this, NULL, 0, NULL);
+ }
- xmlParseChunk(_xml_context, xmlbuf, size, 0);
- }
+ xmlParseChunk(_xml_context, xmlbuf, size, 0);
+ }
- PackageList
- XmlParser::done()
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::done()\n");
+ PackageList
+ XmlParser::done()
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::done()\n");
- if (_processing)
- xmlParseChunk(_xml_context, NULL, 0, 1);
+ if (_processing)
+ xmlParseChunk(_xml_context, NULL, 0, 1);
- if (_xml_context)
- xmlFreeParserCtxt(_xml_context);
+ if (_xml_context)
+ xmlFreeParserCtxt(_xml_context);
- if (!_current_package_stored) {
- fprintf (stderr, "Incomplete package lost\n");
- }
-
- if (_current_update) {
- fprintf (stderr, "Incomplete update lost");
- }
-
- return _all_packages;
- }
-
-
- //---------------------------------------------------------------------------
- // Parser state callbacks
-
- void
- XmlParser::startElement(const char *name, const xmlChar **attrs)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::startElement(%s)\n", name);
-
- switch (_state) {
- case PARSER_TOPLEVEL:
- toplevelStart(name, attrs);
- break;
- case PARSER_PACKAGE:
- packageStart(name, attrs);
- break;
- case PARSER_HISTORY:
- historyStart(name, attrs);
- break;
- case PARSER_DEP:
- dependencyStart(name, attrs);
- break;
- default:
- break;
- }
-
- return;
- }
-
-
- void
- XmlParser::endElement(const char *name)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::endElement(%s)\n", name);
-
- if (name != NULL) { // sax_end_element might set name to NULL
- switch (_state) {
- case PARSER_PACKAGE:
- packageEnd(name);
- break;
- case PARSER_HISTORY:
- historyEnd(name);
- break;
- case PARSER_UPDATE:
- updateEnd(name);
- break;
- case PARSER_DEP:
- dependencyEnd(name);
- break;
- default:
- break;
- }
- }
-
- releaseBuffer();
-
- return;
- }
-
-
- void
- XmlParser::toplevelStart(const char * name, const xmlChar **attrs)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::toplevelStart(%s)\n", name);
-
- if (!strcmp(name, "package")) {
+ if (!_current_package_stored) {
+ fprintf (stderr, "Incomplete package lost\n");
+ }
+
+ if (_current_update) {
+ fprintf (stderr, "Incomplete update lost");
+ }
+
+ return _all_packages;
+ }
+
+
+ //---------------------------------------------------------------------------
+ // Parser state callbacks
+
+ void
+ XmlParser::startElement(const char *name, const xmlChar **attrs)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::startElement(%s)\n", name);
+
+ switch (_state) {
+ case PARSER_TOPLEVEL:
+ toplevelStart(name, attrs);
+ break;
+ case PARSER_PACKAGE:
+ packageStart(name, attrs);
+ break;
+ case PARSER_HISTORY:
+ historyStart(name, attrs);
+ break;
+ case PARSER_DEP:
+ dependencyStart(name, attrs);
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+
+
+ void
+ XmlParser::endElement(const char *name)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::endElement(%s)\n", name);
+
+ if (name != NULL) { // sax_end_element might set name to NULL
+ switch (_state) {
+ case PARSER_PACKAGE:
+ packageEnd(name);
+ break;
+ case PARSER_HISTORY:
+ historyEnd(name);
+ break;
+ case PARSER_UPDATE:
+ updateEnd(name);
+ break;
+ case PARSER_DEP:
+ dependencyEnd(name);
+ break;
+ default:
+ break;
+ }
+ }
+
+ releaseBuffer();
+
+ return;
+ }
+
+
+ void
+ XmlParser::toplevelStart(const char * name, const xmlChar **attrs)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::toplevelStart(%s)\n", name);
+
+ if (!strcmp(name, "package")) {
- _state = PARSER_PACKAGE;
-
- _current_package_stored = false;
- _current_package_name = "";
- _current_package_prettyName = "";
- _current_package_summary = "";
- _current_package_description = "";
- _current_package_section = "";
- _current_package_kind = ResTraits<zypp::Package>::kind;
- _current_package_arch = Arch_noarch;
- _current_package_edition = Edition::noedition;
- _current_package_fileSize = 0;
- _current_package_installedSize = 0;
- _current_package_installOnly = false;
- _current_package_packageSet = false;
- _current_package_packageUpdateList.clear();
+ _state = PARSER_PACKAGE;
+
+ _current_package_stored = false;
+ _current_package_name = "";
+ _current_package_prettyName = "";
+ _current_package_summary = "";
+ _current_package_description = "";
+ _current_package_section = "";
+ _current_package_kind = ResTraits<zypp::Package>::kind;
+ _current_package_arch = Arch_noarch;
+ _current_package_edition = Edition::noedition;
+ _current_package_fileSize = 0;
+ _current_package_installedSize = 0;
+ _current_package_installOnly = false;
+ _current_package_packageSet = false;
+ _current_package_packageUpdateList.clear();
- _current_requires.clear();
- _current_provides.clear();
- _current_conflicts.clear();
- _current_children.clear();
- _current_recommends.clear();
- _current_suggests.clear();
- _current_obsoletes.clear();
-
- }
- else {
- if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s at toplevel", (const char *)name);
- }
- }
-
-
- void
- XmlParser::packageStart(const char * name, const xmlChar **attrs)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageStart(%s)\n", name);
-
- /* Only care about the containers here */
- if (!strcmp((const char *)name, "history")) {
- _state = PARSER_HISTORY;
- }
- else if (!strcmp (name, "deps")) {
- /*
- * We can get a <deps> tag surrounding the actual package
- * dependency sections (requires, provides, conflicts, etc).
- * In this case, we'll just ignore this tag quietly.
- */
- }
- else if (!strcmp(name, "requires")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_requires;
- }
- else if (!strcmp(name, "recommends")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_recommends;
- }
- else if (!strcmp(name, "suggests")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_suggests;
- }
- else if (!strcmp(name, "conflicts")) {
- bool is_obsolete = false;
- int i;
-
- _state = PARSER_DEP;
-
- for (i = 0; attrs && attrs[i] && !is_obsolete; i += 2) {
-
- if (!strcasecmp ((const char *)(attrs[i]), "obsoletes"))
- is_obsolete = true;
- }
-
- if (is_obsolete)
- _current_dep_list = _toplevel_dep_list = &_current_obsoletes;
- else {
- _current_dep_list = _toplevel_dep_list = &_current_conflicts;
- }
- }
- else if (!strcmp(name, "obsoletes")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_obsoletes;
- }
- else if (!strcmp(name, "provides")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_provides;
- }
- else if (!strcmp(name, "children")) {
- _state = PARSER_DEP;
- _current_dep_list = _toplevel_dep_list = &_current_children;
- }
- else {
- // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in package start", name);
- }
- }
-
-
- void
- XmlParser::historyStart(const char * name, const xmlChar **attrs)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyStart(%s)\n", name);
-
- if (!strcmp(name, "update")) {
- assert(_current_update == NULL);
-
- _current_update = new PackageUpdate(_current_package_name);
-
- _state = PARSER_UPDATE;
- }
- else {
- if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in history", name);
- }
- }
-
-
- void
- XmlParser::dependencyStart(const char *name, const xmlChar **attrs)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyStart(%s)\n", name);
-
- if (!strcmp(name, "dep")) {
- DependencyPtr dep;
- bool is_obsolete;
-
- dep = parse_dep_attrs(&is_obsolete, attrs);
-
- if (is_obsolete)
- _current_obsoletes.push_back (dep);
- else {
- _current_dep_list->push_back (dep);
- }
- }
- else if (!strcmp(name, "or"))
- _current_dep_list = new CDependencyList;
- else {
- if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in dependency", name);
- }
- }
-
-
- //---------------------------------------------------------------------------
-
-
- void
- XmlParser::packageEnd(const char *name)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s)\n", name);
-
- if (!strcmp(name, "package")) {
- PackageUpdatePtr update = NULL;
-
- /* If possible, grab the version info from the most recent update.
- * Otherwise, try to find where the package provides itself and use
- * that version info.
- */
- if (!_current_package_packageUpdateList.empty())
- update = _current_package_packageUpdateList.back();
-
- if (update) {
- _current_package_name = update->name();
- _current_package_kind = update->kind();
- _current_package_edition = update->edition();
- _current_package_fileSize = update->packageSize();
- _current_package_installedSize = update->installedSize();
- }
- else {
- for (CDependencyList::const_iterator iter = _current_provides.begin(); iter != _current_provides.end(); iter++) {
- if ((*iter)->relation() == Rel::EQ
- && ((*iter)->name() == _current_package_name))
- {
- _current_package_kind = (*iter)->kind();
- _current_package_edition = (*iter)->edition();
- break;
- }
- }
- }
+ _current_requires.clear();
+ _current_provides.clear();
+ _current_conflicts.clear();
+ _current_children.clear();
+ _current_recommends.clear();
+ _current_suggests.clear();
+ _current_obsoletes.clear();
+
+ }
+ else {
+ if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s at toplevel", (const char *)name);
+ }
+ }
+
+
+ void
+ XmlParser::packageStart(const char * name, const xmlChar **attrs)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageStart(%s)\n", name);
+
+ /* Only care about the containers here */
+ if (!strcmp((const char *)name, "history")) {
+ _state = PARSER_HISTORY;
+ }
+ else if (!strcmp (name, "deps")) {
+ /*
+ * We can get a <deps> tag surrounding the actual package
+ * dependency sections (requires, provides, conflicts, etc).
+ * In this case, we'll just ignore this tag quietly.
+ */
+ }
+ else if (!strcmp(name, "requires")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_requires;
+ }
+ else if (!strcmp(name, "recommends")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_recommends;
+ }
+ else if (!strcmp(name, "suggests")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_suggests;
+ }
+ else if (!strcmp(name, "conflicts")) {
+ bool is_obsolete = false;
+ int i;
+
+ _state = PARSER_DEP;
+
+ for (i = 0; attrs && attrs[i] && !is_obsolete; i += 2) {
+
+ if (!strcasecmp ((const char *)(attrs[i]), "obsoletes"))
+ is_obsolete = true;
+ }
+
+ if (is_obsolete)
+ _current_dep_list = _toplevel_dep_list = &_current_obsoletes;
+ else {
+ _current_dep_list = _toplevel_dep_list = &_current_conflicts;
+ }
+ }
+ else if (!strcmp(name, "obsoletes")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_obsoletes;
+ }
+ else if (!strcmp(name, "provides")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_provides;
+ }
+ else if (!strcmp(name, "children")) {
+ _state = PARSER_DEP;
+ _current_dep_list = _toplevel_dep_list = &_current_children;
+ }
+ else {
+ // if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in package start", name);
+ }
+ }
+
+
+ void
+ XmlParser::historyStart(const char * name, const xmlChar **attrs)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyStart(%s)\n", name);
+
+ if (!strcmp(name, "update")) {
+ assert(_current_update == NULL);
+
+ _current_update = new PackageUpdate(_current_package_name);
+
+ _state = PARSER_UPDATE;
+ }
+ else {
+ if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in history", name);
+ }
+ }
+
+
+ void
+ XmlParser::dependencyStart(const char *name, const xmlChar **attrs)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyStart(%s)\n", name);
+
+ if (!strcmp(name, "dep")) {
+ Capability dep;
+ bool is_obsolete;
+
+ dep = parse_dep_attrs(&is_obsolete, attrs);
+
+ if (is_obsolete)
+ _current_obsoletes.insert (dep);
+ else {
+ _current_dep_list->insert (dep);
+ }
+ }
+ else if (!strcmp(name, "or"))
+ _current_dep_list->clear();
+ else {
+ if (getenv ("RC_SPEW_XML")) rc_debug (RC_DEBUG_LEVEL_ALWAYS, "! Not handling %s in dependency", name);
+ }
+ }
+
+
+ //---------------------------------------------------------------------------
+
+
+ void
+ XmlParser::packageEnd(const char *name)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s)\n", name);
+
+ if (!strcmp(name, "package")) {
+ PackageUpdatePtr update = NULL;
+
+ /* If possible, grab the version info from the most recent update.
+ * Otherwise, try to find where the package provides itself and use
+ * that version info.
+ */
+ if (!_current_package_packageUpdateList.empty())
+ update = _current_package_packageUpdateList.back();
+
+ if (update) {
+ _current_package_name = update->name();
+ _current_package_kind = update->kind();
+ _current_package_edition = update->edition();
+ _current_package_fileSize = update->packageSize();
+ _current_package_installedSize = update->installedSize();
+ }
+#if 0 //Is this really needed ?
+ else {
+ for (CapSet::const_iterator iter = _current_provides.begin(); iter != _current_provides.end(); iter++) {
+ if ((*iter)->relation() == Rel::EQ
+ && ((*iter)->name() == _current_package_name))
+ {
+ _current_package_kind = (*iter)->kind();
+ _current_package_edition = (*iter)->edition();
+ break;
+ }
+ }
+ }
+#endif
+ // check if we provide ourselfs properly
- // check if we provide ourselfs properly
-
- CDependencyList::const_iterator piter;
- for (piter = _current_provides.begin(); piter != _current_provides.end(); piter++) {
- if ((*piter)->relation() == Rel::EQ
- && ((*piter)->name() == _current_package_name))
- {
- break;
- }
- }
-
- if (piter == _current_provides.end()) { // no self provide found, construct one
- constDependencyPtr selfdep = new Dependency (_current_package_name, Rel::EQ, _current_package_kind, _channel, _current_package_edition);
- //if (getenv ("RC_SPEW")) fprintf (stderr, "Adding self-provide [%s]\n", selfdep->asString().c_str());
- _current_provides.push_front (selfdep);
- }
+ CapFactory factory;
+ Capability selfdep = factory.parse ( ResTraits<zypp::Package>::kind,
+ _current_package_name,
+ Rel::EQ,
+ _current_package_edition,
+ _current_package_arch);
+ CapSet::const_iterator piter;
+ for (piter = _current_provides.begin(); piter != _current_provides.end(); piter++) {
+ if ((*piter) == selfdep)
+ {
+ break;
+ }
+ }
+
+ if (piter == _current_provides.end()) { // no self provide found, construct one
+ //if (getenv ("RC_SPEW")) fprintf (stderr, "Adding self-provide [%s]\n", selfdep->asString().c_str());
+ _current_provides.insert (selfdep);
+ }
- PackagePtr package = new Package ( _channel,
- _current_package_name,
- _current_package_edition,
- _current_package_arch);
- package->setRequires (_current_requires);
- package->setProvides (_current_provides);
- package->setConflicts (_current_conflicts);
- package->setObsoletes (_current_obsoletes);
- package->setSuggests (_current_suggests);
- package->setRecommends (_current_recommends);
- package->setPrettyName (_current_package_prettyName);
- package->setSummary (_current_package_summary);
- package->setDescription (_current_package_description);
- package->setSection (new Section(_current_package_section.c_str()));
- package->setFileSize (_current_package_fileSize);
- package->setInstalledSize (_current_package_installedSize);
- package->setInstallOnly (_current_package_installOnly);
- package->setPackageSet (_current_package_packageSet);
- for (PackageUpdateList::iterator iter = _current_package_packageUpdateList.begin();
- iter != _current_package_packageUpdateList.end();
- iter++) {
- PackageUpdatePtr update = *iter;
- update->setPackage (package);
- package->addUpdate (update);
- }
- _all_packages.push_back (package);
+ PackagePtr package = new Package ( _channel,
+ _current_package_name,
+ _current_package_edition,
+ _current_package_arch);
+
+ Dependencies deps;
+ deps.setRequires (_current_requires);
+ deps.setProvides (_current_provides);
+ deps.setConflicts (_current_conflicts);
+ deps.setObsoletes (_current_obsoletes);
+ deps.setSuggests (_current_suggests);
+ deps.setRecommends (_current_recommends);
+ package->setDependencies (deps);
+ package->setPrettyName (_current_package_prettyName);
+ package->setSummary (_current_package_summary);
+ package->setDescription (_current_package_description);
+ package->setSection (new Section(_current_package_section.c_str()));
+ package->setFileSize (_current_package_fileSize);
+ package->setInstalledSize (_current_package_installedSize);
+ package->setInstallOnly (_current_package_installOnly);
+ package->setPackageSet (_current_package_packageSet);
+ for (PackageUpdateList::iterator iter = _current_package_packageUpdateList.begin();
+ iter != _current_package_packageUpdateList.end();
+ iter++) {
+ PackageUpdatePtr update = *iter;
+ update->setPackage (package);
+ package->addUpdate (update);
+ }
+ _all_packages.push_back (package);
- if (getenv ("RC_SPEW")) fprintf (stderr, "%s\n", package->asString(true).c_str());
- if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd done: '%s'\n", package->asString(true).c_str());
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd now %ld packages\n", _all_packages.size());
- _current_package_stored = true;
- _state = PARSER_TOPLEVEL;
- }
- else if (!strcmp(name, "name")) { _current_package_name = strstrip (_text_buffer);
- } else if (!strcmp(name, "pretty_name")) { _current_package_prettyName = strstrip (_text_buffer);
- } else if (!strcmp(name, "summary")) { _current_package_summary = strstrip (_text_buffer);
- } else if (!strcmp(name, "description")) { _current_package_description = strstrip (_text_buffer);
- } else if (!strcmp(name, "section")) { _current_package_section = strstrip (_text_buffer);
- } else if (!strcmp(name, "arch")) { _current_package_arch = Arch(strstrip (_text_buffer));
- } else if (!strcmp(name, "filesize")) { _current_package_fileSize = atoi(_text_buffer);
- } else if (!strcmp(name, "installedsize")) { _current_package_installedSize = atoi(_text_buffer);
- } else if (!strcmp(name, "install_only")) { _current_package_installOnly = true;
- } else if (!strcmp(name, "package_set")) { _current_package_packageSet = true;
- } else {
- if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) unknown\n", name);
- }
-
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) done\n", name);
-
- releaseBuffer();
- }
-
-
- void
- XmlParser::historyEnd(const char *name)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyEnd(%s)\n", name);
-
- if (!strcmp(name, "history")) {
- assert(_current_update == NULL);
-
- _state = PARSER_PACKAGE;
- }
- }
-
-
- void
- XmlParser::updateEnd(const char *name)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s)\n", name);
-
- constChannelPtr channel;
- const char *url_prefix = NULL;
-
- assert(_current_update != NULL);
-
- if (_channel != NULL) {
- url_prefix = _channel->filePath ();
- }
-
- if (!strcmp(name, "update")) {
- _current_package_packageUpdateList.push_back(_current_update);
-
- _current_update = NULL;
- _state = PARSER_HISTORY;
-
- } else if (!strcmp(name, "epoch")) { _current_update->setEpoch (atoi(_text_buffer));
- } else if (!strcmp(name, "version")) { _current_update->setVersion (strstrip (_text_buffer));
- } else if (!strcmp(name, "release")) { _current_update->setRelease (strstrip (_text_buffer));
- } else if (!strcmp(name, "arch")) { _current_update->setArch (strstrip (_text_buffer));
- } else if (!strcmp(name, "filename")) {
- strstrip (_text_buffer);
- if (url_prefix) {
- _current_update->setPackageUrl (maybe_merge_paths(url_prefix, _text_buffer));
- }
- else {
- _current_update->setPackageUrl (_text_buffer);
- }
- } else if (!strcmp(name, "filesize")) { _current_update->setPackageSize (atoi(_text_buffer));
- } else if (!strcmp(name, "installedsize")) { _current_update->setInstalledSize (atoi (_text_buffer));
- } else if (!strcmp(name, "signaturename")) {
- strstrip (_text_buffer);
- if (url_prefix) {
- _current_update->setSignatureUrl (maybe_merge_paths(url_prefix, _text_buffer));
- }
- else {
- _current_update->setSignatureUrl (_text_buffer);
- }
- } else if (!strcmp(name, "signaturesize")) { _current_update->setSignatureSize (atoi (_text_buffer));
- } else if (!strcmp(name, "md5sum")) { _current_update->setMd5sum (strstrip (_text_buffer));
- } else if (!strcmp(name, "importance")) { _current_update->setImportance (new Importance (strstrip (_text_buffer)));
- } else if (!strcmp(name, "description")) { _current_update->setDescription (strstrip (_text_buffer));
- } else if (!strcmp(name, "hid")) { _current_update->setHid (atoi(_text_buffer));
- } else if (!strcmp (name, "license")) { _current_update->setLicense (strstrip (_text_buffer));
- } else {
- fprintf (stderr, "XmlParser::updateEnd(%s) unknown\n", name);
- }
-
- // if (_current_update != NULL && getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s) => '%s'\n", name, _current_update->asString().c_str());
-
- releaseBuffer();
-
- }
-
-
- void
- XmlParser::dependencyEnd(const char *name)
- {
- // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyEnd(%s)\n", name);
-
- if (!strcmp(name, "or")) {
- OrDependencyPtr or_dep = OrDependency::fromDependencyList (*_current_dep_list);
- DependencyPtr dep = new Dependency (or_dep);
-
- (*_current_dep_list).clear();
-
- (*_toplevel_dep_list).push_back (dep);
- _current_dep_list = _toplevel_dep_list;
- }
- else if (!strcmp(name, "dep")) {
- /* We handled everything we needed for dep in start */
- }
- else {
- /* All of the dep lists (requires, provides, etc.) */
- _toplevel_dep_list = NULL;
- _current_dep_list = NULL;
- _state = PARSER_PACKAGE;
- }
- }
-
-
-
- //===================================================================================================================
-
- #if 0
- //---------------------------------------------------------------------------
-
- /* ------ */
-
-
- static RCResItemDep *
- rc_xml_node_to_resItem_dep_internal (const xmlNode *node)
- {
- gchar *name = NULL, *version = NULL, *release = NULL;
- gboolean has_epoch = false;
- guint32 epoch = 0;
- RCResItemRelation relation;
- RCResItemDep *dep;
+ if (getenv ("RC_SPEW")) fprintf (stderr, "%s\n", package->asString(true).c_str());
+ if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd done: '%s'\n", package->asString(true).c_str());
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd now %ld packages\n", _all_packages.size());
+ _current_package_stored = true;
+ _state = PARSER_TOPLEVEL;
+ }
+ else if (!strcmp(name, "name")) { _current_package_name = strstrip (_text_buffer);
+ } else if (!strcmp(name, "pretty_name")) { _current_package_prettyName = strstrip (_text_buffer);
+ } else if (!strcmp(name, "summary")) { _current_package_summary = strstrip (_text_buffer);
+ } else if (!strcmp(name, "description")) { _current_package_description = strstrip (_text_buffer);
+ } else if (!strcmp(name, "section")) { _current_package_section = strstrip (_text_buffer);
+ } else if (!strcmp(name, "arch")) { _current_package_arch = Arch(strstrip (_text_buffer));
+ } else if (!strcmp(name, "filesize")) { _current_package_fileSize = atoi(_text_buffer);
+ } else if (!strcmp(name, "installedsize")) { _current_package_installedSize = atoi(_text_buffer);
+ } else if (!strcmp(name, "install_only")) { _current_package_installOnly = true;
+ } else if (!strcmp(name, "package_set")) { _current_package_packageSet = true;
+ } else {
+ if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) unknown\n", name);
+ }
+
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::packageEnd(%s) done\n", name);
+
+ releaseBuffer();
+ }
+
+
+ void
+ XmlParser::historyEnd(const char *name)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::historyEnd(%s)\n", name);
+
+ if (!strcmp(name, "history")) {
+ assert(_current_update == NULL);
+
+ _state = PARSER_PACKAGE;
+ }
+ }
+
+
+ void
+ XmlParser::updateEnd(const char *name)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s)\n", name);
+
+ constChannelPtr channel;
+ const char *url_prefix = NULL;
+
+ assert(_current_update != NULL);
+
+ if (_channel != NULL) {
+ url_prefix = _channel->filePath ();
+ }
+
+ if (!strcmp(name, "update")) {
+ _current_package_packageUpdateList.push_back(_current_update);
+
+ _current_update = NULL;
+ _state = PARSER_HISTORY;
+
+ } else if (!strcmp(name, "epoch")) { _current_update->setEpoch (atoi(_text_buffer));
+ } else if (!strcmp(name, "version")) { _current_update->setVersion (strstrip (_text_buffer));
+ } else if (!strcmp(name, "release")) { _current_update->setRelease (strstrip (_text_buffer));
+ } else if (!strcmp(name, "arch")) { _current_update->setArch (strstrip (_text_buffer));
+ } else if (!strcmp(name, "filename")) {
+ strstrip (_text_buffer);
+ if (url_prefix) {
+ _current_update->setPackageUrl (maybe_merge_paths(url_prefix, _text_buffer));
+ }
+ else {
+ _current_update->setPackageUrl (_text_buffer);
+ }
+ } else if (!strcmp(name, "filesize")) { _current_update->setPackageSize (atoi(_text_buffer));
+ } else if (!strcmp(name, "installedsize")) { _current_update->setInstalledSize (atoi (_text_buffer));
+ } else if (!strcmp(name, "signaturename")) {
+ strstrip (_text_buffer);
+ if (url_prefix) {
+ _current_update->setSignatureUrl (maybe_merge_paths(url_prefix, _text_buffer));
+ }
+ else {
+ _current_update->setSignatureUrl (_text_buffer);
+ }
+ } else if (!strcmp(name, "signaturesize")) { _current_update->setSignatureSize (atoi (_text_buffer));
+ } else if (!strcmp(name, "md5sum")) { _current_update->setMd5sum (strstrip (_text_buffer));
+ } else if (!strcmp(name, "importance")) { _current_update->setImportance (new Importance (strstrip (_text_buffer)));
+ } else if (!strcmp(name, "description")) { _current_update->setDescription (strstrip (_text_buffer));
+ } else if (!strcmp(name, "hid")) { _current_update->setHid (atoi(_text_buffer));
+ } else if (!strcmp (name, "license")) { _current_update->setLicense (strstrip (_text_buffer));
+ } else {
+ fprintf (stderr, "XmlParser::updateEnd(%s) unknown\n", name);
+ }
+
+ // if (_current_update != NULL && getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::updateEnd(%s) => '%s'\n", name, _current_update->asString().c_str());
+
+ releaseBuffer();
+
+ }
+
+
+ void
+ XmlParser::dependencyEnd(const char *name)
+ {
+ // if (getenv ("RC_SPEW_XML")) fprintf (stderr, "XmlParser::dependencyEnd(%s)\n", name);
+
+ if (!strcmp(name, "or")) {
+#if 0
+ OrDependencyPtr or_dep = OrDependency::fromDependencyList (*_current_dep_list);
+ DependencyPtr dep = new Dependency (or_dep);
+
+ (*_current_dep_list).clear();
+
+ (*_toplevel_dep_list).push_back (dep);
+ _current_dep_list = _toplevel_dep_list;
+#endif
+ }
+ else if (!strcmp(name, "dep")) {
+ /* We handled everything we needed for dep in start */
+ }
+ else {
+ /* All of the dep lists (requires, provides, etc.) */
+ _toplevel_dep_list = NULL;
+ _current_dep_list = NULL;
+ _state = PARSER_PACKAGE;
+ }
+ }
+
+
+
+ //===================================================================================================================
+
+#if 0
+ //---------------------------------------------------------------------------
+
+ /* ------ */
+
+
+ static RCResItemDep *
+ rc_xml_node_to_resItem_dep_internal (const xmlNode *node)
+ {
+ gchar *name = NULL, *version = NULL, *release = NULL;
+ gboolean has_epoch = false;
+ guint32 epoch = 0;
+ RCResItemRelation relation;
+ RCResItemDep *dep;
- gchar *tmp;
+ gchar *tmp;
- if (g_strcasecmp (node->name, "dep")) {
- return (NULL);
- }
+ if (g_strcasecmp (node->name, "dep")) {
+ return (NULL);
+ }
- name = xml_get_prop (node, "name");
- tmp = xml_get_prop (node, "op");
- if (tmp) {
- relation = rc_resItem_relation_from_string (tmp);
+ name = xml_get_prop (node, "name");
+ tmp = xml_get_prop (node, "op");
+ if (tmp) {
+ relation = rc_resItem_relation_from_string (tmp);
- has_epoch = xml_get_guint32_value (node, "epoch", &epoch);
-
- version = xml_get_prop (node, "version");
- release = xml_get_prop (node, "release");
- } else {
- relation = RC_RELATION_ANY;
- }
-
- /* FIXME: should get channel from XML */
- dep = rc_resItem_dep_new (name, has_epoch, epoch, version, release,
- relation, RC_TYPE_RESOLVABLE, RC_CHANNEL_ANY,
- false, false);
-
- g_free (tmp);
- g_free (name);
- g_free (version);
- g_free (release);
-
- return dep;
- } /* rc_xml_node_to_resItem_dep_internal */
-
- RCResItemDep *
- rc_xml_node_to_resItem_dep (const xmlNode *node)
- {
- RCResItemDep *dep = NULL;
-
- if (!g_strcasecmp (node->name, "dep")) {
- dep = rc_xml_node_to_resItem_dep_internal (node);
- return (dep);
- } else if (!g_strcasecmp (node->name, "or")) {
- RCResItemDepSList *or_dep_slist = NULL;
- RCDepOr *or;
- xmlNode *iter = node->xmlChildrenNode;
-
- while (iter) {
- if (iter->type == XML_ELEMENT_NODE) {
- or_dep_slist = g_slist_append(
- or_dep_slist,
- rc_xml_node_to_resItem_dep_internal (iter));
- }
-
- iter = iter->next;
- }
-
- or = rc_dep_or_new (or_dep_slist);
- dep = rc_dep_or_new_provide (or);
- }
-
- return (dep);
- } /* rc_xml_node_to_resItem_dep */
-
- /* ------ */
-
- /* This hack cleans 8-bit characters out of a string. This is a very
- problematic "solution" to the problem of non-UTF-8 package info. */
- static gchar *
- sanitize_string (const char *str)
- {
- gchar *dup = g_strdup (str);
- gchar *c;
-
- return dup;
-
- if (dup) {
- for (c = dup; *c; ++c) {
- if ((guint)*c > 0x7f)
- *c = '_';
- }
- }
-
- return dup;
- }
-
- #endif
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
+ has_epoch = xml_get_guint32_value (node, "epoch", &epoch);
+
+ version = xml_get_prop (node, "version");
+ release = xml_get_prop (node, "release");
+ } else {
+ relation = RC_RELATION_ANY;
+ }
+
+ /* FIXME: should get channel from XML */
+ dep = rc_resItem_dep_new (name, has_epoch, epoch, version, release,
+ relation, RC_TYPE_RESOLVABLE, RC_CHANNEL_ANY,
+ false, false);
+
+ g_free (tmp);
+ g_free (name);
+ g_free (version);
+ g_free (release);
+
+ return dep;
+ } /* rc_xml_node_to_resItem_dep_internal */
+
+ RCResItemDep *
+ rc_xml_node_to_resItem_dep (const xmlNode *node)
+ {
+ RCResItemDep *dep = NULL;
+
+ if (!g_strcasecmp (node->name, "dep")) {
+ dep = rc_xml_node_to_resItem_dep_internal (node);
+ return (dep);
+ } else if (!g_strcasecmp (node->name, "or")) {
+ RCResItemDepSList *or_dep_slist = NULL;
+ RCDepOr *or;
+ xmlNode *iter = node->xmlChildrenNode;
+
+ while (iter) {
+ if (iter->type == XML_ELEMENT_NODE) {
+ or_dep_slist = g_slist_append(
+ or_dep_slist,
+ rc_xml_node_to_resItem_dep_internal (iter));
+ }
+
+ iter = iter->next;
+ }
+
+ or = rc_dep_or_new (or_dep_slist);
+ dep = rc_dep_or_new_provide (or);
+ }
+
+ return (dep);
+ } /* rc_xml_node_to_resItem_dep */
+
+ /* ------ */
+
+ /* This hack cleans 8-bit characters out of a string. This is a very
+ problematic "solution" to the problem of non-UTF-8 package info. */
+ static gchar *
+ sanitize_string (const char *str)
+ {
+ gchar *dup = g_strdup (str);
+ gchar *c;
+
+ return dup;
+
+ if (dup) {
+ for (c = dup; *c; ++c) {
+ if ((guint)*c > 0x7f)
+ *c = '_';
+ }
+ }
+
+ return dup;
+ }
+
+#endif
+ ///////////////////////////////////////////////////////////////////
+ };// namespace detail
+ /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ };// namespace solver
+ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
};// namespace zypp
/////////////////////////////////////////////////////////////////////////
#include <zypp/solver/detail/Channel.h>
#include <zypp/solver/detail/Package.h>
-#include <zypp/solver/detail/Dependency.h>
+#include <zypp/CapSet.h>
#include <zypp/solver/detail/XmlNode.h>
/////////////////////////////////////////////////////////////////////////
bool _current_package_packageSet;
PackageUpdateList _current_package_packageUpdateList;
- CDependencyList _current_requires;
- CDependencyList _current_provides;
- CDependencyList _current_conflicts;
- CDependencyList _current_children;
- CDependencyList _current_recommends;
- CDependencyList _current_suggests;
- CDependencyList _current_obsoletes;
+ CapSet _current_requires;
+ CapSet _current_provides;
+ CapSet _current_conflicts;
+ CapSet _current_children;
+ CapSet _current_recommends;
+ CapSet _current_suggests;
+ CapSet _current_obsoletes;
PackageUpdatePtr _current_update;
// these point to one of the above lists during dependency parsing
- CDependencyList *_toplevel_dep_list;
- CDependencyList *_current_dep_list;
+ CapSet *_toplevel_dep_list;
+ CapSet *_current_dep_list;
char *_text_buffer;
size_t _text_buffer_size;
#define _LIBzypp_H
#include <zypp/solver/detail/Channel.h>
-#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Match.h>
#include <zypp/solver/detail/ResItem.h>
#include <zypp/solver/detail/Spec.h>