#include <zypp/solver/detail/OrDependency.h>
#include <zypp/solver/detail/Version.h>
#include <zypp/Arch.h>
+#include <zypp/Edition.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
res += dependency.relation().asString();
res += " ";
- res += dependency.edition()->asString();
+ res += dependency.edition().asString();
}
if (dependency.orDep()) res += " [OR]";
if (dependency.preDep()) res += " [PRE]";
Dependency::Dependency (const string & name, const Relation & relation, const Resolvable::Kind & kind,
- constChannelPtr channel, constEditionPtr edition, bool or_dep, bool pre_dep)
+ constChannelPtr channel, const Edition & edition, bool or_dep, bool pre_dep)
: Spec (kind, name, edition)
, _relation (relation)
, _channel (channel)
tmp = node->getProp ("op", NULL);
if (tmp) {
_relation = Relation::parse(tmp);
- setEpoch (node->getIntValueDefault ("epoch", -1));
+ setEpoch (node->getIntValueDefault ("epoch", Edition::noepoch));
setVersion (node->getProp ("version"));
setRelease (node->getProp ("release"));
}
compare_ret = 1;
}
} else if (epoch() > 0 ) {
- compare_ret = -1;
+ 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 (GVersion.hasProperty (VERSION_PROP_ALWAYS_VERIFY_RELEASE)
|| (!(release().empty() || prov->release().empty()))) {
- newdepspec = new Spec(kind(), "", -1, version(), release());
- newprovspec = new Spec(prov->kind(), "", -1, prov->version(), prov->release());
+ newdepspec = new Spec(kind(), "", Edition::noepoch, version(), release());
+ newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version(), prov->release());
} else {
- newdepspec = new Spec(kind(), "", -1, version());
- newprovspec = new Spec(prov->kind(), "", -1, prov->version());
+ newdepspec = new Spec(kind(), "", Edition::noepoch, version());
+ newprovspec = new Spec(prov->kind(), "", Edition::noepoch, prov->version());
}
compare_ret = GVersion.compare (newprovspec, newdepspec);
}
bool _pre_dep;
public:
-
+
Dependency (const std::string & name,
const Relation & relation,
const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
constChannelPtr channel = NULL,
- int epoch = -1,
+ int epoch = Edition::noepoch,
const std::string & version = "",
const std::string & release = "",
const zypp::Arch & arch = zypp::Arch(),
bool or_dep = false,
bool pre_dep = false);
-
+
Dependency (const std::string & name,
const Relation & relation,
- const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
+ const Resolvable::Kind & kind = ResTraits<zypp::Package>::kind,
constChannelPtr channel = NULL,
- constEditionPtr edition = NULL,
+ const zypp::Edition & edition = zypp::Edition(),
bool or_dep = false,
bool pre_dep = false);
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);
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Edition.cc
- *
- * Definition of 'edition'
- * contains epoch-version-release-arch
- * and comparision functions
- *
- * 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.
- */
-
-#include <y2util/stringutil.h>
-
-#include <zypp/solver/detail/Edition.h>
-#include <zypp/solver/detail/Version.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- using namespace std;
-
- IMPL_BASE_POINTER(Edition);
-
- //---------------------------------------------------------------------------
-
- string
- Edition::asString ( bool full ) const
- {
- return toString (*this, full);
- }
-
-
- string
- Edition::toString ( const Edition & edition, bool full )
- {
- string res ("");
-
- if (edition._epoch >= 0) {
- res += stringutil::numstring (edition._epoch);
- res += ":";
- }
-
- res += edition._version;
- if (!edition._release.empty()) {
- res += "-";
- res += edition._release;
- }
-
- if (full) {
- res += ".";
- res += edition._arch.asString();
- }
-
- return res;
- }
-
-
- ostream &
- Edition::dumpOn( ostream & str ) const
- {
- str << asString();
- return str;
- }
-
-
- ostream&
- operator<<( ostream& os, const Edition& edition)
- {
- return os << edition.asString();
- }
-
- //---------------------------------------------------------------------------
-
- Edition::Edition( int epoch, const string & version, const string & release, const zypp::Arch & arch)
- : _epoch (epoch)
- , _version (version)
- , _release (release)
- , _arch (arch)
- {
- }
-
-
- Edition::~Edition()
- {
- }
-
-
- EditionPtr
- Edition::copy (void) const
- {
- return new Edition (_epoch, _version, _release, _arch);
- }
-
-
- EditionPtr
- Edition::fromString (const char *s)
- {
- return GVersion.parse (s);
- }
-
-
- bool
- Edition::match( constEditionPtr edition ) const {
- //fprintf (stderr, "<%s> match <%s>\n", asString().c_str(), edition->asString().c_str());
- if (_epoch != edition->_epoch) return false;
- //fprintf (stderr, "epoch ok\n");
- if (_version != edition->_version) return false;
- //fprintf (stderr, "version ok\n");
- if (_release != edition->_release) return false;
- //fprintf (stderr, "release ok\n");
- if (_arch != edition->_arch) return false;
- //fprintf (stderr, "arch ok\n");
- return true;
- }
-
-
- bool
- Edition::equals( constEditionPtr edition ) const {
- //fprintf (stderr, "<%s> equals <%s>\n", asString().c_str(), edition->asString().c_str());
- return match (edition);
- }
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Edition.h
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * Definition of 'edition'
- * contains epoch-version-release-arch
- * and comparision functions
- *
- * 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 _Edition_h
-#define _Edition_h
-
-#include <iosfwd>
-#include <string>
-
-#include <y2util/Ustring.h>
-
-#include <zypp/solver/detail/EditionPtr.h>
-#include <zypp/solver/detail/XmlNodePtr.h>
-#include <zypp/Arch.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Edition
- /**
- *
- **/
- class Edition : public CountedRep {
- REP_BODY(Edition);
-
- private:
- int _epoch;
- std::string _version;
- std::string _release;
- zypp::Arch _arch;
-
- public:
-
- //
- // -1 resp. NULL values are treated as 'any'
- //
-
- Edition( int epoch = -1, const std::string & version = "", const std::string & release = "", const Arch & arch = zypp::Arch());
- virtual ~Edition();
-
- // ---------------------------------- I/O
-
- const XmlNodePtr asXmlNode (void) const;
-
- static std::string toString ( const Edition & edition, bool full = false );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- friend std::ostream& operator<<( std::ostream&, const Edition& );
-
- std::string asString ( bool full = false ) const;
-
- // ---------------------------------- accessors
-
- void setVersion (const std::string & version) { _version = version; }
- void setRelease (const std::string & release) { _release = release; }
- void setEpoch (int epoch) { _epoch = epoch; }
- void setArch (const std::string & arch) { _arch = zypp::Arch(arch); }
- void setArch (const zypp::Arch & arch) { _arch = arch; }
-
- const std::string & version() const { return _version; }
- const std::string & release() const { return _release; }
- const int epoch() const { return _epoch; }
- bool hasEpoch() const { return _epoch >= 0; }
- const zypp::Arch & arch() const { return _arch; }
-
- bool match( constEditionPtr edition ) const;
- bool equals( constEditionPtr edition ) const;
-
- // ---------------------------------- accessors
-
- EditionPtr copy (void) const;
- static EditionPtr fromString (const char *s);
-
- };
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _Edition_h
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* EditionPtr.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 _EditionPtr_h
-#define _EditionPtr_h
-
-#include <y2util/RepDef.h>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- // CLASS NAME : EditionPtr
- // CLASS NAME : constEditionPtr
- ///////////////////////////////////////////////////////////////////
- DEFINE_BASE_POINTER(Edition);
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-#endif // _EditionPtr_h
debug.h \
utils.h \
extract.h \
- Edition.h \
- EditionPtr.h \
Hash.h \
Spec.h \
SpecPtr.h \
lib@PACKAGE@_solver_detail_la_SOURCES = \
utils.cc \
debug.cc \
- Edition.cc \
Spec.cc \
Channel.cc \
Subscription.cc \
#define _MatchPtr_h
#include <y2util/RepDef.h>
-#include <zypp/solver/detail/Edition.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
#include <zypp/solver/detail/OrDependency.h>
#include <zypp/solver/detail/Dependency.h>
+#include <zypp/solver/detail/Version.h>
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
SpecPtr spec;
char *name;
Relation relation = Relation::Any;
- EditionPtr edition = NULL;
+ zypp::Edition edition;
/* grab the name */
/* e .. p is the epoch:version-release */
vstr = strndup (e, p - e);
- EditionPtr edition = Edition::fromString (vstr);
+ zypp::Edition edition = GVersion.parse (vstr);
free ((void *)vstr);
}
-
- DependencyPtr dep = new Dependency (name, relation, ResTraits<zypp::Package>::kind, NULL, edition);
-
+
+
+ DependencyPtr dep = new Dependency (name, relation, ResTraits<zypp::Package>::kind, NULL, edition );
+
out_dep.push_back (dep);
free ((void *)name);
if (version) {
- setEpoch (epoch ? atoi (epoch) : -1);
+ setEpoch (epoch ? atoi (epoch) : Edition::noepoch);
setVersion (version);
setRelease (release);
UpgradeCandidateInfo upgrade_info;
upgrade_info.context = info->context;
- DependencyPtr maybe_upgrade_dep = new Dependency (resItem->name(), Relation::Any, ResTraits<zypp::Package>::kind, new Channel (CHANNEL_TYPE_NONSYSTEM), -1);
+ DependencyPtr maybe_upgrade_dep = new Dependency (resItem->name(), Relation::Any, ResTraits<zypp::Package>::kind, new Channel (CHANNEL_TYPE_NONSYSTEM), Edition::noepoch);
info->world->foreachProvidingResItem (maybe_upgrade_dep, upgrade_candidates_cb, (void *)&upgrade_info);
#endif
#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Channel.h>
#include <zypp/ResObject.h>
+#include <zypp/Edition.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
public:
- ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = -1, const std::string & version = "", const std::string & release = "", const zypp::Arch & arch = zypp::Arch());
+ ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = Edition::noepoch, const std::string & version = "", const std::string & release = "", const zypp::Arch & arch = zypp::Arch());
ResItem(const ResObject::Ptr & resObject);
ResItem(const XmlNodePtr node);
const std::string name() const { return _name; }
void setName (const std::string & name) { _name = Name(name.c_str()); }
- constEditionPtr edition() const { return _edition; }
- void setEdition (constEditionPtr edition) { _edition = edition->copy(); }
+ const Edition & edition() const { return _edition; }
+ void setEdition (const Edition & edition) { _edition = edition }
#endif
};
res += spec.name();
- string ed = spec.edition()->asString (full);
- if (!ed.empty()) {
+ string ed = spec.edition().asString();
+ if (!ed.empty() &&
+ ed != "EDITION-UNSPEC") {
res += "-";
res += ed;
}
-
+
+ if (spec.arch() != zypp::Arch_noarch) {
+ res += ".";
+ res += spec.arch().asString();
+ }
+
+
return res;
}
//---------------------------------------------------------------------------
- Spec::Spec (const Resolvable::Kind & kind, const string & name, constEditionPtr edition)
+ Spec::Spec (const Resolvable::Kind & kind, const string & name, const Edition & edition, const zypp::Arch & arch)
: _kind (kind)
, _name (Name (name))
- , _edition (edition == NULL ? new Edition() : edition->copy())
+ , _edition (edition)
+ , _arch (arch)
{
}
Spec::Spec ( const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const zypp::Arch & arch)
: _kind (kind)
, _name (Name (name))
- , _edition (new Edition (epoch, version, release, arch))
+ , _edition (Edition (version, release, epoch))
+ , _arch(arch)
{
}
HashValue
Spec::hash (void) const
{
- HashValue ret = _edition->epoch() + 1;
+ HashValue ret = _edition.epoch() + 1;
const char *spec_strs[3], *p;
int i;
spec_strs[0] = _name.asString().c_str();
- spec_strs[1] = _edition->version().c_str();
- spec_strs[2] = _edition->release().c_str();
+ spec_strs[1] = _edition.version().c_str();
+ spec_strs[2] = _edition.release().c_str();
for (i = 0; i < 3; ++i) {
p = spec_strs[i];
Spec::match(constSpecPtr spec) const {
return ((_kind == spec->kind())
&& (_name == spec->name())
- && _edition->match (spec->edition()));
+ && Edition::compare( _edition, spec->edition()) == 0);
}
//fprintf (stderr, "<%s> equals <%s>\n", asString(true).c_str(), spec->asString(true).c_str());
return ((_kind == spec->kind())
&& (_name == spec->name())
- && _edition->equals(spec->edition()));
+ && Edition::compare( _edition, spec->edition()) == 0);
}
+
+ void Spec::setVersion (const std::string & version) {
+ Edition newEdition(version,
+ _edition.release(),
+ _edition.epoch());
+ _edition = newEdition;
+ }
+
+ void Spec::setRelease (const std::string & release) {
+ Edition newEdition(_edition.version(),
+ release,
+ _edition.epoch());
+ _edition = newEdition;
+ }
+
+ void Spec::setEpoch (int epoch) {
+ Edition newEdition(_edition.version(),
+ _edition.release(),
+ epoch);
+ _edition = newEdition;
+ }
+
///////////////////////////////////////////////////////////////////
};// namespace detail
#include <zypp/solver/detail/Hash.h>
#include <zypp/solver/detail/SpecPtr.h>
#include <zypp/solver/detail/XmlNode.h>
-#include <zypp/solver/detail/Edition.h>
+#include <zypp/Edition.h>
#include <zypp/ResObject.h>
/////////////////////////////////////////////////////////////////////////
private:
Resolvable::Kind _kind;
Name _name;
- EditionPtr _edition;
+ Edition _edition;
+ Arch _arch;
public:
typedef std::list<Spec> SpecList;
Spec( const Resolvable::Kind & kind,
const std::string & name,
- int epoch = -1,
+ int epoch = Edition::noepoch,
const std::string & version = "",
const std::string & release = "",
const zypp::Arch & arch = Arch());
- Spec (const Resolvable::Kind & kind, const std::string & name, constEditionPtr edition);
+ Spec (const Resolvable::Kind & kind, const std::string & name, const Edition & edition, const zypp::Arch & arch = Arch());
Spec (constXmlNodePtr node);
// ---------------------------------- accessors
- const std::string & version() const { return _edition->version(); }
- void setVersion (const std::string & version) { _edition->setVersion (version); }
+ const std::string & version() const { return _edition.version(); }
+ void setVersion (const std::string & version);
- const std::string & release() const { return _edition->release(); }
- void setRelease (const std::string & release) { _edition->setRelease (release); }
+ const std::string & release() const { return _edition.release(); }
+ void setRelease (const std::string & release);
- const int epoch() const { return _edition->epoch(); }
- void setEpoch (int epoch) { _edition->setEpoch (epoch); }
- bool hasEpoch() const { return _edition->hasEpoch(); }
+ const int epoch() const { return _edition.epoch(); }
+ void setEpoch (int epoch);
+ bool hasEpoch() const { return _edition.epoch() > 0; }
- const zypp::Arch & arch() const { return _edition->arch(); }
- void setArch (const Arch & arch) { _edition->setArch (arch); }
- void setArch (const std::string & arch) { _edition->setArch (arch); }
+ const zypp::Arch & arch() const { return _arch; }
+ void setArch (const Arch & arch) { _arch = arch; }
+ void setArch (const std::string & arch) { _arch = Arch(arch); }
const Resolvable::Kind & kind() const { return _kind; }
void setKind (const Resolvable::Kind & kind) { _kind = kind; }
const std::string name() const { return _name; }
void setName (const std::string & name) { _name = Name(name.c_str()); }
- constEditionPtr edition() const { return _edition; }
- void setEdition (constEditionPtr edition) { _edition = edition->copy(); }
+ const Edition & edition() const { return _edition; }
+ void setEdition (const Edition & edition) { _edition = edition; }
// calculate hash
HashValue hash (void) const;
//---------------------------------------------------------------------------
- static EditionPtr
+ static Edition
rpm_parse (const char *input)
{
const char *vptr = NULL, *rptr = NULL;
if (input == NULL || *input == 0)
- return NULL;
+ {
+ return Edition();
+ }
- int epoch = -1;
+ int epoch = Edition::noepoch;
const char *version;
const char *release;
if (endptr != vptr) {
/* No epoch here, just a : in the version string */
- epoch = -1;
+ epoch = Edition::noepoch;
vptr = input;
} else {
vptr++;
release = NULL;
}
- EditionPtr edition = new Edition(epoch, version, release, zypp::Arch());
+ Edition edition( version, release, epoch);
return edition;
}
#include <y2util/Ustring.h>
#include <zypp/solver/detail/Spec.h>
+#include <zypp/Edition.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
unsigned int _properties;
- EditionPtr (*_parse)(const char *input);
+ Edition (*_parse)(const char *input);
// compare uses SpecPtr and takes name into account
int (*_compare)(constSpecPtr a, constSpecPtr b);
// compare uses SpecPtr and takes name into account
int compare (constSpecPtr a, constSpecPtr b) const { return (*_compare) (a, b); }
- EditionPtr parse (const char *input) const { return (*_parse)(input); }
+ Edition parse (const char *input) const { return (*_parse)(input); }
bool hasProperty (unsigned int property) const { return (_properties & property) != 0; }
bool op_present = false;
/* Temporary variables dependent upon the presense of an 'op' attribute */
const char *name = NULL;
- int epoch = -1;
+ int epoch = Edition::noepoch;
string version;
string release;
- string arch;
+ string arch = "";
Relation relation = Relation::Any;
*is_obsolete = false;
/* FIXME: should get Channel from XML */
/* FIXME: should get Kind from XML */
- return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch(arch));
+ if ( std::strlen(arch.c_str()) > 0)
+ {
+ return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch(arch));
+ }
+ else
+ {
+ return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, zypp::Arch_noarch);
+ }
}