*/
#include <iostream>
#include <set>
+#include <sys/utsname.h>
#include "zypp/Arch.h"
/** Dumb Arch compat table
* \todo improve
- */
+ */
struct CompatTable
{
- static set<string> _compatTable;
+ static set<string> _compatTable;
- /** \return Whether \a lhs is compatible with \a rhs. */
- static bool compatible( const zypp::Arch & lhs, const zypp::Arch & rhs )
- {
- if ( lhs == zypp::Arch_noarch )
- return true;
+ /** \return Whether \a lhs is compatible with \a rhs. */
+ static bool compatible( const zypp::Arch & lhs, const zypp::Arch & rhs )
+ {
+ if ( lhs == zypp::Arch_noarch )
+ return true;
- if ( _compatTable.empty() )
- {
- // initialize
+ if ( _compatTable.empty() )
+ {
+ // initialize
#define DEF_COMPAT(L,R) _compatTable.insert( #L "|" #R )
- DEF_COMPAT( noarch, i386 );
- DEF_COMPAT( noarch, i486 );
- DEF_COMPAT( i386, i486 );
- DEF_COMPAT( noarch, i586 );
- DEF_COMPAT( i386, i586 );
- DEF_COMPAT( i486, i586 );
- DEF_COMPAT( noarch, i686 );
- DEF_COMPAT( i386, i686 );
- DEF_COMPAT( i486, i686 );
- DEF_COMPAT( i586, i686 );
- DEF_COMPAT( noarch, athlon );
- DEF_COMPAT( i386, athlon );
- DEF_COMPAT( i486, athlon );
- DEF_COMPAT( i586, athlon );
- DEF_COMPAT( i686, athlon );
- DEF_COMPAT( noarch, x86_64 );
- DEF_COMPAT( i386, x86_64 );
- DEF_COMPAT( i486, x86_64 );
- DEF_COMPAT( i586, x86_64 );
- DEF_COMPAT( i686, x86_64 );
- DEF_COMPAT( athlon, x86_64 );
-
- DEF_COMPAT( noarch, s390 );
- DEF_COMPAT( noarch, s390x );
- DEF_COMPAT( s390, s390x );
-
- DEF_COMPAT( noarch, ppc );
- DEF_COMPAT( noarch, ppc64 );
- DEF_COMPAT( ppc, ppc64 );
-
- DEF_COMPAT( noarch, ia64 );
+ DEF_COMPAT( noarch, i386 );
+ DEF_COMPAT( noarch, i486 );
+ DEF_COMPAT( i386, i486 );
+ DEF_COMPAT( noarch, i586 );
+ DEF_COMPAT( i386, i586 );
+ DEF_COMPAT( i486, i586 );
+ DEF_COMPAT( noarch, i686 );
+ DEF_COMPAT( i386, i686 );
+ DEF_COMPAT( i486, i686 );
+ DEF_COMPAT( i586, i686 );
+ DEF_COMPAT( noarch, athlon );
+ DEF_COMPAT( i386, athlon );
+ DEF_COMPAT( i486, athlon );
+ DEF_COMPAT( i586, athlon );
+ DEF_COMPAT( i686, athlon );
+ DEF_COMPAT( noarch, x86_64 );
+ DEF_COMPAT( i386, x86_64 );
+ DEF_COMPAT( i486, x86_64 );
+ DEF_COMPAT( i586, x86_64 );
+ DEF_COMPAT( i686, x86_64 );
+ DEF_COMPAT( athlon, x86_64 );
+
+ DEF_COMPAT( noarch, s390 );
+ DEF_COMPAT( noarch, s390x );
+ DEF_COMPAT( s390, s390x );
+
+ DEF_COMPAT( noarch, ppc );
+ DEF_COMPAT( noarch, ppc64 );
+ DEF_COMPAT( ppc, ppc64 );
+
+ DEF_COMPAT( noarch, ia64 );
#undef DEF_COMPAT
- }
+ }
- return _compatTable.find( lhs.asString()+"|"+rhs.asString() )
- != _compatTable.end();
- }
+ return _compatTable.find( lhs.asString()+"|"+rhs.asString() )
+ != _compatTable.end();
+ }
};
- set<string> CompatTable::_compatTable;
+ set<string> CompatTable::_compatTable;
- /////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
} // namespace
///////////////////////////////////////////////////////////////////
DEF_BUILTIN( ia64 );
#undef DEF_BUILTIN
+
+ static const string system_arch (void);
+ static const string canonical_arch (const string & arch);
+
+
+ const Arch Arch::System = Arch(system_arch ());
+
+ //---------------------------------------------------------------------------
+ // architecture stuff
+
+ static const string
+ canonical_arch (const string & arch)
+ {
+ typedef struct { char *from; char *to; } canonical;
+ // convert machine string to known_arch
+ static canonical canonical_archs[] = {
+ { "noarch", "noarch" },
+ { "unknown", "unknown" },
+ { "any", "any" },
+ { "all", "any" },
+ { "i386", "i386" },
+ { "ix86", "i386" }, /* OpenPKG uses this */
+ { "i486", "i486" },
+ { "i586", "i586" },
+ { "i686", "i686" },
+ { "x86_64", "x86_64" },
+ { "ia32e", "ia32e" },
+ { "athlon", "athlon" },
+ { "ppc", "ppc" },
+ { "ppc64", "ppc64" },
+ { "s390", "s390" },
+ { "s390x", "s390x" },
+ { "ia64", "ia64" },
+ { "sparc", "sparc" },
+ { "sun4c", "sparc" },
+ { "sun4d", "sparc" },
+ { "sun4m", "sparc" },
+ { "sparc64", "sparc64" },
+ { "sun4u", "sparc64" },
+ { "sparcv9", "sparc64" },
+ { 0 }
+ };
+
+ for (canonical *ptr = canonical_archs; ptr->from; ptr++) {
+ if (arch == ptr->from) {
+ return ptr->to;
+ }
+ }
+
+ return "canonical";
+ }
+
+
+ static const string
+ system_arch (void)
+ {
+ static struct utsname buf;
+ static bool checked = false;
+
+ if (!checked) {
+ if (uname (&buf) < 0) {
+ return NULL;
+ }
+ checked = true;
+ }
+
+ return string (buf.machine);
+ }
+
+
+ //---------------------------------------------------------------------------
+
+
+
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
*/
bool compatibleWith( const Arch & rhs ) const;
+ /** Architecture of the current working system
+ * \return \c Arch.
+ */
+ static const Arch System;
+
private:
/** String representation of Arch. */
std::string _value;
/** */
const Kind & kind() const
{ return _kind; }
+ /** */
+ void setKind( const Kind & val_r )
+ { _kind = val_r; }
+
/** */
const std::string & name() const
{ return _name; }
/** */
+ void setName( const std::string & val_r )
+ { _name = val_r; }
+
+ /** */
const Edition & edition() const
{ return _edition; }
/** */
+ void setEdition( const Edition & val_r )
+ { _edition = val_r; }
+
+ /** */
const Arch & arch() const
{ return _arch; }
/** */
+ void setArch( const Arch & val_r )
+ { _arch = val_r; }
+
+ /** */
const Dependencies & deps() const
{ return _deps; }
void setDeps( const Dependencies & val_r )
{ _deps = val_r; }
+
+
private:
/** */
Kind _kind;
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Arch.cc
- *
- * 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.
- */
-
-#include <y2util/stringutil.h>
-#include <sys/utsname.h>
-
-#include <zypp/solver/detail/Arch.h>
-#include <zypp/solver/detail/utils.h>
-
-#if 0
-static char *known_archs[] = {
- "", "*", "?", // noarch, any, unknown
- "i386", "i486", "i586", "i686",
- "x86-64", "x86_64", "ia32e", "athlon",
- "ppc", "ppc64",
- "s390", "s390x",
- "ia64",
- "sparc", "sparc64"
-};
-#endif
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- using namespace std;
-
- static const string system_arch (void);
- static const string canonical_arch (const string & arch);
-
- //---------------------------------------------------------------------------
-
- const Arch * Arch::Unknown = Arch::create ("unknown");
- const Arch * Arch::Any = Arch::create ("any");
- const Arch * Arch::Noarch = Arch::create ("noarch");
- const Arch * Arch::System = Arch::create (system_arch ());
-
- //---------------------------------------------------------------------------
- // architecture stuff
-
- static const string
- canonical_arch (const string & arch)
- {
- typedef struct { char *from; char *to; } canonical;
- // convert machine string to known_arch
- static canonical canonical_archs[] = {
- { "noarch", "noarch" },
- { "unknown", "unknown" },
- { "any", "any" },
- { "all", "any" },
- { "i386", "i386" },
- { "ix86", "i386" }, /* OpenPKG uses this */
- { "i486", "i486" },
- { "i586", "i586" },
- { "i686", "i686" },
- { "x86_64", "x86_64" },
- { "ia32e", "ia32e" },
- { "athlon", "athlon" },
- { "ppc", "ppc" },
- { "ppc64", "ppc64" },
- { "s390", "s390" },
- { "s390x", "s390x" },
- { "ia64", "ia64" },
- { "sparc", "sparc" },
- { "sun4c", "sparc" },
- { "sun4d", "sparc" },
- { "sun4m", "sparc" },
- { "sparc64", "sparc64" },
- { "sun4u", "sparc64" },
- { "sparcv9", "sparc64" },
- { 0 }
- };
-
- for (canonical *ptr = canonical_archs; ptr->from; ptr++) {
- if (arch == ptr->from) {
- return ptr->to;
- }
- }
-
- return "canonical";
- }
-
-
- static const string
- system_arch (void)
- {
- static struct utsname buf;
- static bool checked = false;
-
- if (!checked) {
- if (uname (&buf) < 0) {
- return NULL;
- }
- checked = true;
- }
-
- return string (buf.machine);
- }
-
-
- //---------------------------------------------------------------------------
-
- const string
- Arch::asString ( void ) const
- {
- return toString (*this);
- }
-
-
- const string
- Arch::toString ( const Arch & arch )
- {
- return arch._arch;
- }
-
-
- ostream &
- Arch::dumpOn( ostream & str ) const
- {
- str << asString();
- return str;
- }
-
-
- ostream&
- operator<<( ostream & os, const Arch & arch)
- {
- return os << arch.asString();
- }
-
- //---------------------------------------------------------------------------
-
- Arch::Arch( const string & a)
- : _arch (a)
- {
- }
-
-
- const Arch *
- Arch::create (const string & arch)
- {
- typedef std::map<const std::string, const Arch *> ArchTable;
-
- static ArchTable table;
- ArchTable::iterator pos = table.find (arch);
- if (pos != table.end()) {
- return pos->second;
- }
- const Arch *new_arch = new Arch(canonical_arch (arch));
- table.insert (ArchTable::value_type (arch, new_arch));
-
- return new_arch;
- }
-
-
- ArchList
- Arch::getCompatList () const
- {
- typedef struct {
- const char *arch;
- const char *compat_arch;
- } ArchAndCompatArch;
-
- /* _NOARCH should never be listed in this table (other than as the
- * terminator), as it will automatically be added. Every architecture
- * is implicitly compatible with itself. Compatible architectures
- * should be listed in most-preferred to least-preferred order. */
-
- static ArchAndCompatArch compat_table[] = {
- { "i486", "i386" },
- { "i586", "i486" },
- { "i586", "i386" },
- { "i686", "i586" },
- { "i686", "i486" },
- { "i686", "i386" },
- { "athlon", "i686" },
- { "athlon", "i586" },
- { "athlon", "i486" },
- { "athlon", "i386" },
- { "x86_64", "i686" },
- { "x86_64", "i586" },
- { "x86_64", "i486" },
- { "x86_64", "i386" },
- { "x86_64", "athlon" },
- { "x86_64", "ia32e" },
- { "ppc64", "ppc" },
- { "s390x", "s390" },
- { "sparc64", "sparc" },
- { 0 }
- };
-
-
- ArchAndCompatArch *iter;
- ArchList ret;
-
- ret.push_back (this); // be compatible with yourself
-
- iter = compat_table;
- while (iter->arch != NULL) {
- if (_arch == iter->arch) {
- ret.push_back (create (iter->compat_arch));
- }
- iter++;
- }
-
- return ret;
- }
-
-
- int
- Arch::getCompatScore (const ArchList & archlist) const
- {
- int score = 0;
-
- for (ArchList::const_iterator iter = archlist.begin(); iter != archlist.end(); iter++) {
- if (*iter == this) {
- return score;
- }
- score++;
- }
- return -1;
- }
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* Arch.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 _Arch_h
-#define _Arch_h
-
-#include <iosfwd>
-#include <list>
-#include <map>
-#include <string>
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
- class Arch;
- typedef std::list<const Arch *> ArchList;
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : Arch
- /**
- *
- **/
- class Arch {
-
- private:
-
- std::string _arch;
-
- explicit Arch( const std::string & a = "" );
-
- public:
- static const Arch *Any;
- static const Arch *Unknown;
- static const Arch *Noarch;
- static const Arch *System;
-
- static const Arch *create ( const std::string & arch ); // factory
- virtual ~Arch() {};
-
- // ---------------------------------- I/O
-
- static const std::string toString ( const Arch & arch );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- friend std::ostream& operator<< ( std::ostream &, const Arch & arch);
-
- const std::string asString ( void ) const;
-
- // ---------------------------------- accessors
-
- // ---------------------------------- methods
-
- bool isAny (void) const { return this == Any; }
- bool isUnknown (void) const { return this == Unknown; }
- bool isNoarch (void) const { return this == Noarch; }
-
- ArchList getCompatList () const;
- int getCompatScore (const ArchList & archlist) const;
-
- };
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-#endif // _Arch_h
#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/OrDependency.h>
#include <zypp/solver/detail/Version.h>
+#include <zypp/Arch.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
Dependency::Dependency (const string & name, const Relation & relation, const Resolvable::Kind & kind,
constChannelPtr channel,
- int epoch, const string & version, const string & release, const Arch * arch,
+ int epoch, const string & version, const string & release, const zypp::Arch * arch,
bool or_dep, bool pre_dep)
: Spec (kind, name, epoch, version, release, arch)
, _relation (relation)
tmp = node->getProp ("arch", NULL);
if (tmp) {
- setArch (Arch::create (node->getProp ("arch")));
+ setArch (new Arch(node->getProp ("arch")));
} else {
- setArch (Arch::Unknown);
+ setArch (new Arch());
}
#if 0
tmp = node->getProp ("kind", NULL);
int epoch = -1,
const std::string & version = "",
const std::string & release = "",
- const Arch * arch = Arch::Any,
+ const zypp::Arch * arch = new zypp::Arch(),
bool or_dep = false,
bool pre_dep = false);
//---------------------------------------------------------------------------
- Edition::Edition( int epoch, const string & version, const string & release, const Arch * arch)
+ Edition::Edition( int epoch, const string & version, const string & release, const zypp::Arch * arch)
: _epoch (epoch)
, _version (version)
, _release (release)
#include <zypp/solver/detail/EditionPtr.h>
#include <zypp/solver/detail/XmlNodePtr.h>
-#include <zypp/solver/detail/Arch.h>
+#include <zypp/Arch.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
int _epoch;
std::string _version;
std::string _release;
- const Arch *_arch;
+ const 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 = Arch::Unknown);
+ Edition( int epoch = -1, const std::string & version = "", const std::string & release = "", const Arch * arch = new zypp::Arch());
virtual ~Edition();
// ---------------------------------- I/O
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 = Arch::create(arch); }
- void setArch (const Arch * arch) { _arch = arch; }
+ void setArch (const std::string & arch) { _arch = new 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 Arch * arch() const { return _arch; }
+ const zypp::Arch * arch() const { return _arch; }
bool match( constEditionPtr edition ) const;
bool equals( constEditionPtr edition ) const;
debug.h \
utils.h \
extract.h \
- Arch.h \
Edition.h \
EditionPtr.h \
Hash.h \
lib@PACKAGE@_solver_detail_la_SOURCES = \
utils.cc \
debug.cc \
- Arch.cc \
Edition.cc \
Spec.cc \
Channel.cc \
if (version) free ((void *)version);
if (release) free ((void *)release);
- /* Hack for no archs in the XML yet */
- if (arch()->isUnknown())
- setArch (Arch::System);
+// /* Hack for no archs in the XML yet */
+// if (arch()->isUnknown())
+// setArch (Arch::System);
}
Package::~Package()
//---------------------------------------------------------------------------
- ResItem::ResItem (const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const Arch * arch)
+ ResItem::ResItem (const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const zypp::Arch * arch)
:Spec (kind, name, epoch, version, release, arch)
, _channel (false)
, _installed (false)
, _installed_size (0)
{
- string archString = "i386";
-
- if (arch != NULL)
- {
- archString = arch->asString();
- }
zypp::Edition _edition( version, release, zypp::str::numstring(epoch) );
- zypp::Arch _arch( archString );
// create the ResObject
shared_ptr<zypp::detail::PackageImpl> pkgImpl;
- zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( name, _edition, _arch,
+ zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( name, _edition, *arch,
pkgImpl ) );
_resObject = pkg;
public:
- ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = -1, const std::string & version = "", const std::string & release = "", const Arch * arch = Arch::Unknown);
+ ResItem(const Resolvable::Kind & kind, const std::string & name, int epoch = -1, const std::string & version = "", const std::string & release = "", const zypp::Arch * arch = new zypp::Arch());
ResItem(const ResObject::Ptr & resObject);
ResItem(const XmlNodePtr node);
const CDependencyList & freshens() const { return _freshens; }
void setFreshens (const CDependencyList & freshens) { _freshens = freshens; }
+
+ // Spec definitions
+#if 0
+ const std::string & version() const { return _edition->version(); }
+ void setVersion (const std::string & version) { _edition->setVersion (version); }
+
+ const std::string & release() const { return _edition->release(); }
+ void setRelease (const std::string & release) { _edition->setRelease (release); }
+
+ const int epoch() const { return _edition->epoch(); }
+ void setEpoch (int epoch) { _edition->setEpoch (epoch); }
+ bool hasEpoch() const { return _edition->hasEpoch(); }
+
+ const zypp::Arch * arch() const { return _edition->arch(); }
+ void setArch (const zypp::Arch * arch) { _edition->setArch (arch); }
+ void setArch (const std::string & arch) { _edition->setArch (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(); }
+#endif
};
}
- Spec::Spec ( const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const 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))
int epoch = -1,
const std::string & version = "",
const std::string & release = "",
- const Arch * arch = Arch::Unknown);
+ const zypp::Arch * arch = new zypp::Arch());
Spec (const Resolvable::Kind & kind, const std::string & name, constEditionPtr edition);
void setEpoch (int epoch) { _edition->setEpoch (epoch); }
bool hasEpoch() const { return _edition->hasEpoch(); }
- const Arch * arch() const { return _edition->arch(); }
+ 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); }
#include <zypp/solver/detail/StoreWorld.h>
#include <zypp/solver/detail/ResItemAndDependency.h>
#include <zypp/solver/detail/debug.h>
+#include <zypp/Arch.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
bool
StoreWorld::addResItem (constResItemPtr resItem)
{
- ArchList compat_arch_list;
ResItemAndDependencyPtr r_and_d;
const char *package_name;
constChannelPtr channel;
- int arch_score;
bool actually_added_package = false;
if (resItem == NULL) return false;
- compat_arch_list = Arch::System->getCompatList();
- //fprintf (stderr, "Arch::System '%s' -> %d compats\n", Arch::System->asString().c_str(), (int) compat_arch_list.size());
channel = resItem->channel ();
- // fprintf (stderr, "StoreWorld[%p]::addResItem(%s) [%s]\n", this, ((constSpecPtr)resItem)->asString().c_str(), channel?channel->name():"?");
+// fprintf (stderr, "StoreWorld[%p]::addResItem(%s) [%s]\n", this, ((constSpecPtr)resItem)->asString().c_str(), channel?channel->name():"?");
- arch_score = resItem->arch()->getCompatScore(compat_arch_list);
/* Before we do anything, check to make sure that a resItem of the
same name isn't already in that channel. If there is a
if (!resItem->isInstalled ()) { // its not a system package
constResItemPtr dup_res;
- int dup_arch_score;
/* Filter out resItems with totally incompatible arches */
- if (arch_score < 0) {
+ if ( !resItem->arch()->compatibleWith(zypp::Arch::System)) {
rc_debug (RC_DEBUG_LEVEL_DEBUG, "Ignoring resItem with incompatible arch: Arch '%s', %s", resItem->arch()->asString().c_str(), resItem->asString(true).c_str());
goto finished;
}
cmp = GVersion.compare (resItem, dup_res);
//fprintf (stderr, "res: %s, dup_res %s, cmp %d\n", resItem->asString().c_str(), dup_res->asString().c_str(), cmp);
- dup_arch_score = dup_res->arch()->getCompatScore(compat_arch_list);
-
/* If the resItem we are trying to add has a lower
version number, just ignore it. */
goto finished;
}
-
+#if 0
/* If the version numbers are equal, we ignore the resItem to
add if it has a less-preferable arch. If both
resItems have the same version # and arch, we favor the
rc_debug (RC_DEBUG_LEVEL_INFO, "\t%s", dup_res->asString().c_str());
goto finished;
}
-
+#endif
/* Otherwise we throw out the old resItem and proceed with
adding the newer one. */
#include <zypp/solver/detail/Version.h>
#include <zypp/solver/detail/debug.h>
+#include <zypp/Arch.h>
/////////////////////////////////////////////////////////////////////////
namespace zypp
release = NULL;
}
- EditionPtr edition = new Edition(epoch, version, release, Arch::create(arch));
+ EditionPtr edition = new Edition(epoch, version, release, new zypp::Arch());
return edition;
}
/* 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, Arch::create(arch));
+ return new Dependency (name, relation, ResTraits<zypp::Package>::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, new zypp::Arch(arch));
}
}
}
}
-
+
+#if 0
/* Hack for the old XML */
if (_current_package->arch()->isUnknown()) {
- _current_package->setArch (Arch::System);
+ _current_package->setArch (zypp::Arch::System);
}
-
+#endif
+
+
// check if we provide ourselfs properly
CDependencyList::const_iterator piter;
ResItemPtr resItem = fill_debian_package (iter, channel->getFilePath (), &off);
resItem->setEpoch (0);
- resItem->setArch (Arch::Noarch);
+ resItem->setArch (new Arch());
resItem->setChannel (channel);
if (callback)
#ifndef _LIBzypp_H
#define _LIBzypp_H
-#include <zypp/solver/detail/Arch.h>
#include <zypp/solver/detail/Channel.h>
#include <zypp/solver/detail/Dependency.h>
#include <zypp/solver/detail/Match.h>
-DG_LOG_DOMAIN=\"testsuite\" \
-Wall
-LIBZYPP_LIBS = -lxml2 -lz -lm -ly2util -lpthread -lrt -lz -lbz2
+LIBZYPP_LIBS = -lxml2 -lz -lm -ly2util -lpthread -lrt -lz -lbz2 -lzypp
# We're not ready for this yet.
#check_PROGRAMS = deptestomatic
edition_single.cc
edition_single_LDFLAGS = \
- -L$(top_srcdir)/zypp/solver/detail/.libs
+ -L$(top_srcdir)/zypp/solver/detail/.libs \
+ -L$(top_srcdir)/zypp
edition_single_LDADD = \
-lzypp_solver_detail \
spec_single.cc
spec_single_LDFLAGS = \
- -L$(top_srcdir)/zypp/solver/detail/.libs
+ -L$(top_srcdir)/zypp/solver/detail/.libs \
+ -L$(top_srcdir)/zypp
spec_single_LDADD = \
-lzypp_solver_detail \
utils_single.cc
utils_single_LDFLAGS = \
- -L$(top_srcdir)/zypp/solver/detail/.libs
+ -L$(top_srcdir)/zypp/solver/detail/.libs \
+ -L$(top_srcdir)/zypp
utils_single_LDADD = \
-lzypp_solver_detail \
deptestomatic_multi.cc
deptestomatic_multi_LDFLAGS = \
- -L$(top_srcdir)/zypp/solver/detail/.libs
+ -L$(top_srcdir)/zypp/solver/detail/.libs \
+ -L$(top_srcdir)/zypp
deptestomatic_multi_LDADD = \
-lzypp_solver_detail \
*/
#include <zypp/solver/detail/Edition.h>
+#include <zypp/Arch.h>
using namespace std;
using namespace zypp::solver::detail;
bool
defaultarch(void)
{
- const Arch *arch = Arch::create(""); // the default should be 'unknown'
+ const zypp::Arch arch; // the default should be 'noarch'
- return arch == Arch::Any;
+ return arch == zypp::Arch_noarch;
}
bool
x86arch(void)
{
- const Arch *arch = Arch::create("x86");
+ const zypp::Arch arch("x86");
- return arch != Arch::Any;
+ return arch != zypp::Arch_noarch;
}
//---------------------------------------------------------------------------
bool
archEdition(void)
{
- Edition edition(0, "42", "47.11", Arch::create("x86_64"));
+ Edition edition(0, "42", "47.11", new zypp::Arch("x86_64"));
return (edition.asString() == "0:42-47.11.x86_64");
}
bool
fullEdition(void)
{
- Edition edition(1, "42", "47.11", Arch::create("x86_64"));
+ Edition edition(1, "42", "47.11", new zypp::Arch("x86_64"));
return (edition.asString() == "1:42-47.11.x86_64");
}
-defaultarch FAIL
+defaultarch PASS
x86arch PASS
emptyEdition PASS
epochEdition PASS
*/
#include <zypp/solver/detail/Spec.h>
+#include "zypp/ResObject.h"
using namespace std;
using namespace zypp::solver::detail;
bool
emptySpec (void)
{
- Spec spec(Kind::Package, "");
+ Spec spec(zypp::ResTraits<zypp::Package>::kind, "");
return spec.asString() == "";
}
bool
epochSpec(void)
{
- Spec spec(Kind::Package, "foo", 1);
+ Spec spec(zypp::ResTraits<zypp::Package>::kind, "foo", 1);
return (spec.asString() == "foo-1:");
}
bool
versionSpec(void)
{
- Spec spec(Kind::Patch, "bar", 0,"42");
+ Spec spec(zypp::ResTraits<zypp::Patch>::kind, "bar", 0,"42");
return (spec.asString() == "patch:bar-0:42");
}
bool
releaseSpec(void)
{
- Spec spec(Kind::Package, "foobar", -1,"42","47.11");
+ Spec spec(zypp::ResTraits<zypp::Package>::kind, "foobar", -1,"42","47.11");
return (spec.asString() == "foobar-42-47.11");
}
bool
archSpec(void)
{
- Spec spec(Kind::Package, "arch", 0, "42", "47.11", Arch::create("x86_64"));
+ Spec spec(zypp::ResTraits<zypp::Package>::kind, "arch", 0, "42", "47.11",
+ new zypp::Arch("x86_64"));
return (spec.asString() == "arch-0:42-47.11.x86_64");
}
bool
fullSpec(void)
{
- Spec spec(Kind::Package, "full", 1, "42", "47.11", Arch::create("x86_64"));
+ Spec spec(zypp::ResTraits<zypp::Package>::kind, "full", 1, "42", "47.11",
+ new zypp::Arch("x86_64"));
return (spec.asString() == "full-1:42-47.11.x86_64");
}