From df210da8c02aa77a57043a68eeb79e4d2a8c94ca Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Tue, 20 Dec 2005 09:20:12 +0000 Subject: [PATCH] taking zypp:Arch in the solver --- zypp/Arch.cc | 169 ++++++++++++----- zypp/Arch.h | 5 + zypp/detail/ResolvableImpl.h | 18 ++ zypp/solver/detail/Arch.cc | 261 --------------------------- zypp/solver/detail/Arch.h | 102 ----------- zypp/solver/detail/Dependency.cc | 7 +- zypp/solver/detail/Dependency.h | 2 +- zypp/solver/detail/Edition.cc | 2 +- zypp/solver/detail/Edition.h | 12 +- zypp/solver/detail/Makefile.am | 2 - zypp/solver/detail/Package.cc | 6 +- zypp/solver/detail/ResItem.cc | 11 +- zypp/solver/detail/ResItem.h | 28 ++- zypp/solver/detail/Spec.cc | 2 +- zypp/solver/detail/Spec.h | 4 +- zypp/solver/detail/StoreWorld.cc | 17 +- zypp/solver/detail/Version.cc | 3 +- zypp/solver/detail/XmlParser.cc | 11 +- zypp/solver/detail/extract.cc | 2 +- zypp/solver/detail/libzypp_solver.h | 1 - zypp/solver/testsuite/Makefile.am | 14 +- zypp/solver/testsuite/edition_single.cc | 13 +- zypp/solver/testsuite/single.out/edition.out | 2 +- zypp/solver/testsuite/spec_single.cc | 15 +- 24 files changed, 233 insertions(+), 476 deletions(-) delete mode 100644 zypp/solver/detail/Arch.cc delete mode 100644 zypp/solver/detail/Arch.h diff --git a/zypp/Arch.cc b/zypp/Arch.cc index e73e3bc..1eabb80 100644 --- a/zypp/Arch.cc +++ b/zypp/Arch.cc @@ -11,6 +11,7 @@ */ #include #include +#include #include "zypp/Arch.h" @@ -22,63 +23,63 @@ namespace /** Dumb Arch compat table * \todo improve - */ + */ struct CompatTable { - static set _compatTable; + static set _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 CompatTable::_compatTable; + set CompatTable::_compatTable; - ///////////////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////////////// } // namespace /////////////////////////////////////////////////////////////////// @@ -107,6 +108,80 @@ namespace zypp 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); + } + + + //--------------------------------------------------------------------------- + + + /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// diff --git a/zypp/Arch.h b/zypp/Arch.h index f4b1d7c..3ab49b1 100644 --- a/zypp/Arch.h +++ b/zypp/Arch.h @@ -49,6 +49,11 @@ namespace zypp */ 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; diff --git a/zypp/detail/ResolvableImpl.h b/zypp/detail/ResolvableImpl.h index bff6a2e..e73c226 100644 --- a/zypp/detail/ResolvableImpl.h +++ b/zypp/detail/ResolvableImpl.h @@ -42,16 +42,32 @@ namespace zypp /** */ 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; } @@ -61,6 +77,8 @@ namespace zypp void setDeps( const Dependencies & val_r ) { _deps = val_r; } + + private: /** */ Kind _kind; diff --git a/zypp/solver/detail/Arch.cc b/zypp/solver/detail/Arch.cc deleted file mode 100644 index e938645..0000000 --- a/zypp/solver/detail/Arch.cc +++ /dev/null @@ -1,261 +0,0 @@ -/* -*- 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 -#include - -#include -#include - -#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 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 -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/detail/Arch.h b/zypp/solver/detail/Arch.h deleted file mode 100644 index 656f227..0000000 --- a/zypp/solver/detail/Arch.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- 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 -#include -#include -#include - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - class Arch; - typedef std::list 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 diff --git a/zypp/solver/detail/Dependency.cc b/zypp/solver/detail/Dependency.cc index 06292ad..bbedb4c 100644 --- a/zypp/solver/detail/Dependency.cc +++ b/zypp/solver/detail/Dependency.cc @@ -27,6 +27,7 @@ #include #include #include +#include ///////////////////////////////////////////////////////////////////////// namespace zypp @@ -243,7 +244,7 @@ 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) @@ -301,9 +302,9 @@ namespace zypp 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); diff --git a/zypp/solver/detail/Dependency.h b/zypp/solver/detail/Dependency.h index 3cc6d81..9c157f2 100644 --- a/zypp/solver/detail/Dependency.h +++ b/zypp/solver/detail/Dependency.h @@ -137,7 +137,7 @@ namespace zypp 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); diff --git a/zypp/solver/detail/Edition.cc b/zypp/solver/detail/Edition.cc index ca39f68..9a9fd09 100644 --- a/zypp/solver/detail/Edition.cc +++ b/zypp/solver/detail/Edition.cc @@ -92,7 +92,7 @@ namespace zypp //--------------------------------------------------------------------------- - 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) diff --git a/zypp/solver/detail/Edition.h b/zypp/solver/detail/Edition.h index 2426898..ee5c326 100644 --- a/zypp/solver/detail/Edition.h +++ b/zypp/solver/detail/Edition.h @@ -32,7 +32,7 @@ #include #include -#include +#include ///////////////////////////////////////////////////////////////////////// namespace zypp @@ -57,7 +57,7 @@ namespace zypp int _epoch; std::string _version; std::string _release; - const Arch *_arch; + const zypp::Arch *_arch; public: @@ -65,7 +65,7 @@ namespace zypp // -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 @@ -85,14 +85,14 @@ namespace zypp 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; diff --git a/zypp/solver/detail/Makefile.am b/zypp/solver/detail/Makefile.am index c45cf45..f0460ec 100644 --- a/zypp/solver/detail/Makefile.am +++ b/zypp/solver/detail/Makefile.am @@ -14,7 +14,6 @@ include_HEADERS = \ debug.h \ utils.h \ extract.h \ - Arch.h \ Edition.h \ EditionPtr.h \ Hash.h \ @@ -101,7 +100,6 @@ noinst_LTLIBRARIES = lib@PACKAGE@_solver_detail.la lib@PACKAGE@_solver_detail_la_SOURCES = \ utils.cc \ debug.cc \ - Arch.cc \ Edition.cc \ Spec.cc \ Channel.cc \ diff --git a/zypp/solver/detail/Package.cc b/zypp/solver/detail/Package.cc index 3268d0b..c72fe8b 100644 --- a/zypp/solver/detail/Package.cc +++ b/zypp/solver/detail/Package.cc @@ -422,9 +422,9 @@ namespace zypp 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() diff --git a/zypp/solver/detail/ResItem.cc b/zypp/solver/detail/ResItem.cc index b88fd6b..42057ff 100644 --- a/zypp/solver/detail/ResItem.cc +++ b/zypp/solver/detail/ResItem.cc @@ -138,7 +138,7 @@ namespace zypp //--------------------------------------------------------------------------- - 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) @@ -148,18 +148,11 @@ namespace zypp , _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 pkgImpl; - zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( name, _edition, _arch, + zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( name, _edition, *arch, pkgImpl ) ); _resObject = pkg; diff --git a/zypp/solver/detail/ResItem.h b/zypp/solver/detail/ResItem.h index 79849bc..4a134a0 100644 --- a/zypp/solver/detail/ResItem.h +++ b/zypp/solver/detail/ResItem.h @@ -89,7 +89,7 @@ namespace zypp 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); @@ -149,6 +149,32 @@ namespace zypp 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 }; diff --git a/zypp/solver/detail/Spec.cc b/zypp/solver/detail/Spec.cc index 8997fe5..34f107a 100644 --- a/zypp/solver/detail/Spec.cc +++ b/zypp/solver/detail/Spec.cc @@ -99,7 +99,7 @@ namespace zypp } - 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)) diff --git a/zypp/solver/detail/Spec.h b/zypp/solver/detail/Spec.h index 51e6838..b7475f0 100644 --- a/zypp/solver/detail/Spec.h +++ b/zypp/solver/detail/Spec.h @@ -87,7 +87,7 @@ class Name : public Ustring { 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); @@ -119,7 +119,7 @@ class Name : public Ustring { 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); } diff --git a/zypp/solver/detail/StoreWorld.cc b/zypp/solver/detail/StoreWorld.cc index 77e58e0..954bb02 100644 --- a/zypp/solver/detail/StoreWorld.cc +++ b/zypp/solver/detail/StoreWorld.cc @@ -28,6 +28,7 @@ #include #include #include +#include ///////////////////////////////////////////////////////////////////////// namespace zypp @@ -96,22 +97,17 @@ 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 @@ -125,10 +121,9 @@ namespace zypp 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; } @@ -150,8 +145,6 @@ namespace zypp 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. */ @@ -162,7 +155,7 @@ namespace zypp 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 @@ -173,7 +166,7 @@ namespace zypp 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. */ diff --git a/zypp/solver/detail/Version.cc b/zypp/solver/detail/Version.cc index 2186e49..2aaca79 100644 --- a/zypp/solver/detail/Version.cc +++ b/zypp/solver/detail/Version.cc @@ -24,6 +24,7 @@ #include #include +#include ///////////////////////////////////////////////////////////////////////// namespace zypp @@ -107,7 +108,7 @@ 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; } diff --git a/zypp/solver/detail/XmlParser.cc b/zypp/solver/detail/XmlParser.cc index 323cae9..17834bb 100644 --- a/zypp/solver/detail/XmlParser.cc +++ b/zypp/solver/detail/XmlParser.cc @@ -79,7 +79,7 @@ namespace zypp /* FIXME: should get Channel from XML */ /* FIXME: should get Kind from XML */ - return new Dependency (name, relation, ResTraits::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, Arch::create(arch)); + return new Dependency (name, relation, ResTraits::kind, new Channel(CHANNEL_TYPE_ANY), epoch, version, release, new zypp::Arch(arch)); } @@ -568,12 +568,15 @@ namespace zypp } } } - + +#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; diff --git a/zypp/solver/detail/extract.cc b/zypp/solver/detail/extract.cc index 156d0d8..8605752 100644 --- a/zypp/solver/detail/extract.cc +++ b/zypp/solver/detail/extract.cc @@ -442,7 +442,7 @@ namespace zypp 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) diff --git a/zypp/solver/detail/libzypp_solver.h b/zypp/solver/detail/libzypp_solver.h index c5b79e3..9513f9b 100644 --- a/zypp/solver/detail/libzypp_solver.h +++ b/zypp/solver/detail/libzypp_solver.h @@ -21,7 +21,6 @@ #ifndef _LIBzypp_H #define _LIBzypp_H -#include #include #include #include diff --git a/zypp/solver/testsuite/Makefile.am b/zypp/solver/testsuite/Makefile.am index e526c16..db23127 100644 --- a/zypp/solver/testsuite/Makefile.am +++ b/zypp/solver/testsuite/Makefile.am @@ -13,7 +13,7 @@ INCLUDES= \ -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 @@ -26,7 +26,8 @@ edition_single_SOURCES = \ 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 \ @@ -36,7 +37,8 @@ spec_single_SOURCES = \ 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 \ @@ -46,7 +48,8 @@ utils_single_SOURCES = \ 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 \ @@ -57,7 +60,8 @@ deptestomatic_multi_SOURCES = \ 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 \ diff --git a/zypp/solver/testsuite/edition_single.cc b/zypp/solver/testsuite/edition_single.cc index 77a7aec..6f42d77 100644 --- a/zypp/solver/testsuite/edition_single.cc +++ b/zypp/solver/testsuite/edition_single.cc @@ -22,6 +22,7 @@ */ #include +#include using namespace std; using namespace zypp::solver::detail; @@ -31,17 +32,17 @@ 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; } //--------------------------------------------------------------------------- @@ -80,7 +81,7 @@ releaseEdition(void) 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"); } @@ -88,7 +89,7 @@ archEdition(void) 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"); } diff --git a/zypp/solver/testsuite/single.out/edition.out b/zypp/solver/testsuite/single.out/edition.out index 40186e0..a6937f3 100644 --- a/zypp/solver/testsuite/single.out/edition.out +++ b/zypp/solver/testsuite/single.out/edition.out @@ -1,4 +1,4 @@ -defaultarch FAIL +defaultarch PASS x86arch PASS emptyEdition PASS epochEdition PASS diff --git a/zypp/solver/testsuite/spec_single.cc b/zypp/solver/testsuite/spec_single.cc index e5dd362..10c54bd 100644 --- a/zypp/solver/testsuite/spec_single.cc +++ b/zypp/solver/testsuite/spec_single.cc @@ -22,6 +22,7 @@ */ #include +#include "zypp/ResObject.h" using namespace std; using namespace zypp::solver::detail; @@ -29,14 +30,14 @@ using namespace zypp::solver::detail; bool emptySpec (void) { - Spec spec(Kind::Package, ""); + Spec spec(zypp::ResTraits::kind, ""); return spec.asString() == ""; } bool epochSpec(void) { - Spec spec(Kind::Package, "foo", 1); + Spec spec(zypp::ResTraits::kind, "foo", 1); return (spec.asString() == "foo-1:"); } @@ -44,14 +45,14 @@ epochSpec(void) bool versionSpec(void) { - Spec spec(Kind::Patch, "bar", 0,"42"); + Spec spec(zypp::ResTraits::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::kind, "foobar", -1,"42","47.11"); return (spec.asString() == "foobar-42-47.11"); } @@ -59,7 +60,8 @@ releaseSpec(void) bool archSpec(void) { - Spec spec(Kind::Package, "arch", 0, "42", "47.11", Arch::create("x86_64")); + Spec spec(zypp::ResTraits::kind, "arch", 0, "42", "47.11", + new zypp::Arch("x86_64")); return (spec.asString() == "arch-0:42-47.11.x86_64"); } @@ -67,7 +69,8 @@ archSpec(void) bool fullSpec(void) { - Spec spec(Kind::Package, "full", 1, "42", "47.11", Arch::create("x86_64")); + Spec spec(zypp::ResTraits::kind, "full", 1, "42", "47.11", + new zypp::Arch("x86_64")); return (spec.asString() == "full-1:42-47.11.x86_64"); } -- 2.7.4