From 17c8390e6fe4a12144872707c3db5b45867cde74 Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Thu, 26 Jan 2006 12:27:13 +0000 Subject: [PATCH] they're all gone now --- zypp/solver/temporary/Channel.cc | 423 -------------- zypp/solver/temporary/Channel.h | 222 ------- zypp/solver/temporary/ChannelPtr.h | 51 -- zypp/solver/temporary/Hash.h | 45 -- zypp/solver/temporary/Makefile.am | 64 --- zypp/solver/temporary/Match.cc | 185 ------ zypp/solver/temporary/Match.h | 130 ----- zypp/solver/temporary/MatchPtr.h | 52 -- zypp/solver/temporary/MultiWorld.cc | 706 ----------------------- zypp/solver/temporary/MultiWorld.h | 143 ----- zypp/solver/temporary/MultiWorldPtr.h | 53 -- zypp/solver/temporary/Package.cc | 575 ------------------- zypp/solver/temporary/Package.h | 160 ------ zypp/solver/temporary/PackagePtr.h | 54 -- zypp/solver/temporary/PackageUpdate.cc | 234 -------- zypp/solver/temporary/PackageUpdate.h | 151 ----- zypp/solver/temporary/PackageUpdatePtr.h | 51 -- zypp/solver/temporary/ResItem.cc | 310 ---------- zypp/solver/temporary/ResItem.h | 173 ------ zypp/solver/temporary/ResItemPtr.h | 52 -- zypp/solver/temporary/ServiceWorld.cc | 93 --- zypp/solver/temporary/ServiceWorld.h | 102 ---- zypp/solver/temporary/ServiceWorldPtr.h | 53 -- zypp/solver/temporary/Spec.cc | 277 --------- zypp/solver/temporary/Spec.h | 144 ----- zypp/solver/temporary/SpecPtr.h | 54 -- zypp/solver/temporary/StoreWorld.cc | 794 ------------------------- zypp/solver/temporary/StoreWorld.h | 142 ----- zypp/solver/temporary/StoreWorldPtr.h | 54 -- zypp/solver/temporary/Subscription.cc | 413 ------------- zypp/solver/temporary/Subscription.h | 103 ---- zypp/solver/temporary/UndumpWorld.cc | 178 ------ zypp/solver/temporary/UndumpWorld.h | 89 --- zypp/solver/temporary/UndumpWorldPtr.h | 53 -- zypp/solver/temporary/World.cc | 578 ------------------- zypp/solver/temporary/World.h | 273 --------- zypp/solver/temporary/WorldPtr.h | 52 -- zypp/solver/temporary/XmlNode.cc | 309 ---------- zypp/solver/temporary/XmlNode.h | 121 ---- zypp/solver/temporary/XmlNodePtr.h | 53 -- zypp/solver/temporary/XmlParser.cc | 944 ------------------------------ zypp/solver/temporary/XmlParser.h | 171 ------ zypp/solver/temporary/extract.cc | 956 ------------------------------- zypp/solver/temporary/extract.h | 79 --- zypp/solver/temporary/utils.cc | 697 ---------------------- zypp/solver/temporary/utils.h | 82 --- 46 files changed, 10698 deletions(-) delete mode 100644 zypp/solver/temporary/Channel.cc delete mode 100644 zypp/solver/temporary/Channel.h delete mode 100644 zypp/solver/temporary/ChannelPtr.h delete mode 100644 zypp/solver/temporary/Hash.h delete mode 100644 zypp/solver/temporary/Makefile.am delete mode 100644 zypp/solver/temporary/Match.cc delete mode 100644 zypp/solver/temporary/Match.h delete mode 100644 zypp/solver/temporary/MatchPtr.h delete mode 100644 zypp/solver/temporary/MultiWorld.cc delete mode 100644 zypp/solver/temporary/MultiWorld.h delete mode 100644 zypp/solver/temporary/MultiWorldPtr.h delete mode 100644 zypp/solver/temporary/Package.cc delete mode 100644 zypp/solver/temporary/Package.h delete mode 100644 zypp/solver/temporary/PackagePtr.h delete mode 100644 zypp/solver/temporary/PackageUpdate.cc delete mode 100644 zypp/solver/temporary/PackageUpdate.h delete mode 100644 zypp/solver/temporary/PackageUpdatePtr.h delete mode 100644 zypp/solver/temporary/ResItem.cc delete mode 100644 zypp/solver/temporary/ResItem.h delete mode 100644 zypp/solver/temporary/ResItemPtr.h delete mode 100644 zypp/solver/temporary/ServiceWorld.cc delete mode 100644 zypp/solver/temporary/ServiceWorld.h delete mode 100644 zypp/solver/temporary/ServiceWorldPtr.h delete mode 100644 zypp/solver/temporary/Spec.cc delete mode 100644 zypp/solver/temporary/Spec.h delete mode 100644 zypp/solver/temporary/SpecPtr.h delete mode 100644 zypp/solver/temporary/StoreWorld.cc delete mode 100644 zypp/solver/temporary/StoreWorld.h delete mode 100644 zypp/solver/temporary/StoreWorldPtr.h delete mode 100644 zypp/solver/temporary/Subscription.cc delete mode 100644 zypp/solver/temporary/Subscription.h delete mode 100644 zypp/solver/temporary/UndumpWorld.cc delete mode 100644 zypp/solver/temporary/UndumpWorld.h delete mode 100644 zypp/solver/temporary/UndumpWorldPtr.h delete mode 100644 zypp/solver/temporary/World.cc delete mode 100644 zypp/solver/temporary/World.h delete mode 100644 zypp/solver/temporary/WorldPtr.h delete mode 100644 zypp/solver/temporary/XmlNode.cc delete mode 100644 zypp/solver/temporary/XmlNode.h delete mode 100644 zypp/solver/temporary/XmlNodePtr.h delete mode 100644 zypp/solver/temporary/XmlParser.cc delete mode 100644 zypp/solver/temporary/XmlParser.h delete mode 100644 zypp/solver/temporary/extract.cc delete mode 100644 zypp/solver/temporary/extract.h delete mode 100644 zypp/solver/temporary/utils.cc delete mode 100644 zypp/solver/temporary/utils.h diff --git a/zypp/solver/temporary/Channel.cc b/zypp/solver/temporary/Channel.cc deleted file mode 100644 index efc2faf..0000000 --- a/zypp/solver/temporary/Channel.cc +++ /dev/null @@ -1,423 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Channel.cc - * - * Copyright (C) 2000-2002 Ximian, Inc. - * Copyright (C) 2005 SUSE Linux Products GmbH - * - * Definition of 'channel' - * - * 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 "zypp/base/Logger.h" -#include "zypp/base/String.h" - -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/World.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(Channel); - -//--------------------------------------------------------------------------- - -int Channel::_fake_id = 1; - -//--------------------------------------------------------------------------- - -string -Channel::asString ( void ) const -{ - if (this == NULL) ERR << "Channel::asString NULL" << endl; - return toString (*this); -} - - -string -Channel::toString ( const Channel & channel ) -{ - string res (" *_distro_targets; /* List of targets (char *) for this channel */ - - res += ", LastUpdate: "; - res += str::numstring(channel.lastUpdate()); - - if (channel.system()) res += ", System! "; - if (channel.hidden()) res += ", Hidden! "; - if (channel.immutable()) res += ", Immutable! "; - - return res + "'>"; -} - - -ostream & -Channel::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const Channel& channel) -{ - return os << channel.asString(); -} - -//--------------------------------------------------------------------------- - -Channel::Channel(const string & id, const string & name, const string & alias, const string & description) - : _world (NULL) - , _last_update (0) - , _system (false) - , _hidden (false) - , _immutable (false) -{ - if (id.empty()) { - _id = str::form( "fake-id-%d", _fake_id++).c_str(); - } - else { - _id = id; - } - - if (name.empty()) { - _name = "Unnamed Channel"; - } - else { - _name = name; - } - - if (alias.empty()) { - _alias = name; - } - else { - _alias = alias; - } - - if (description.empty()) { - _description = "No description available."; - } - else { - _description = description; - } - - _type = CHANNEL_TYPE_UNKNOWN; - - _priority = -1; - _priority_unsubscribed = -1; - - _DBG("RC_SPEW") << "Channel() [" << this << "] (" << asString() << ")" << endl ; -} - - -Channel::Channel (const XmlNode_Ptr node, int *subscribed, World_Ptr world) - : _world (world) - , _last_update (0) - , _system (false) - , _hidden (false) - , _immutable (false) -{ - static unsigned int dummy_id = 0xdeadbeef; - - _name = node->getProp ("name"); - _alias = node->getProp ("alias"); - - _id = node->getProp ("id"); - if (_id.empty()) { - char *temp; - asprintf (&temp, "dummy:%d", dummy_id); - _id = temp; - ++dummy_id; - } - - *subscribed = node->getIntValueDefault ("subscribed", 0); - - _priority = node->getIntValueDefault ("priority_base", 0); - _priority_unsubscribed = node->getIntValueDefault ("priority_unsubd", 0); - - _DBG("RC_SPEW") << "Channel(xml) [" << this << "] (" << asString() << ")" << endl; -} - - -Channel::~Channel() -{ -} - - -#if 0 -xmlNode * -rc_channel_to_xml_node (RCChannel *channel) -{ - xmlNode *node; - char tmp[128]; - - g_return_val_if_fail (channel != NULL, NULL); - - node = xmlNewNode (NULL, "channel"); - - xmlNewProp (node, "id", rc_channel_get_id (channel)); - - xmlNewProp (node, "name", rc_channel_get_name (channel)); - - if (rc_channel_get_alias (channel)) - xmlNewProp (node, "alias", rc_channel_get_alias (channel)); - - sprintf (tmp, "%d", rc_channel_is_subscribed (channel) ? 1 : 0); - xmlNewProp (node, "subscribed", tmp); - - sprintf (tmp, "%d", rc_channel_get_priority (channel, true)); - xmlNewProp (node, "priority_base", tmp); - - sprintf (tmp, "%d", rc_channel_get_priority (channel, false)); - xmlNewProp (node, "priority_unsubd", tmp); - - return node; -} -#endif - - -bool -Channel::isSubscribed (void) const -{ - if (_world == NULL) - ERR << "Channel::isSubscribed() without world" << endl; - return _world->isSubscribed (this); -} - - -void -Channel::setSubscription (bool subscribed) -{ - if (_world == NULL) - ERR << "Channel::setSubscription() without world" << endl; - _world->setSubscription (this, subscribed); -} - - -int -Channel::priorityParse (const string & priority_str) const -{ -#define DEFAULT_CHANNEL_PRIORITY 1600 - - typedef struct { - const char *str; - int priority; - } ChannelPriorityPair; - - ChannelPriorityPair channel_priority_table[] = { - { "private", 6400 }, - { "ximian", 3200 }, - { "distro", 1600 }, - { "third_party", 800 }, - { "preview", 400 }, - { "untested", 200 }, - { "snapshot", 100 }, - { NULL, 0 } - }; - - const char *c; - int i; - bool is_numeric = true; - - if (!priority_str.empty()) { - c = priority_str.c_str(); - while (*c && is_numeric) { - if (! isdigit (*c)) - is_numeric = false; - c++; - } - if (is_numeric) { - return atoi (priority_str.c_str()); - } - - for (i=0; channel_priority_table[i].str != NULL; ++i) { - if (! strcasecmp (channel_priority_table[i].str, priority_str.c_str())) - return channel_priority_table[i].priority; - } - - } - - return DEFAULT_CHANNEL_PRIORITY; -} - - -bool -Channel::isWildcard (void) const -{ - return _type == CHANNEL_TYPE_SYSTEM - || _type == CHANNEL_TYPE_NONSYSTEM - || _type == CHANNEL_TYPE_ANY; -} - - -bool -Channel::equals (const Channel & channel) const -{ - return equals (&channel); -} - -bool -Channel::equals (Channel_constPtr channel) const -{ - if (_type == CHANNEL_TYPE_ANY - || channel->_type == CHANNEL_TYPE_ANY) { - return true; - } - - if (isWildcard () && channel->isWildcard ()) { - return this == channel; - } - - /* So at this point we know that between a and b there is - at most one wildcard. */ - - if (_type == CHANNEL_TYPE_SYSTEM) { - return channel->system(); - } - else if (_type == CHANNEL_TYPE_NONSYSTEM) { - return !channel->system(); - } - - if (channel->_type == CHANNEL_TYPE_SYSTEM) { - return system(); - } - else if (channel->_type == CHANNEL_TYPE_NONSYSTEM) { - return !system(); - } - - return hasEqualId (channel); -} - - -bool -Channel::hasEqualId (const Channel & channel) const -{ - return hasEqualId (&channel); -} - - -bool -Channel::hasEqualId (Channel_constPtr channel) const -{ - return (channel->id () == _id); -} - - -void -Channel::setPriorities (int subscribed_priority, int unsubscribed_priority) -{ - if (immutable()) return; - - _priority = subscribed_priority; - _priority_unsubscribed = unsubscribed_priority; -} - - -int -Channel::getPriority(bool is_subscribed) const -{ -#define UNSUBSCRIBED_CHANNEL_ADJUSTMENT(x) ((x)/2) - - int priority; - - priority = _priority; - if (priority <= 0) - priority = DEFAULT_CHANNEL_PRIORITY; - - if (!is_subscribed) { - if (_priority_unsubscribed > 0) { - priority = _priority_unsubscribed; - } else { - priority = UNSUBSCRIBED_CHANNEL_ADJUSTMENT (priority); - } - } - - return priority; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/Channel.h b/zypp/solver/temporary/Channel.h deleted file mode 100644 index 99b7c5c..0000000 --- a/zypp/solver/temporary/Channel.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Channel.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 ZYPP_SOLVER_TEMPORARY_CHANNEL_H -#define ZYPP_SOLVER_TEMPORARY_CHANNEL_H - -#include -#include -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/temporary/ChannelPtr.h" -#include "zypp/solver/temporary/WorldPtr.h" -#include "zypp/solver/temporary/XmlNode.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef std::list ChannelList; - -typedef bool (*ChannelFn) (Channel_constPtr channel, void *data); -typedef bool (*ChannelAndSubscribedFn) (Channel_Ptr channel, bool flag, void *data); - -typedef enum { - - CHANNEL_TYPE_ANY = 0, - CHANNEL_TYPE_SYSTEM, - CHANNEL_TYPE_NONSYSTEM, - - CHANNEL_TYPE_UNKNOWN, - CHANNEL_TYPE_HELIX, - CHANNEL_TYPE_DEBIAN, - CHANNEL_TYPE_APTRPM, - CHANNEL_TYPE_YAST, - CHANNEL_TYPE_YUM - -} ChannelType; - -/////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Channel -/** - * - **/ - -class Channel : public base::ReferenceCounted, private base::NonCopyable { - - - private: - ChannelType _type; - - static int _fake_id; - - World_Ptr _world; - - std::string _id; - std::string _legacy_id; // Old ID for RCE servers - - std::string _name; - std::string _alias; - std::string _description; - // priority if channel is... - int _priority; // subscribed - int _priority_unsubscribed; // unsubscribed - - std::string _path; - std::string _file_path; - std::string _icon_file; - std::string _pkginfo_file; - -// std::list *_distro_targets; /* List of targets (std::string ) for this channel */ - - time_t _last_update; - - bool _system; - bool _hidden; - bool _immutable; - - public: - - Channel (ChannelType type) : _type (type), _world(NULL) {} - - Channel(const std::string & id = "", const std::string & name = "", const std::string & alias = "", const std::string & description = ""); - Channel(const XmlNode_Ptr node, int *subscribed, World_Ptr world); //RCChannel *rc_channel_from_xml_node (xmlNode *channel_node); - - virtual ~Channel(); - - // ---------------------------------- I/O - - const XmlNode_Ptr asXmlNode (void) const; // rc_channel_to_xml_node - - static std::string toString ( const Channel & edition ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const Channel& ); - - std::string asString ( void ) const; - - // ---------------------------------- accessors - - ChannelType type(void) const { return _type; } - void setType (ChannelType type) { _type = type; } - - std::string id (void) const { return _id; } - void setId (const std::string & id) { _id = id; } - - World_Ptr world (void) const { return _world; } - void setWorld (World_Ptr world) { _world = world; } - - std::string legacyId (void) const { return _legacy_id; } // Old ID for RCE servers - void setLegacyId (const std::string & legacy_id) { _legacy_id = legacy_id; } - - std::string name (void) const { return _name; } - void setName (const std::string & name) { _name = name; } - - std::string alias (void) const { return _alias; } - void setAlias (const std::string & alias) { _alias = alias; } - - std::string description (void) const { return _description; } - void setDescription (const std::string & description) { _description = description; } - - int priority (void) const { return _priority; } - void setPriority (int priority) { _priority = priority; } - - int priorityUnsubscribed (void) const { return _priority_unsubscribed; } - void setPriorityUnsubscribed (int priority_unsubscribed) { _priority_unsubscribed = priority_unsubscribed; } - - std::string path (void) const { return _path; } - void setPath (const std::string & path) { _path = path; } - - std::string filePath (void) const { return _file_path; } - void setFilePath (const std::string file_path) { _file_path = file_path; } - - std::string iconFile (void) const { return _icon_file; } - void setIconFile (const std::string icon_file) { _icon_file = icon_file; } - - std::string pkginfoFile (void) const { return _pkginfo_file; } - void setPkginfoFile (const std::string & pkginfo_file) { _pkginfo_file = pkginfo_file; } - -// const std::list *distroTargets (void) const { return _distro_targets; } -// void setDistroTargets (const std::list *distro_targets) { _distro_targets = distro_targets; } - - time_t lastUpdate (void) const { return _last_update; } - void setLastUpdate (time_t last_update) { _last_update = last_update; } - - bool system (void) const { return _system; } - void setSystem (bool system) { _system = system; } - bool hidden (void) const { return _hidden; } - void setHidden (bool hidden) { _hidden = hidden; } - bool immutable (void) const { return _immutable; } - void setImmutable (bool immutable) { _immutable = immutable; } - - //----------------------------------------------------------------------- - - bool isWildcard (void) const; - - virtual bool equals (const Channel & channel) const; - virtual bool equals (Channel_constPtr channel) const; - bool hasEqualId (const Channel & channel) const; - bool hasEqualId (Channel_constPtr channel) const; - - //RCResItemSList *rc_channel_get_resItems (RCChannel *channel); - - // Distro target functions - - void addDistroTarget (const std::string & target); - bool hasDistroTarget (const std::string & target) const; - - // Subscription management - - bool isSubscribed (void) const; - void setSubscription (bool subscribed); - - int priorityParse (const std::string & priority_cptr) const; - void setPriorities (int subd_priority, int unsubd_priority); - int getPriority (bool is_subscribed) const; -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_CHANNEL_H diff --git a/zypp/solver/temporary/ChannelPtr.h b/zypp/solver/temporary/ChannelPtr.h deleted file mode 100644 index 0aeaf7e..0000000 --- a/zypp/solver/temporary/ChannelPtr.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Channel_Ptr.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 ZYPP_SOLVER_TEMPORARY_CHANNEL_PTR_H -#define ZYPP_SOLVER_TEMPORARY_CHANNEL_PTR_H - -#include "zypp/base/PtrTypes.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : Channel_Ptr - // CLASS NAME : Channel_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Channel); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -//////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_CHANNEL_PTR_H diff --git a/zypp/solver/temporary/Hash.h b/zypp/solver/temporary/Hash.h deleted file mode 100644 index 301574a..0000000 --- a/zypp/solver/temporary/Hash.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Hash.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 ZYPP_SOLVER_TEMPORARY_HASH_H -#define ZYPP_SOLVER_TEMPORARY_HASH_H - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - typedef unsigned int HashValue; - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_HASH_H diff --git a/zypp/solver/temporary/Makefile.am b/zypp/solver/temporary/Makefile.am deleted file mode 100644 index fd7b168..0000000 --- a/zypp/solver/temporary/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -# -# Makefile.am for solver/temporary -# - -SUBDIRS = - -INCLUDES = \ - -I$(top_srcdir) -Wall -fno-strict-aliasing \ - -I/usr/include/libxml2 -I/usr/include/rpm \ - -DG_LOG_DOMAIN=\"solver_temporary\" - -solvertemporaryincludedir = $(pkgincludedir)/solver/temporary - -solvertemporaryinclude_HEADERS = \ - utils.h \ - extract.h \ - Hash.h \ - Spec.h \ - SpecPtr.h \ - Channel.h \ - ChannelPtr.h \ - Subscription.h \ - ResItem.h \ - ResItemPtr.h \ - Package.h \ - PackagePtr.h \ - PackageUpdate.h \ - PackageUpdatePtr.h \ - XmlNode.h \ - XmlNodePtr.h \ - XmlParser.h \ - Match.h \ - MatchPtr.h \ - World.h \ - WorldPtr.h \ - UndumpWorld.h \ - UndumpWorldPtr.h \ - StoreWorld.h \ - StoreWorldPtr.h \ - MultiWorld.h \ - MultiWorldPtr.h \ - ServiceWorld.h \ - ServiceWorldPtr.h - -noinst_LTLIBRARIES = lib@PACKAGE@_solver_temporary.la - -lib@PACKAGE@_solver_temporary_la_SOURCES = \ - utils.cc \ - Spec.cc \ - Channel.cc \ - Subscription.cc \ - ResItem.cc \ - XmlNode.cc \ - Package.cc \ - PackageUpdate.cc \ - XmlParser.cc \ - Match.cc \ - World.cc \ - UndumpWorld.cc \ - StoreWorld.cc \ - MultiWorld.cc \ - ServiceWorld.cc \ - extract.cc - diff --git a/zypp/solver/temporary/Match.cc b/zypp/solver/temporary/Match.cc deleted file mode 100644 index f677eda..0000000 --- a/zypp/solver/temporary/Match.cc +++ /dev/null @@ -1,185 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Match.cc - * - * 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 "zypp/solver/temporary/Match.h" -#include "zypp/solver/temporary/World.h" -#include "zypp/Rel.h" - -#include "zypp/CapFactory.h" -#include "zypp/CapSet.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(Match); - -//--------------------------------------------------------------------------- - -string -Match::asString ( void ) const -{ - return toString (*this); -} - - -string -Match::toString ( const Match & lock ) -{ - return ""; -} - - -ostream & -Match::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const Match& edition) -{ - return os << edition.asString(); -} - -//--------------------------------------------------------------------------- - -Match::Match() - : _importance (Importance::Undefined) -{ -} - -Match::Match (XmlNode_Ptr node) - : _importance (Importance::Undefined) -{ -} - -Match::~Match() -{ -} - -//--------------------------------------------------------------------------- - -XmlNode_Ptr -Match::asXmlNode (void) const -{ - return new XmlNode("match"); -} - - -// equality -bool -Match::equals ( const Match & lock ) const { - - // Check the name glob - - if ((_name_glob.empty()) ^ (lock._name_glob.empty())) - return false; - if (_name_glob != lock._name_glob) - return false; - - // Check the channel - - if ((_channel_id.empty()) ^ (lock._channel_id.empty())) - return false; - if (_channel_id != lock._channel_id) - return false; - - // Check the importance - - if (_importance != lock._importance - || _importance_gteq != lock._importance_gteq) - { - return false; - } - - // Check the dep - if ( _dependency != lock._dependency) - return false; - - return true; -} - - -CapMatch -Match::test (ResItem_constPtr resItem, World_Ptr world) const -{ - string name; - Channel_constPtr channel = resItem->channel (); - - if (channel != NULL && !_channel_id.empty()) { - if (! channel->hasEqualId (_channel_id)) { - return false; - } - } - - name = resItem->name (); - - // FIXME, implement regexp -#if 0 - if (match->_pattern_spec - && ! 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; */ - /* } */ - /* } */ - CapFactory factory; - Capability dependency; - - dependency = factory.parse ( resItem->kind(), - resItem->name(), - Rel::EQ, - resItem->edition()); - CapMatch check = _dependency.matches (dependency); - return check; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/Match.h b/zypp/solver/temporary/Match.h deleted file mode 100644 index d286428..0000000 --- a/zypp/solver/temporary/Match.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Match.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 ZYPP_SOLVER_TEMPORARY_MATCH_H -#define ZYPP_SOLVER_TEMPORARY_MATCH_H - -#include -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/detail/Importance.h" - -#include "zypp/solver/temporary/MatchPtr.h" -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/ResItem.h" -#include "zypp/solver/temporary/WorldPtr.h" -#include "zypp/solver/temporary/XmlNode.h" -#include "zypp/CapMatch.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - class Match; - typedef std::list MatchList; - - class World; - typedef bool (*MatchFn) (Match_constPtr match, void *data); - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : Match - /** - * - **/ - class Match : public base::ReferenceCounted, private base::NonCopyable { - - - private: - std::string _channel_id; - - Capability _dependency; - - std::string _name_glob; - // GPatternSpec *_pattern_spec; - - Importance _importance; - bool _importance_gteq; - - public: - - Match(); - Match(XmlNode_Ptr node); - virtual ~Match(); - - // ---------------------------------- I/O - - static std::string toString ( const Match & lock ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const Match & lock ); - - std::string asString ( void ) const; - - XmlNode_Ptr asXmlNode (void) const; - - // ---------------------------------- accessors - - const std::string & channelId () const { return _channel_id; } - void setChannel (Channel_constPtr channel) { _channel_id = channel->id(); } - void setChannelId (const std::string & channel_id) { _channel_id = channel_id; } - - 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; } - - const Importance & importance (bool *match_gteq) const { *match_gteq = _importance_gteq; return _importance; } - void setImportance (const Importance & importance, bool match_gteq) { _importance = importance; _importance_gteq = match_gteq; } - - // ---------------------------------- methods - - typedef bool (*MatchFn) (Match_constPtr, void *data); - - // equality - bool equals (const Match & match) const; - - CapMatch test (ResItem_constPtr resItem, World_Ptr world) const; - }; - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_MATCH_H diff --git a/zypp/solver/temporary/MatchPtr.h b/zypp/solver/temporary/MatchPtr.h deleted file mode 100644 index 0742ba8..0000000 --- a/zypp/solver/temporary/MatchPtr.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Match_Ptr.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 ZYPP_SOLVER_TEMPORARY_MATCH_PTR_H -#define ZYPP_SOLVER_TEMPORARY_MATCH_PTR_H - -#include "zypp/base/PtrTypes.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : Match_Ptr - // CLASS NAME : Match_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Match); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_MATCH_PTR_H diff --git a/zypp/solver/temporary/MultiWorld.cc b/zypp/solver/temporary/MultiWorld.cc deleted file mode 100644 index 42d9725..0000000 --- a/zypp/solver/temporary/MultiWorld.cc +++ /dev/null @@ -1,706 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* MultiWorld.cc - * - * 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 "zypp/base/String.h" -#include "zypp/solver/temporary/MultiWorld.h" -#include "zypp/solver/temporary/ServiceWorld.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -//=========================================================================== - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : SubWorldInfo - -class SubWorldInfo { - - private: - World_Ptr _subworld; - World_Ptr _refreshed_subworld; - - bool _refreshed_ready; - - unsigned int _changed_resItems_id; - unsigned int _changed_channels_id; - unsigned int _changed_subscriptions_id; - unsigned int _changed_locks_id; - - public: - - SubWorldInfo (World_Ptr subworld, MultiWorld_Ptr multiworld); - virtual ~SubWorldInfo(); - - // ---------------------------------- I/O - - static std::string toString (const SubWorldInfo & subworldinfo); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const SubWorldInfo & subworldinfo); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - World_Ptr subworld () const { return _subworld; } - - // ---------------------------------- methods - -}; - -//--------------------------------------------------------------------------- - -string -SubWorldInfo::asString ( void ) const -{ - return toString (*this); -} - - -string -SubWorldInfo::toString ( const SubWorldInfo & subworldinfo ) -{ - return ""; -} - - -ostream & -SubWorldInfo::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const SubWorldInfo & subworldinfo) -{ - return os << subworldinfo.asString(); -} - -//--------------------------------------------------------------------------- - -SubWorldInfo::SubWorldInfo (World_Ptr subworld, MultiWorld_Ptr multiworld) - : _subworld (subworld) - , _changed_resItems_id (0) - , _changed_channels_id (0) - , _changed_subscriptions_id (0) - , _changed_locks_id (0) - -{ -#if 0 - _changed_resItems_id = - g_signal_connect (G_OBJECT (subworld), - "changed_resItems", - (GCallback) changed_resItems_cb, - world); - - _changed_channels_id = - g_signal_connect (G_OBJECT (subworld), - "changed_channels", - (GCallback) changed_channels_cb, - world); - - _changed_subscriptions_id = - g_signal_connect (G_OBJECT (subworld), - "changed_subscriptions", - (GCallback) changed_subscriptions_cb, - world); - - _changed_locks_id = - g_signal_connect (G_OBJECT (subworld), - "changed_locks", - (GCallback) changed_locks_cb, - world); -#endif -} - - -SubWorldInfo::~SubWorldInfo() -{ -} - - -//=========================================================================== - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : NameConflictInfo - -class NameConflictInfo { - - private: - int _depth; - MultiWorld_Ptr _multiworld; - World_Ptr _subworld; - string _name; - - public: - NameConflictInfo(int depth, MultiWorld_Ptr multiworld, World_Ptr subworld, const string & name); - virtual ~NameConflictInfo(); - - // ---------------------------------- I/O - - static std::string toString (const NameConflictInfo & nameconflictinfo); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const NameConflictInfo & nameconflictinfo); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - int depth () const { return _depth; } - MultiWorld_Ptr multiworld () const { return _multiworld; } - World_Ptr subworld () const { return _subworld; } - string name () const { return _name; } - void setName (const string & name) { _name = name; } - - // ---------------------------------- methods - - void incDepth (void) { _depth++; } -}; - - -//--------------------------------------------------------------------------- - -string -NameConflictInfo::asString ( void ) const -{ - return toString (*this); -} - - -string -NameConflictInfo::toString ( const NameConflictInfo & subworldinfo ) -{ - return ""; -} - - -ostream & -NameConflictInfo::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const NameConflictInfo & subworldinfo) -{ - return os << subworldinfo.asString(); -} - -//--------------------------------------------------------------------------- - -NameConflictInfo::NameConflictInfo (int depth, MultiWorld_Ptr multiworld, World_Ptr subworld, const string & name) - : _depth (depth) - , _multiworld (multiworld) - , _subworld (subworld) - , _name (name) -{ -} - - -NameConflictInfo::~NameConflictInfo() -{ -} - - -//=========================================================================== - -IMPL_PTR_TYPE(MultiWorld); - -string -MultiWorld::asString ( void ) const -{ - return toString (*this); -} - - -string -MultiWorld::toString ( const MultiWorld & world ) -{ - return ""; -} - - -ostream & -MultiWorld::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const MultiWorld & world) -{ - return os << world.asString(); -} - -//--------------------------------------------------------------------------- - -MultiWorld::MultiWorld () - : World (MULTI_WORLD) -{ -} - - -MultiWorld::~MultiWorld() -{ -} - -//--------------------------------------------------------------------------- - -class ForeachByTypeInfo { - public: - WorldType type; - WorldFn callback; - NameConflictInfo *name_conflict_info; - - int count; -}; - - -int -MultiWorld::foreachSubworld (WorldFn callback, void *user_data) -{ - if (callback == NULL) return -1; - - /* Make a copy of subworlds for case where user callback is - running main loop and a refresh starts at that time. */ - - WorldList copied_subworlds; - - for (SubWorldInfoList::iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - copied_subworlds.push_front ((*iter)->subworld()); - } - - int count = 0; - - for (WorldList::iterator iter = copied_subworlds.begin(); iter != copied_subworlds.end(); iter++) { - if (! callback (*iter, user_data)) { - count = -1; - break; - } else - ++count; - } - - return count; -} - - -static bool -foreach_by_type_cb (World_Ptr subworld, void *user_data) -{ - ForeachByTypeInfo *info = (ForeachByTypeInfo *)user_data; - - if ((subworld->type() != info->type) - || info->callback == NULL) - { - return true; - } - - if (! info->callback (subworld, info->name_conflict_info)) { - info->count = -1; - return false; - } else { - ++info->count; - return true; - } -} - - -int -MultiWorld::foreachSubworldByType (WorldType type, WorldFn fn, void *data) -{ - ForeachByTypeInfo info; - - NameConflictInfo *name_conflict_info = (NameConflictInfo *)data; - info.type = type; - info.callback = fn; - info.name_conflict_info = name_conflict_info; - info.count = 0; - - foreachSubworld (foreach_by_type_cb, (void *)(&info)); - - return info.count; -} - -//--------------------------------------------------------------------------- -// subworld - -static bool -service_name_conflict_cb (World_Ptr world, void *user_data) -{ - ServiceWorld_constPtr service = dynamic_pointer_cast(world); - if (service == NULL) { - ERR << "OOPS: service_name_conflict_cb: world is no service" << endl; - abort(); - } - - NameConflictInfo *info = (NameConflictInfo *)user_data; - if (service->name() == info->name()) { - info->incDepth(); - ServiceWorld_Ptr infoservice = dynamic_pointer_cast(info->subworld()); - if (infoservice == NULL) { - ERR << "OOPS: service_name_conflict_cb: info->subworld is no service" << endl; - abort(); - } - info->setName (str::form ("%s (%d)", infoservice->name().c_str(), info->depth()).c_str()); - info->multiworld()->foreachSubworldByType (SERVICE_WORLD, service_name_conflict_cb, info); - return false; - } - - return true; -} - - -void -MultiWorld::addSubworld (World_Ptr subworld) -{ - if (subworld == NULL) return; - - /* - * If we're adding a service, make sure that the name of the service - * doesn't conflict with any other. - */ - ServiceWorld_Ptr service = dynamic_pointer_cast(subworld); // service will be NULL if subworld is not a ServiceWorld - - if (service != NULL) { - NameConflictInfo conflict_info (0, this, subworld, service->name()); - - foreachSubworldByType (SERVICE_WORLD, service_name_conflict_cb, &conflict_info); - - service->setName (conflict_info.name()); - } - - SubWorldInfo *subworld_info = new SubWorldInfo (subworld, this); - - _subworlds.push_back (subworld_info); - -// g_signal_emit (multi, signals[SUBWORLD_ADDED], 0, subworld); - - return; -} - - -void -MultiWorld::removeSubworld (World_Ptr subworld) -{ - if (subworld == NULL) return; - - for (SubWorldInfoList::iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - if ((*iter)->subworld() == subworld) { - _subworlds.erase (iter); -// g_signal_emit (multi, signals[SUBWORLD_REMOVED], 0, subworld); - return; - } - } - return; -} - - -//--------------------------------------------------------------------------- -// channels - -ChannelList -MultiWorld::channels () const -{ - ChannelList cl; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - cl = (*iter)->subworld()->channels(); -//FIXME cl.merge ((*iter)->subworld()->channels()); - } - return cl; -} - - -bool -MultiWorld::containsChannel (Channel_constPtr channel) const -{ - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - if ((*iter)->subworld()->containsChannel(channel)) - return true; - } - return false; -} - - -Channel_Ptr -MultiWorld::getChannelByName (const string & channel_name) const -{ - Channel_Ptr channel; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - channel = (*iter)->subworld()->getChannelByName(channel_name); - if (channel != NULL) - return channel; - } - return NULL; -} - - -Channel_Ptr -MultiWorld::getChannelByAlias (const string & alias) const -{ - Channel_Ptr channel; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - channel = (*iter)->subworld()->getChannelByAlias(alias); - if (channel != NULL) - return channel; - } - return NULL; -} - - -Channel_Ptr -MultiWorld::getChannelById (const string & channel_id) const -{ - Channel_Ptr channel; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - channel = (*iter)->subworld()->getChannelById(channel_id); - if (channel != NULL) - return channel; - } - return NULL; -} - - -int -MultiWorld::foreachChannel (ChannelFn fn, void *data) const -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachChannel(fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - - -//--------------------------------------------------------------------------- -// Single resItem queries - -ResItem_constPtr -MultiWorld::findInstalledResItem (ResItem_constPtr resItem) -{ - ResItem_constPtr installed; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - installed = (*iter)->subworld()->findInstalledResItem(resItem); - if (installed != NULL) - return installed; - } - return NULL; -} - - -ResItem_constPtr -MultiWorld::findResItem (Channel_constPtr channel, const string & name, const Resolvable::Kind & kind) const -{ - ResItem_constPtr resItem; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - resItem = (*iter)->subworld()->findResItem(channel, name, kind); - if (resItem != NULL) - return resItem; - } - return NULL; -} - - -ResItem_constPtr -MultiWorld::findResItemWithConstraint (Channel_constPtr channel, const string & name, const Capability & constraint, bool is_and) const -{ - ResItem_constPtr resItem; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - resItem = (*iter)->subworld()->findResItemWithConstraint(channel, name, constraint, is_and); - if (resItem != NULL) - return resItem; - } - return NULL; -} - - -Channel_Ptr -MultiWorld::guessResItemChannel (ResItem_constPtr resItem) const -{ - Channel_Ptr channel; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - channel = (*iter)->subworld()->guessResItemChannel(resItem); - if (channel != NULL) - return channel; - } - return NULL; -} - -//--------------------------------------------------------------------------- -// iterate over resItems - -int -MultiWorld::foreachResItem (Channel_Ptr channel, CResItemFn fn, void *data) -{ - return foreachResItemByName ("", channel, fn, data); -} - - -int -MultiWorld::foreachResItemByName (const std::string & name, Channel_Ptr channel, CResItemFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachResItemByName(name, channel, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - - -int -MultiWorld::foreachResItemByKind (const Resolvable::Kind & kind, CResItemFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachResItemByKind(kind, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - - -int -MultiWorld::foreachResItemByMatch (Match_constPtr match, CResItemFn fn, void *data) -{ - ERR << "MultiWorld::foreachResItemByMatch not implemented" << endl; - return 0; -} - - -//----------------------------------------------------------------------------- -// iterater over resItems with dependency - -int -MultiWorld::foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachProvidingResItem (dep, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - -int -MultiWorld::foreachRequiringResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachRequiringResItem (dep, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - -int -MultiWorld::foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachConflictingResItem (dep, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - - -int -MultiWorld::foreachFresheningResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachFresheningResItem (dep, fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - - -//----------------------------------------------------------------------------- -// iterater over resItems with locks - -int -MultiWorld::foreachLock (MatchFn fn, void *data) const -{ - int count = 0; - for (SubWorldInfoList::const_iterator iter = _subworlds.begin(); iter != _subworlds.end(); iter++) { - int this_count; - this_count = (*iter)->subworld()->foreachLock(fn, data); - if (this_count < 0) - return -1; - count += this_count; - } - return count; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/MultiWorld.h b/zypp/solver/temporary/MultiWorld.h deleted file mode 100644 index 0b000a6..0000000 --- a/zypp/solver/temporary/MultiWorld.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* MultiWorld.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 ZYPP_SOLVER_TEMPORARY_MULTIWORLD_H -#define ZYPP_SOLVER_TEMPORARY_MULTIWORLD_H - -#include -#include - -#include "zypp/solver/temporary/MultiWorldPtr.h" -#include "zypp/solver/temporary/ServiceWorldPtr.h" -#include "zypp/solver/temporary/World.h" - -#include "zypp/solver/detail/Pending.h" -#include "zypp/Capability.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -class SubWorldInfo; -class NameConflictInfo; -class ForeachByTypeInfo; - -typedef std::list SubWorldInfoList; - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : MultiWorld - -class MultiWorld : public World { - - - private: - - SubWorldInfoList _subworlds; - - Pending_Ptr _multi_pending; - PendingList _subworld_pendings; - - void (*_subworld_added) (World_Ptr subworld); - void (*_subworld_removed) (World_Ptr subworld); - - public: - - MultiWorld (); - MultiWorld (XmlNode_Ptr node); - MultiWorld (const std::string & filename); - virtual ~MultiWorld(); - - // ---------------------------------- I/O - - static std::string toString (const MultiWorld & section); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const MultiWorld & section); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - void addSubworld (World_Ptr subworld); - void removeSubworld (World_Ptr subworld); - - // ---------------------------------- methods - - virtual ChannelList channels () const; - virtual bool containsChannel (Channel_constPtr channel) const; - virtual Channel_Ptr getChannelByName (const std::string & channel_name) const; - virtual Channel_Ptr getChannelByAlias (const std::string & alias) const; - virtual Channel_Ptr getChannelById (const std::string & channel_id) const; - virtual Channel_Ptr guessResItemChannel (ResItem_constPtr resItem) const; - virtual int foreachChannel (ChannelFn fn, void *data) const; - - int foreachSubworld (WorldFn callback, void *user_data); - int foreachSubworldByType (WorldType type, WorldFn fn, void *data); - WorldList getSubworlds (); - ServiceWorld_Ptr lookupService (const std::string & url); - ServiceWorld_Ptr lookupServiceById (const std::string & id); - bool mountService (const std::string & url, void *error); // GError **error); - - // Single resItem queries - - virtual ResItem_constPtr findInstalledResItem (ResItem_constPtr resItem); - virtual ResItem_constPtr findResItem (Channel_constPtr channel, const std::string & name, const Resolvable::Kind & kind = ResTraits::kind) const; - virtual ResItem_constPtr findResItemWithConstraint (Channel_constPtr channel, const std::string & name, const Capability & constraint, bool is_and) const; - - // Iterate over resItems - - virtual int foreachResItem (Channel_Ptr channel, CResItemFn fn, void *data); - virtual int foreachResItemByName (const std::string & name, Channel_Ptr channel, CResItemFn fn, void *data); - virtual int foreachResItemByKind (const Resolvable::Kind & kind, CResItemFn fn, void *user_data); - virtual int foreachResItemByMatch (Match_constPtr match, CResItemFn fn, void *data); - - // Iterate across provides or requirement - - virtual int foreachProvidingResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachRequiringResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachConflictingResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachFresheningResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data); - - // locks - - virtual int foreachLock (MatchFn fn, void *data) const; - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_MULTIWORLD_H diff --git a/zypp/solver/temporary/MultiWorldPtr.h b/zypp/solver/temporary/MultiWorldPtr.h deleted file mode 100644 index ca22b21..0000000 --- a/zypp/solver/temporary/MultiWorldPtr.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* MultiWorld_Ptr.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 ZYPP_SOLVER_TEMPORARY_MULTIWORLD_PTR_H -#define ZYPP_SOLVER_TEMPORARY_MULTIWORLD_PTR_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/solver/temporary/WorldPtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : MultiWorld_Ptr - // CLASS NAME : MultiWorld_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(MultiWorld); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_MULTIWORLD_PTR_H diff --git a/zypp/solver/temporary/Package.cc b/zypp/solver/temporary/Package.cc deleted file mode 100644 index 31af4a7..0000000 --- a/zypp/solver/temporary/Package.cc +++ /dev/null @@ -1,575 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Package.cc - * - * 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 "zypp/Package.h" -#include "zypp/detail/PackageImpl.h" -#include "zypp/base/Logger.h" -#include "zypp/base/String.h" -#include "zypp/CapFactory.h" -#include "zypp/CapSet.h" - -#include "zypp/solver/temporary/utils.h" -#include "zypp/solver/temporary/Package.h" -#include "zypp/solver/temporary/PackageUpdate.h" -#include "zypp/solver/temporary/MultiWorld.h" -#include "zypp/solver/temporary/XmlNode.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(Package); - -struct DepTable { - CapSet requires; - CapSet provides; - CapSet conflicts; - CapSet obsoletes; - CapSet children; - CapSet suggests; - CapSet recommends; -}; - -//--------------------------------------------------------------------------- - -static Capability -parseXmlDep (XmlNode_constPtr node) { - string tmp; - string epoch,version,release,name = ""; - Arch arch = Arch_noarch; - Rel relation; - CapFactory factory; - - if (!node->equals("dep")) { - ERR << "parseXmlDep bad node" << endl; - abort(); - } - - name = node->getProp ("name"); - tmp = node->getProp ("op"); - if (!tmp.empty()) { - relation = Rel(tmp); - epoch = str::numstring(node->getIntValueDefault ("epoch", Edition::noepoch)); - version = node->getProp ("version"); - release = node->getProp ("release"); - } - - tmp = node->getProp ("arch"); - if (!tmp.empty()) { - arch = Arch(node->getProp ("arch")); - } else { - arch = Arch(); - } - - return factory.parse ( ResTraits::kind, - name, - relation, - Edition (version, release, epoch)); -} - -static void -extract_dep_info (XmlNode_constPtr iter, struct DepTable & dep_table) -{ - if (iter->equals("requires")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.requires.insert(parseXmlDep (iter2)); - iter2 = iter2->next(); - } - - } else if (iter->equals("recommends")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.recommends.insert (parseXmlDep (iter2)); - iter2 = iter2->next(); - } - - } else if (iter->equals("suggests")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.suggests.insert (parseXmlDep (iter2)); - iter2 = iter2->next(); - } - - } else if (iter->equals("conflicts")) { - XmlNode_Ptr iter2; - bool all_are_obs = false, this_is_obs = false; - string obs; - - iter2 = iter->children(); - - obs = iter->getProp ("obsoletes"); - if (!obs.empty()) { - all_are_obs = true; - } - - while (iter2) { - - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - Capability dep = parseXmlDep(iter2); - - if (! all_are_obs) { - this_is_obs = false; - obs = iter2->getProp ("obsoletes"); - if (!obs.empty()) { - this_is_obs = true; - } - } - - if (all_are_obs || this_is_obs) { - dep_table.obsoletes.insert (dep); - } else { - dep_table.conflicts.insert (dep); - } - - iter2 = iter2->next(); - } - - } else if (iter->equals("obsoletes")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.obsoletes.insert (parseXmlDep (iter2)); - iter2 = iter2->next(); - } - - } else if (iter->equals("provides")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.provides.insert (parseXmlDep (iter2)); - iter2 = iter2->next(); - } - - } else if (iter->equals("children")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - dep_table.children.insert (parseXmlDep (iter2)); - iter2 = iter2->next(); - } - } -} - -//--------------------------------------------------------------------------- - - -string -Package::asString ( bool full ) const -{ - return toString (*this, full); -} - - -string -Package::toString ( const PackageUpdateList & l, bool full ) -{ - string ret ("["); - for (PackageUpdateList::const_iterator i = l.begin(); i != l.end(); i++) { - if (i != l.begin()) ret += ", "; - ret += (*i)->asString(full); - } - return ret + "]"; -} - -string -Package::toString ( const Package & package, bool full ) -{ - string ret; - ret += ResItem::toString(package, full); - if (full) { -// if (package._section != NULL) ret += (string ("
asString() + "'/>"); -// if (!package._pretty_name.empty()) ret += (string (""); -// if (!package._summary.empty()) ret += (string (""); -// if (!package._description.empty()) ret += (string (""); - ret += (string (""); - } - return ret; -} - - -ostream & -Package::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const Package& package) -{ - return os << package.asString(); -} - -//--------------------------------------------------------------------------- - -Package::Package (Channel_constPtr channel, const Resolvable::Kind & kind) - : ResItem (kind, "") - , _pretty_name ("") - , _summary ("") - , _description ("") - , _package_filename ("") - , _signature_filename ("") - , _install_only (false) - , _package_set (false) - , _id ("") -{ - setChannel (channel); -} - - -Package::Package (Channel_constPtr channel, - const Resolvable::Kind & kind, - const string & name, - const Edition & edition, - const Arch arch) - - : ResItem (kind, name, edition, arch) - , _pretty_name ("") - , _summary ("") - , _description ("") - , _package_filename ("") - , _signature_filename ("") - , _install_only (false) - , _package_set (false) - , _id ("") -{ - - setChannel (channel); -} - - -Package::Package (XmlNode_constPtr node, Channel_constPtr channel, const Resolvable::Kind & kind) - : ResItem (kind, "") - , _pretty_name ("") - , _summary ("") - , _description ("") - , _package_filename ("") - , _signature_filename ("") - , _install_only (false) - , _package_set (false) - , _id ("") -{ - string name = ""; - int epoch = Edition::noepoch; - string version = ""; - string release = ""; - Arch arch = Arch_noarch; - - if (!node->equals("package")) { - ERR << "Package::Package() not a package node" << endl; - exit (1); - } - - struct DepTable dep_table; - - setChannel (channel); - - XmlNode_constPtr iter = node->children(); - - while (iter) { - bool extracted_deps = false; - - if (iter->equals("name")) { name = iter->getContent(); - } else if (iter->equals("epoch")) { epoch = atoi (iter->getContent().c_str()); - } else if (iter->equals("version")) { version = iter->getContent(); - } else if (iter->equals("release")) { release = iter->getContent(); - } else if (iter->equals("summary")) { _summary = iter->getContent(); - } else if (iter->equals("description")) { _description = iter->getContent(); - } else if (iter->equals("arch")) { arch = Arch(iter->getContent()); - } else if (iter->equals("filesize")) { - setFileSize (iter->getIntValueDefault("filesize", 0)); - } else if (iter->equals("installedsize")) { - setInstalledSize (iter->getIntValueDefault("installedsize", 0)); - } else if (iter->equals("install_only")) { _install_only = true; - } else if (iter->equals("package_set")) { _package_set = true; - } else if (iter->equals("history")) { - XmlNode_constPtr iter2; - - iter2 = iter->children(); - - while (iter2) { - if (!iter2->isElement()) { - iter2 = iter2->next(); - continue; - } - - PackageUpdate_Ptr update = new PackageUpdate (iter2, this); - addUpdate (update); - - iter2 = iter2->next(); - } - } else if (iter->equals("deps")) { - XmlNode_constPtr iter2; - - for (iter2 = iter->children(); iter2; iter2 = iter2->next()) { - if (!iter2->isElement()) - continue; - - extract_dep_info (iter2, dep_table); - } - - extracted_deps = true; - } - else { - if (!extracted_deps) - extract_dep_info (iter, dep_table); - else { - /* FIXME: Bitch to the user here? */ - } - } - - iter = iter->next(); - } - - if (!dep_table.children.empty()) { - // children are used in package sets - // treat them as normal requires - // -#warning Children are handled as requires - CapSet::const_iterator iter; - for (iter = dep_table.children.begin(); iter != dep_table.children.end(); iter++) - { - dep_table.requires.insert (*iter); - } - } - - - // check if we're already listed in the provides - // if not, provide ourself - CapFactory factory; - Capability selfdep = factory.parse ( kind, - name, - Rel::EQ, - Edition( version, release, zypp::str::numstring(epoch))); - - - CapSet::const_iterator piter; - for (piter = dep_table.provides.begin(); piter != dep_table.provides.end(); piter++) { - if ((*piter) == selfdep) - { - break; - } - } - if (piter == dep_table.provides.end()) { // no self provide found, construct one - _DBG("RC_SPEW") << "Adding self-provide [" << selfdep.asString() << "]" << endl; - dep_table.provides.insert (selfdep); - } - - Dependencies deps; - deps[Dep::REQUIRES] = dep_table.requires; - deps[Dep::PROVIDES] = dep_table.provides; - deps[Dep::CONFLICTS] = dep_table.conflicts; - deps[Dep::OBSOLETES] = dep_table.obsoletes; - deps[Dep::SUGGESTS] = dep_table.suggests; - deps[Dep::RECOMMENDS] = dep_table.recommends; - deprecatedSetDependencies (deps); - - if (!_history.empty()) { - - /* If possible, we grab the version info from the most - recent update. */ - - PackageUpdate_Ptr update = _history.front(); - - epoch = update->package()->epoch(); - version = update->package()->version(); - release = update->package()->release(); - - } - else { - - /* Otherwise, try to find where the package provides itself, - and use that version info. */ - - if (!provides().empty()) - for (CapSet::const_iterator iter = provides().begin(); iter != provides().end(); iter++) { - std::string capString = (*iter).asString(); - std::string cmpString = name + " == "; - string::size_type ret = capString.find (cmpString); - if (ret != string::npos) - { - Edition edition = Edition(capString.substr (cmpString.length())); - epoch = edition.epoch(); - version = edition.version(); - release = edition.release(); - break; - } - } - } - - Edition _edition( version, release, zypp::str::numstring(epoch) ); - shared_ptr pkgImpl; - zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( NVRAD(name, _edition, arch), - pkgImpl ) ); - _resObject = pkg; -} - -Package::~Package() -{ -} - -//--------------------------------------------------------------------------- - - -void -Package::addUpdate (PackageUpdate_Ptr update) -{ - if (update == NULL) return; - - assert (update->package() == NULL - || update->package() == const_cast(this)); - - update->setPackage(this); - - if (_history.empty()) { - _history.push_back (update); - } else { -#warning addUpdate incomplete -#if 1 - for (PackageUpdateList::iterator iter = _history.begin(); iter != _history.end(); iter++) { - int result = Spec::compare ((Spec_Ptr)update, (Spec_Ptr)(*iter)); - - if (result > 0 || (result == 0 && update->parent() != NULL)) { - _history.insert (iter, update); // = g_slist_insert_before (package->history, l, update); - break; - } else if (iter == _history.end() || // FIXME list.last() ? - (result == 0 && update->parent() == NULL)) { - _history.insert (++iter, update); // = g_slist_insert_before (package->history, l->next, update); - break; - } - } -#endif - } -} - - -PackageUpdate_Ptr -Package::getLatestUpdate (void) const -{ - World_Ptr world; - - if (_history.empty()) { - return NULL; - } - - PackageUpdate_Ptr latest = _history.back(); - /* if the absolute latest is not a patch, just return that */ - if (latest->parent() == NULL) { - return latest; - } - - world = World::globalWorld(); - - for (PackageUpdateList::const_iterator l = _history.begin(); l != _history.end(); l++) { - PackageUpdate_Ptr update = *l; - ResItem_constPtr installed; - - if (!update->equals (latest)) { - return NULL; - } - - /* found a non-patch package equal to the latest, so use that */ - if (update->parent() == NULL) { - return update; - } - - /* see if the required parent for this patch is installed */ - - installed = world->findInstalledResItem (update->parent()); - - if (installed != NULL && - installed->equals(update->parent())) - return update; - } - - /* no suitable update found */ - return NULL; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/Package.h b/zypp/solver/temporary/Package.h deleted file mode 100644 index 2864b4e..0000000 --- a/zypp/solver/temporary/Package.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Package.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 ZYPP_SOLVER_TEMPORARY_PACKAGE_H -#define ZYPP_SOLVER_TEMPORARY_PACKAGE_H - -#include -#include -#include -#include - -#include "zypp/solver/temporary/PackagePtr.h" -#include "zypp/solver/temporary/PackageUpdatePtr.h" -#include "zypp/solver/temporary/ResItem.h" -#include "zypp/solver/temporary/XmlNode.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef std::list PackageList; -typedef PackageList * PackageList_Ptr; - -typedef std::list PackageUpdateList; -typedef PackageUpdateList * PackageUpdateList_Ptr; - - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Package -/** - * - **/ - -class Package : public ResItem { - - - private: - - // Filled in by package info XML - std::string _pretty_name; - std::string _summary; - std::string _description; - - PackageUpdateList _history; - - // After downloading this package, fill in the local file name, - // and signature, if appropriate - std::string _package_filename; - std::string _signature_filename; - - bool _install_only; // Only install, don't upgrade this package - bool _package_set; - - std::string _id; - - public: - - Package(Channel_constPtr channel, const Resolvable::Kind & kind); - Package(Channel_constPtr channel, - const Resolvable::Kind & kind, // Yes, its a hack, but 'Package' is just for the testsuite anyways - const std::string & name, - const Edition & edition = Edition::noedition, - const Arch arch = Arch_noarch); - Package(XmlNode_constPtr node, Channel_constPtr channel, const Resolvable::Kind & kind); - virtual ~Package(); - - // ---------------------------------- I/O - - const xmlNodePtr asXmlNode (void) const; // xmlNode *rc_package_to_xml_node (RCPackage *package); - - static std::string toString ( const Package & spec, bool full = false ); - - static std::string toString ( const PackageUpdateList & l, bool full = false ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const Package& ); - - std::string asString ( bool full = false ) const; - - // ---------------------------------- accessors - - // accessor for _pretty_name - const std::string prettyName() const { return _pretty_name; } - void setPrettyName(const std::string & pretty_name) { _pretty_name = pretty_name; } - - // accessor for _summary - const std::string summary() const { return _summary; } - void setSummary (const std::string & summary) { _summary = summary; } - - // accessor for _description - const std::string description() const { return _description; } - void setDescription(const std::string & description) { _description = description; } - - // accessor for _package_filename - const PackageUpdateList & history() const { return _history; } - void setHistory(const PackageUpdateList & history) { _history = history; } - - // accessor for _package_filename - const std::string packageFilename() const { return _package_filename; } - void setPackageFilename(const std::string & package_filename) { _package_filename = package_filename; } - - // accessor for _signature_filename - const std::string signatureFilename() const { return _signature_filename; } - void setSignatureFilename(const std::string & signature_filename) { _signature_filename = signature_filename; } - - // accessor for _install_only - bool installOnly() const { return _install_only; } - void setInstallOnly(bool install_only) { _install_only = install_only; } - - // accessor for _package_set - bool packageSet() const { return _package_set; } - void setPackageSet(bool package_set) { _package_set = package_set; } - - // accessor for id - const std::string id() const { return _id; } - void setId (const std::string & id) { _id = id; } - - // ---------------------------------- methods - - void addUpdate (PackageUpdate_Ptr update); - - PackageUpdate_Ptr getLatestUpdate (void) const; - }; - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_PACKAGE_H diff --git a/zypp/solver/temporary/PackagePtr.h b/zypp/solver/temporary/PackagePtr.h deleted file mode 100644 index dfc9ba8..0000000 --- a/zypp/solver/temporary/PackagePtr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Package_Ptr.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 ZYPP_SOLVER_TEMPORARY_PACKAGE_PTR_H -#define ZYPP_SOLVER_TEMPORARY_PACKAGE_PTR_H - -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/temporary/ResItemPtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : Package_Ptr - // CLASS NAME : Package_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Package); - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - -#endif // ZYPP_SOLVER_TEMPORARY_PACKAGE_PTR_H diff --git a/zypp/solver/temporary/PackageUpdate.cc b/zypp/solver/temporary/PackageUpdate.cc deleted file mode 100644 index a0690ec..0000000 --- a/zypp/solver/temporary/PackageUpdate.cc +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* PackageUpdate.cc - * - * 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 -#include -#include - -#include "zypp/base/String.h" -#include "zypp/solver/temporary/utils.h" -#include "zypp/solver/temporary/PackageUpdate.h" -#include "zypp/solver/temporary/Package.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(PackageUpdate); - -//--------------------------------------------------------------------------- - -string -PackageUpdate::asString ( bool full ) const -{ - return toString (*this); -} - - -string -PackageUpdate::toString ( const PackageUpdate & package_update, bool full ) -{ - string ret; - ret += ((const Spec &)package_update).asString(full); - - return ret; -} - - -ostream & -PackageUpdate::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const PackageUpdate& package_update) -{ - return os << package_update.asString(); -} - - -const XmlNode_Ptr -PackageUpdate::asXmlNode (void) const -{ - XmlNode_Ptr update_node = new XmlNode("update"); - string tmp; - - if (hasEpoch()) { - tmp = str::form("%d", epoch()); - update_node->addTextChild ("epoch", tmp); - } - - update_node->addTextChild ("version", version()); - - if (!release().empty()) { - update_node->addTextChild ("release", release()); - } - - if (!_package_url.empty()) { - char * u = strdup (_package_url.c_str()); - update_node->addTextChild ("filename", basename (u)); // HACK: basename expects 'char *', c_str() delivers 'const char *' - free (u); - } - - tmp = str::form ("%ld", (unsigned long)_package_size); - update_node->addTextChild ("filesize", tmp.c_str()); - - tmp = str::form ("%ld", (unsigned long)_installed_size); - update_node->addTextChild ("installedsize", tmp); - - if (!_signature_url.empty()) { - update_node->addTextChild ("signaturename", _signature_url); - - tmp = str::form ("%ld", (unsigned long)_signature_size); - update_node->addTextChild ("signaturesize", tmp); - } - - if (!_md5sum.empty()) { - update_node->addTextChild ("md5sum", _md5sum); - } - - update_node->addTextChild ("importance", _importance.asString()); - - update_node->addTextChild ("description", _description); - - if (_hid) { - tmp = str::form ("%d", _hid); - update_node->addTextChild ("hid", tmp); - } - - if (!_license.empty()) { - update_node->addTextChild ("license", _license); - } - - return update_node; -} - -//--------------------------------------------------------------------------- - -PackageUpdate::PackageUpdate (const string & name, const Resolvable::Kind & kind) - : Spec (kind, name) - , _package (NULL) - , _package_size (0) - , _installed_size (0) - , _signature_size (0) - , _importance (Importance::Undefined) - , _hid (0) - , _parent (NULL) -{ -} - - -PackageUpdate::PackageUpdate (XmlNode_constPtr node, Package_Ptr package) - : Spec (package->kind(), package->name()) - , _package (NULL) - , _package_size (0) - , _installed_size (0) - , _signature_size (0) - , _importance (Importance::Undefined) - , _hid (0) - , _parent (NULL) -{ - Channel_constPtr channel; - string url_prefix; - - if (node == NULL) { - ERR << "PackageUpdate::PackageUpdate(NULL)" << endl; - exit (1); - } - - /* Make sure this is an update node */ - if (!node->equals("update")) { - ERR << "PackageUpdate::PackageUpdate() wrong node (" << node->name() << ")" << endl; - exit (1); - } - - channel = package->channel(); - - _package = package; - - if (channel) { - url_prefix = channel->filePath(); - } - - XmlNode_Ptr iter = node->children(); - - while (iter) { - if (iter->equals ("epoch")) { setEpoch (iter->getUnsignedIntContentDefault (0)); - } else if (iter->equals ("version")) { setVersion (iter->getContent()); - } else if (iter->equals ("release")) { setRelease (iter->getContent()); - } else if (iter->equals ("arch")) { setArch (iter->getContent()); - } else if (iter->equals ("filename")) { - string tmp = iter->getContent(); - if (!url_prefix.empty()) { - _package_url = maybe_merge_paths (url_prefix, tmp); - } else { - _package_url = tmp; - } - } else if (iter->equals ("filesize")) { _package_size = iter->getUnsignedIntContentDefault (0); - } else if (iter->equals ("installedsize")) { _installed_size = iter->getUnsignedIntContentDefault (0); - } else if (iter->equals ("signaturename")) { - string tmp = iter->getContent(); - if (!url_prefix.empty()) { - _signature_url = maybe_merge_paths (url_prefix, tmp); - } else { - _signature_url = tmp; - } - } else if (iter->equals ("signaturesize")) { _signature_size = iter->getUnsignedIntContentDefault (0); - } else if (iter->equals ("md5sum")) { _md5sum = iter->getContent(); - } else if (iter->equals ("importance")) { _importance = Importance::parse (iter->getContent()); - } else if (iter->equals ("description")) { _description = iter->getContent(); - } else if (iter->equals ("hid")) { _hid = iter->getUnsignedIntContentDefault (0); - } else if (iter->equals ("license")) { _license = iter->getContent(); - } - - iter = iter->next(); - } -} - - -PackageUpdate::~PackageUpdate() -{ - if (_package != NULL) _package = NULL; - if (_parent != NULL) _parent = NULL; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/PackageUpdate.h b/zypp/solver/temporary/PackageUpdate.h deleted file mode 100644 index 187b7ff..0000000 --- a/zypp/solver/temporary/PackageUpdate.h +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* PackageUpdate.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 ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_H -#define ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_H - -#include -#include -#include -#include - -#include "zypp/solver/detail/Importance.h" - -#include "zypp/solver/temporary/PackageUpdatePtr.h" -#include "zypp/solver/temporary/PackagePtr.h" -#include "zypp/solver/temporary/Spec.h" -#include "zypp/solver/temporary/XmlNode.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : PackageUpdate -/** - * - **/ - -class PackageUpdate : public Spec { - - - private: - Package_Ptr _package; - - std::string _package_url; - size_t _package_size; - size_t _installed_size; - - std::string _signature_url; - size_t _signature_size; - - std::string _md5sum; - - Importance _importance; - - unsigned int _hid; - - std::string _description; - - std::string _license; - - // refers to the parent package for SuSE patch RPMs - Package_constPtr _parent; - - public: - - PackageUpdate(const std::string & name, const Resolvable::Kind & kind); // Yes, 'kind' is a hack, but 'PackageUpdate' is just for the testsuite anyways - PackageUpdate(XmlNode_constPtr node, Package_Ptr package); - - virtual ~PackageUpdate(); - - // ---------------------------------- I/O - - const XmlNode_Ptr asXmlNode (void) const; - - static std::string toString ( const PackageUpdate & packageupdate, bool full = false ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const PackageUpdate& ); - - std::string asString ( bool full = false ) const; - - // ---------------------------------- accessors - - Package_constPtr package() const { return _package; } - void setPackage (Package_Ptr package) { _package = package; } - - const std::string packageUrl() const { return _package_url; } - void setPackageUrl (const std::string & package_url) { _package_url = package_url; } - - size_t packageSize() const { return _package_size; } - void setPackageSize (size_t package_size) { _package_size = package_size; } - - size_t installedSize() const { return _installed_size; } - void setInstalledSize (size_t installed_size ) { _installed_size = installed_size; } - - const std::string description() const { return _description; } - void setDescription(const std::string & description) { _description = description; } - - const std::string signatureUrl() const { return _signature_url; } - void setSignatureUrl (const std::string & signature_url) { _signature_url = signature_url; } - - size_t signatureSize() const { return _signature_size; } - void setSignatureSize (size_t signature_size) { _signature_size = signature_size; } - - const std::string md5sum() const { return _md5sum; } - void setMd5sum (const std::string & md5sum) { _md5sum = md5sum; } - - const Importance importance() const { return _importance; } - void setImportance (const Importance & importance) { _importance = importance; } - - unsigned int hid() const { return _hid; } - void setHid (unsigned int hid) { _hid = hid; } - - const std::string license() const { return _license; } - void setLicense (const std::string & license) { _license = license; } - - // refers to the parent package for SuSE patch RPMs - Package_constPtr parent() const { return _parent; } - void setParent (Package_constPtr parent) { _parent = parent; } - - // ---------------------------------- methods - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_H diff --git a/zypp/solver/temporary/PackageUpdatePtr.h b/zypp/solver/temporary/PackageUpdatePtr.h deleted file mode 100644 index 398c089..0000000 --- a/zypp/solver/temporary/PackageUpdatePtr.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* PackageUpdate_Ptr.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 ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_PTR_H -#define ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_PTR_H - -#include "zypp/base/PtrTypes.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : PackageUpdate_Ptr - // CLASS NAME : PackageUpdate_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(PackageUpdate); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_PACKAGEUPDATE_PTR_H diff --git a/zypp/solver/temporary/ResItem.cc b/zypp/solver/temporary/ResItem.cc deleted file mode 100644 index 138d50c..0000000 --- a/zypp/solver/temporary/ResItem.cc +++ /dev/null @@ -1,310 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ResItem.cc - * Copyright (C) 2000-2002 Ximian, Inc. - * Copyright (C) 2005 SUSE Linux Products GmbH - * - * Definition of 'resItem' - * - * 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 "zypp/solver/temporary/ResItem.h" -#include "zypp/ResObject.h" -#include "zypp/Package.h" -#include "zypp/Selection.h" -#include "zypp/Pattern.h" -#include "zypp/Patch.h" -#include "zypp/Message.h" -#include "zypp/Script.h" -#include "zypp/Product.h" -#include "zypp/detail/PackageImpl.h" -#include "zypp/detail/SelectionImpl.h" -#include "zypp/detail/PatternImpl.h" -#include "zypp/detail/PatchImpl.h" -#include "zypp/detail/MessageImpl.h" -#include "zypp/detail/ScriptImpl.h" -#include "zypp/detail/ProductImpl.h" -#include "zypp/base/String.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - using namespace std; - - - IMPL_PTR_TYPE(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 - { - return toString (*this, full); - } - - - string - ResItem::toString ( const ResItem & resItem, bool full ) - { - string res; - - if (full - || (resItem.kind() != ResTraits::kind)) // only show non-package kinds - { - res += resItem.kind().asString(); - res += ":"; - } - - res += resItem.name(); - - string ed = resItem.edition().asString(); - if (!ed.empty() && - ed != "EDITION-UNSPEC") - { - res += "-"; - res += ed; - } - - if (resItem.arch() != Arch_noarch) { - res += "."; - res += resItem.arch().asString(); - } - - if (!resItem.channel()->system()) { - res += "["; - res += (resItem.channel() == NULL) ? "(channel?)" : resItem.channel()->name(); - res += "]"; - } - if (!full) return res; - - if (resItem.isInstalled()) res += ""; - if (resItem.local()) res += ""; - - res += "FileSize "; - res += str::numstring (resItem.fileSize()); - res += ", InstalledSize "; - res += str::numstring (resItem.installedSize()); - - if (!resItem.requires().empty()) { - res += ", Requires: "; - res += capSetToString(resItem.requires()); - } - - if (!resItem.provides().empty()) { - res += ", Provides: "; - res += capSetToString(resItem.provides()); - } - if (!resItem.conflicts().empty()) { - res += ", Conflicts: "; - res += capSetToString(resItem.conflicts()); - } - if (!resItem.obsoletes().empty()) { - res += ", Obsoletes: "; - res += capSetToString(resItem.obsoletes()); - } - - if (!resItem.suggests().empty()) { - res += ", Suggests: "; - res += capSetToString(resItem.suggests()); - } - if (!resItem.recommends().empty()) { - res += ", Recommends: "; - res += capSetToString(resItem.recommends()); - } - if (!resItem.freshens().empty()) { - res += ", Freshens: "; - res += capSetToString(resItem.freshens()); - } - return res; - } - - - string - ResItem::toString ( const CResItemList & rl, bool full ) - { - string res("["); - for (CResItemList::const_iterator iter = rl.begin(); iter != rl.end(); iter++) { - if (iter != rl.begin()) res += ", "; - res += (*iter)->asString(full); - } - return res + "]"; - } - - - ostream & - ResItem::dumpOn( ostream & str ) const - { - str << asString(); - return str; - } - - - ostream& - operator<<( ostream& os, const ResItem& edition) - { - return os << edition.asString(); - } - - //--------------------------------------------------------------------------- - - ResItem::ResItem (const Resolvable::Kind & kind, const string & name, const Edition & edition, const Arch & arch) - : _channel (false) - , _installed (false) - , _local (false) - , _locked (false) - , _file_size (0) - , _installed_size (0) - - { -// Edition _edition( version, release, zypp::str::numstring(epoch) ); - - // create the ResObject - if (kind == ResTraits::kind) - { - shared_ptr pkgImpl; - zypp::Package::Ptr pkg( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - pkgImpl ) ); - _resObject = pkg; - } else if (kind == ResTraits::kind) - { - shared_ptr selImpl; - zypp::Selection::Ptr sel( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - selImpl ) ); - _resObject = sel; - } else if (kind == ResTraits::kind) - { - shared_ptr patternImpl; - zypp::Pattern::Ptr pattern( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - patternImpl ) ); - _resObject = pattern; - } else if (kind == ResTraits::kind) - { - shared_ptr productImpl; - zypp::Product::Ptr product( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - productImpl ) ); - _resObject = product; - } else if (kind == ResTraits::kind) - { - shared_ptr patchImpl; - zypp::Patch::Ptr patch( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - patchImpl ) ); - _resObject = patch; - } else if (kind == ResTraits::kind) - { - shared_ptr scriptImpl; - zypp::Script::Ptr script( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - scriptImpl ) ); - _resObject = script; - } else if (kind == ResTraits::kind) - { - shared_ptr messageImpl; - zypp::Message::Ptr message( zypp::detail::makeResolvableAndImpl( NVRAD(name, edition, arch), - messageImpl ) ); - _resObject = message; - } - - } - - ResItem::ResItem(const ResObject::Ptr & resObject) - : _channel (false) - , _installed (false) - , _local (false) - , _locked (false) - , _file_size (0) - , _installed_size (0) - { - assert (resObject); - _resObject = resObject; - } - - ResItem::~ResItem() - { - } - - //--------------------------------------------------------------------------- - - bool - ResItem::isInstalled () const - { - if (_channel != NULL - && _channel->system()) { - return true; - } - return false; - } - - bool - ResItem::equals(ResItem_constPtr item) const { - return ((kind() == item->kind()) - && (name() == item->name()) - && Edition::compare( edition(), item->edition()) == 0); - } - - bool ResItem::equals(const Resolvable::Kind & compKind, - const string & compName, - const Edition & compEdition) const { - return ((compKind == kind()) - && (compName == name()) - && Edition::compare( compEdition, edition()) == 0); - } - - int ResItem::compare (ResItem_constPtr res1, ResItem_constPtr res2) { - int rc = 0; - - const string name1 = res1->name(); - const string name2 = res2->name(); - if (! (name1.empty() && name2.empty())) - { - rc = name1.compare (name2); - } - if (rc) return rc; - - rc = Edition::compare (res1->edition(), - res2->edition()); - - return rc; - } - - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/temporary/ResItem.h b/zypp/solver/temporary/ResItem.h deleted file mode 100644 index 14ca69a..0000000 --- a/zypp/solver/temporary/ResItem.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ResItem.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 ZYPP_SOLVER_TEMPORARY_RESITEM_H -#define ZYPP_SOLVER_TEMPORARY_RESITEM_H - -#include -#include -#include -#include -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/temporary/ResItemPtr.h" -#include "zypp/solver/temporary/StoreWorldPtr.h" -#include "zypp/solver/temporary/Channel.h" - -#include "zypp/CapSet.h" -#include "zypp/ResObject.h" -#include "zypp/Edition.h" -#include "zypp/Dependencies.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef std::list ResItemList; -typedef std::list CResItemList; - -typedef std::set CResItemSet; - -typedef bool (*ResItemFn) (ResItem_Ptr r, void *data); -typedef bool (*CResItemFn) (ResItem_constPtr r, void *data); -typedef bool (*ResItemPairFn) (ResItem_constPtr r1, ResItem_constPtr r2, void *data); -typedef bool (*ResItemAndDepFn) (ResItem_constPtr r, const Capability & dep, void *data); - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : ResItem -/** - * - **/ - -class ResItem : public base::ReferenceCounted, private base::NonCopyable { - - - private: - Channel_constPtr _channel; - - bool _installed; - bool _local; - bool _locked; - - size_t _file_size; - size_t _installed_size; - - protected: - - // ---------------------------------- accessors - - void setLocal (bool local) { _local = local; } - ResObject::Ptr _resObject; - - public: - - ResItem(const Resolvable::Kind & kind, const std::string & name, const Edition & edition = Edition::noedition, const Arch & arch = Arch()); - - ResItem(const ResObject::Ptr & resObject); - ResItem(const XmlNode_Ptr node); - - virtual ~ResItem(); - - // ---------------------------------- I/O - - const XmlNode_Ptr asXmlNode (void) const; - - static std::string toString ( const ResItem & res, bool full = false ); - - static std::string toString ( const CResItemList & reslist, bool full = false ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream & str, const ResItem & str); - - std::string asString ( bool full = false ) const; - - // ---------------------------------- accessors - - Channel_constPtr channel() const { return _channel; } - void setChannel (Channel_constPtr channel) { _channel = channel; } - - bool locked () const { return _locked; } - void setLocked (bool locked) { _locked = locked; } - - bool isInstalled() const; // does *not* reflect _installed - void setInstalled (bool installed) { _installed = installed; } - - bool local() const { return _local; } - - size_t fileSize() const { return _file_size; } - void setFileSize (size_t file_size) { _file_size = file_size; } - - size_t installedSize() const { return _installed_size; } - void setInstalledSize (size_t installed_size) { _installed_size = installed_size; } - - const CapSet & requires() const { return _resObject->dep( Dep::REQUIRES ); } - const CapSet & prerequires() const { return _resObject->dep( Dep::PREREQUIRES ); } - const CapSet & provides() const { return _resObject->dep( Dep::PROVIDES ); } - const CapSet & conflicts() const { return _resObject->dep( Dep::CONFLICTS ); } - const CapSet & obsoletes() const { return _resObject->dep( Dep::OBSOLETES ); } - const CapSet & suggests() const { return _resObject->dep( Dep::SUGGESTS ); } - const CapSet & recommends() const { return _resObject->dep( Dep::RECOMMENDS ); } - const CapSet & freshens() const { return _resObject->dep( Dep::FRESHENS ); } - - void deprecatedSetDependencies (const Dependencies & dependencies) { _resObject->deprecatedSetDeps(dependencies); } - - ResObject::constPtr resObject() { return _resObject; } - - // Spec definitions - - const Edition & edition() const { return _resObject->edition(); } - const std::string & version() const { return edition().version(); } - const std::string & release() const { return edition().release(); } - const int epoch() const { return edition().epoch(); } - bool hasEpoch() const { return edition().epoch() != Edition::noepoch; } - const Arch & arch() const { return _resObject->arch(); } - const Resolvable::Kind & kind() const { return _resObject->kind(); } - const std::string name() const { return _resObject->name(); } - bool equals(ResItem_constPtr item) const; - bool equals(const Resolvable::Kind & kind, const std::string & name, - const Edition & edition) const; - - static int compare (ResItem_constPtr res1, ResItem_constPtr res2); - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_RESITEM_H diff --git a/zypp/solver/temporary/ResItemPtr.h b/zypp/solver/temporary/ResItemPtr.h deleted file mode 100644 index 0d4f00f..0000000 --- a/zypp/solver/temporary/ResItemPtr.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ResItem_Ptr.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 ZYPP_SOLVER_TEMPORARY_RESITEM_PTR_H -#define ZYPP_SOLVER_TEMPORARY_RESITEM_PTR_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/solver/temporary/SpecPtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : ResItem_Ptr - // CLASS NAME : ResItem_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(ResItem); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_RESITEM_PTR_H diff --git a/zypp/solver/temporary/ServiceWorld.cc b/zypp/solver/temporary/ServiceWorld.cc deleted file mode 100644 index 01a16a3..0000000 --- a/zypp/solver/temporary/ServiceWorld.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ServiceWorld.cc - * - * 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 "zypp/solver/temporary/ServiceWorld.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - using namespace std; - - IMPL_PTR_TYPE(ServiceWorld); - - //--------------------------------------------------------------------------- - - string - ServiceWorld::asString ( void ) const - { - return toString (*this); - } - - - string - ServiceWorld::toString ( const ServiceWorld & service ) - { - return ""; - } - - - ostream & - ServiceWorld::dumpOn( ostream & str ) const - { - str << asString(); - return str; - } - - - ostream& - operator<<( ostream& os, const ServiceWorld & service) - { - return os << service.asString(); - } - - //--------------------------------------------------------------------------- - - ServiceWorld::ServiceWorld () - : StoreWorld (SERVICE_WORLD) - { - } - - - ServiceWorld::~ServiceWorld() - { - ERR << "*** deleting service world[" << this << "]: " << World::toString(type()) << endl; - } - - //--------------------------------------------------------------------------- - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/ServiceWorld.h b/zypp/solver/temporary/ServiceWorld.h deleted file mode 100644 index c3a0ec1..0000000 --- a/zypp/solver/temporary/ServiceWorld.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ServiceWorld.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 ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_H -#define ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_H - -#include -#include - -#include "zypp/solver/temporary/ServiceWorldPtr.h" -#include "zypp/solver/temporary/StoreWorld.h" -#include "zypp/solver/temporary/Channel.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef bool (*ServiceWorldAssembleFn) (ServiceWorld_Ptr service, void *error); // GError **error - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : ServiceWorld - -class ServiceWorld : public StoreWorld { - - - private: - - std::string _url; - std::string _name; - std::string _unique_id; - - bool _is_sticky; // if true, can't be unmounted - bool _is_invisible; // ... to users - bool _is_unsaved; // Never save into the services.xml file - bool _is_singleton; // only one such service at a time. FIXME: broken - - ServiceWorldAssembleFn _assemble_fn; - - public: - - ServiceWorld (); - virtual ~ServiceWorld(); - - // ---------------------------------- I/O - - static std::string toString (const ServiceWorld & section); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const ServiceWorld & section); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - std::string url () const { return _url; } - std::string name () const { return _name; } - void setName (const std::string & name) { _name = name; } - std::string unique_id () const { return _unique_id; } - - // ---------------------------------- methods - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - -#endif // ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_H diff --git a/zypp/solver/temporary/ServiceWorldPtr.h b/zypp/solver/temporary/ServiceWorldPtr.h deleted file mode 100644 index ae829ed..0000000 --- a/zypp/solver/temporary/ServiceWorldPtr.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* ServiceWorld_Ptr.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 ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_PTR_H -#define ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_PTR_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/solver/temporary/WorldPtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : ServiceWorld_Ptr - // CLASS NAME : ServiceWorld_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(ServiceWorld); - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - -#endif // ZYPP_SOLVER_TEMPORARY_SERVICEWORLD_PTR_H diff --git a/zypp/solver/temporary/Spec.cc b/zypp/solver/temporary/Spec.cc deleted file mode 100644 index b4e5770..0000000 --- a/zypp/solver/temporary/Spec.cc +++ /dev/null @@ -1,277 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Spec.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 "zypp/solver/temporary/Spec.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(Spec); - -//--------------------------------------------------------------------------- - -string -Spec::asString ( bool full ) const -{ - return toString (*this, full); -} - - -string -Spec::toString ( const Spec & spec, bool full ) -{ - string res; - - if (full - || (spec.kind() != "Package" - && spec.kind() != "ResObject")) { - res += spec.kind().asString(); - res += ":"; - } - - res += spec.name(); - - string ed = spec.edition().asString(); - if (!ed.empty() && - ed != "EDITION-UNSPEC") { - res += "-"; - res += ed; - } - - if (spec.arch() != Arch_noarch) { - res += "."; - res += spec.arch().asString(); - } - - - return res; -} - - -ostream & -Spec::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const Spec& spec) -{ - return os << spec.asString(); -} - -//--------------------------------------------------------------------------- - -Spec::Spec (const Resolvable::Kind & kind, const string & name, const Edition & edition, const Arch & arch) - : _kind (kind) - , _name (Name (name)) - , _edition (edition) - , _arch (arch) -{ -} - - -Spec::Spec ( const Resolvable::Kind & kind, const string & name, int epoch, const string & version, const string & release, const Arch & arch) - : _kind (kind) - , _name (Name (name)) - , _edition (Edition (version, release, epoch)) - , _arch(arch) -{ -} - - -Spec::Spec (XmlNode_constPtr node, const Resolvable::Kind & kind) - : _kind (kind) -{ - ERR << "Spec::Spec (XmlNode_constPtr node)\nNot implemented" << endl; - abort(); -} - - -Spec::~Spec() -{ -} - - -// needed during xml parsing (-> XmlParser) - -Spec_constPtr -Spec::copy (void) const -{ - return new Spec (_kind, _name, _edition); -} - - -#if 0 -xmlNode * -rc_resItem_spec_to_xml_node (RCResItemSpec *spec) -{ - xmlNode *spec_node; - char buffer[128]; - - spec_node = xmlNewNode (NULL, "spec"); - - xmlNewTextChild (spec_node, NULL, "name", - g_quark_to_string (spec->nameq)); - - if (spec->has_epoch) { - g_snprintf (buffer, 128, "%d", spec->epoch); - xmlNewTextChild (spec_node, NULL, "epoch", buffer); - } - - xmlNewTextChild (spec_node, NULL, "version", spec->version); - - if (spec->release) - xmlNewTextChild (spec_node, NULL, "release", spec->release); - - xmlNewTextChild (spec_node, NULL, "arch", - rc_arch_to_string (spec->arch)); - - return spec_node; -} - -#endif - -//--------------------------------------------------------------------------- - - -HashValue -Spec::hash (void) const -{ - HashValue ret = _edition.epoch() + 1; - const char *spec_strs[3], *p; - int i; - - spec_strs[0] = _name.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]; - if (p) { - for (p += 1; *p != '\0'; ++p) { - ret = (ret << 5) - ret + *p; - } - } else { - ret = ret * 17; - } - } - - return ret; -} - - -const Spec * -Spec::findByName (const SpecList &speclist, const Name & name) const -{ - const Spec *spec = NULL; - for (SpecList::const_iterator iter = speclist.begin(); iter != speclist.end(); iter++) { - if ((*iter).name() == name) { - spec = &(*iter); - break; - } - } - return spec; -} - - -bool -Spec::match(Spec_constPtr spec) const { - return ((_kind == spec->kind()) - && (_name == spec->name()) - && Edition::compare( _edition, spec->edition()) == 0); -} - - -bool -Spec::equals(Spec_constPtr spec) const { -// ERR << "<" << asString(true) << "> equals <" << spec->asString(true) << ">" << endl; - return ((_kind == spec->kind()) - && (_name == spec->name()) - && 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; -} - - -int Spec::compare (Spec_constPtr spec1, Spec_constPtr spec2) { - int rc = 0; - - const string name1 = spec1->name(); - const string name2 = spec2->name(); - if (! (name1.empty() && name2.empty())) - { - rc = name1.compare (name2); - } - if (rc) return rc; - - rc = Edition::compare (spec1->edition(), - spec2->edition()); - - return rc; -} - - - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/Spec.h b/zypp/solver/temporary/Spec.h deleted file mode 100644 index b139be5..0000000 --- a/zypp/solver/temporary/Spec.h +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Spec.h resItem specification: name + edition - * - * 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 ZYPP_SOLVER_TEMPORARY_SPEC_H -#define ZYPP_SOLVER_TEMPORARY_SPEC_H - -#include -#include -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/temporary/Hash.h" -#include "zypp/solver/temporary/SpecPtr.h" -#include "zypp/solver/temporary/XmlNode.h" - -#include "zypp/Edition.h" -#include "zypp/ResObject.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Spec -/** - * - **/ -typedef std::string Name; -class Spec : public base::ReferenceCounted, private base::NonCopyable { - - - private: - Resolvable::Kind _kind; - Name _name; - Edition _edition; - Arch _arch; - - public: - typedef std::list SpecList; - - Spec( const Resolvable::Kind & kind, - const std::string & name, - 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, const Edition & edition, const Arch & arch = Arch()); - - Spec (XmlNode_constPtr node, const Resolvable::Kind & kind); - - virtual ~Spec(); - - // ---------------------------------- I/O - - const xmlNodePtr asXmlNode (const char *name) const; - - static std::string toString ( const Spec & spec, bool full = false ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const Spec& ); - - std::string asString ( bool full = false ) const; - - // ---------------------------------- accessors - - 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); - - const int epoch() const { return _edition.epoch(); } - void setEpoch (int epoch); - bool hasEpoch() const { return _edition.epoch() > 0; } - - const 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()); } - - const Edition & edition() const { return _edition; } - void setEdition (const Edition & edition) { _edition = edition; } - - // calculate hash - HashValue hash (void) const; - - // match operator - bool match(Spec_constPtr spec) const; - bool equals (Spec_constPtr spec) const; - - // find spec in SpecList by name - const Spec * findByName (const SpecList &speclist, const Name & name) const; - static int compare (Spec_constPtr spec1, Spec_constPtr spec2); - - // copy - - Spec_constPtr copy (void) const; -}; -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_SPEC_H diff --git a/zypp/solver/temporary/SpecPtr.h b/zypp/solver/temporary/SpecPtr.h deleted file mode 100644 index 632e465..0000000 --- a/zypp/solver/temporary/SpecPtr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Spec_Ptr.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 ZYPP_SOLVER_TEMPORARY_SPEC_PTR_H -#define ZYPP_SOLVER_TEMPORARY_SPEC_PTR_H - -#include "zypp/base/PtrTypes.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : Spec_Ptr - // CLASS NAME : Spec_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(Spec); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - -#endif // ZYPP_SOLVER_TEMPORARY_SPEC_PTR_H diff --git a/zypp/solver/temporary/StoreWorld.cc b/zypp/solver/temporary/StoreWorld.cc deleted file mode 100644 index b0e7f63..0000000 --- a/zypp/solver/temporary/StoreWorld.cc +++ /dev/null @@ -1,794 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* StoreWorld.cc - * - * 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. - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "zypp/solver/temporary/StoreWorld.h" -#include "zypp/solver/detail/ResItemAndDependency.h" -#include "zypp/base/Logger.h" -#include "zypp/Arch.h" -#include "zypp/CapSet.h" -#include "zypp/base/Logger.h" -#include "zypp/CapMatch.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(StoreWorld); - -//--------------------------------------------------------------------------- - -string -StoreWorld::asString ( void ) const -{ - return toString (*this); -} - - -string -StoreWorld::toString ( const StoreWorld & storeworld ) -{ - string res (""); - - return res; -} - - -ostream & -StoreWorld::dumpOn (ostream & str) const -{ - str << asString(); - return str; -} - - -ostream & -operator<< (ostream & os, const StoreWorld & storeworld) -{ - return os << storeworld.asString(); -} - -//--------------------------------------------------------------------------- - -StoreWorld::StoreWorld (WorldType type) - : World (type) -{ -} - - -StoreWorld::~StoreWorld() -{ - ERR << "*** deleting store world[" << this << "]: " << World::toString(type()) << endl; -} - - -//--------------------------------------------------------------------------- - -// Add/remove resItems - -bool -StoreWorld::addResItem (ResItem_constPtr resItem) -{ - ResItemAndDependency_Ptr r_and_d; - string package_name; - Channel_constPtr channel; - bool actually_added_package = false; - - if (resItem == NULL) return false; - - channel = resItem->channel (); - -// ERR << "StoreWorld[" << this << "]::addResItem(" << ((Spec_constPtr)resItem)->asString() ") [" << (channel?channel->name():"?") << "]" << endl; - - - /* 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 - duplicate, we keep the one with the most recent version number - and drop the other. - - This check only applies to resItems in a channel. We have - to allow for multiple installs. Grrrr... - */ - - if (!resItem->isInstalled ()) { // its not a system package - - ResItem_constPtr dup_res; - - /* Filter out resItems with totally incompatible arches */ - if ( !resItem->arch().compatibleWith(Arch::System)) { - DBG << "Ignoring resItem with incompatible arch: Arch '" << resItem->arch().asString() - << "', " << resItem->asString(true) << endl; - goto finished; - } - - package_name = resItem->name().c_str(); - dup_res = findResItem (channel, package_name); - - /* This shouldn't happen (and would be caught by the check - below, because cmp will equal 0), but it never hurts to - check and produce a more explicit warning message. */ - - if (resItem == dup_res) { - WAR << "Ignoring re-add of resItem '" << package_name << "'" << endl; - goto finished; - } - - if (dup_res != NULL) { - int cmp; - - cmp = ResItem::compare (resItem, dup_res); -//ERR << "res: " << resItem->asString() << ", dup_res " << dup_res->asString() << ", cmp " << cmp << endl; - - /* If the resItem we are trying to add has a lower - version number, just ignore it. */ - - if (cmp < 0) { - MIL << "Not adding resItem '" << resItem->asString() << "'." << endl << "\tA newer version is already in the channel." - << endl; - MIL << "\t" << dup_res->asString() << endl; - 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 - first resItem and just return. */ - - if (cmp == 0 && arch_score > dup_arch_score) { - MIL << "Not adding resItem '" << resItem->asString() << "'." << endl - << "\tAnother resItem with the same version but with a preferred arch is already in the channel." << endl; - MIL << "\t" << dup_res->asString() << endl; - goto finished; - } -#endif - - /* Otherwise we throw out the old resItem and proceed with - adding the newer one. */ - - MIL << "Replacing resItem '" << dup_res->asString() << "'." << endl - << "\tAnother resItem in the channel has the same name and a superior " - << (cmp ? "version" : "arch") << "." << endl; - MIL << "\t" << resItem->asString() << endl; - - removeResItem (dup_res); - } - } - - actually_added_package = true; - - if (channel && !channel->hidden()) { - touchResItemSequenceNumber (); - } - - /* StoreWorld all of our resItems in a hash by name. */ - _resItems_by_name.insert (ResItemTable::value_type (resItem->name(), resItem)); - - /* StoreWorld all of the resItem's provides in a hash by name. */ - 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().index(), r_and_d)); - } - - /* StoreWorld all of the resItem's requires in a hash by name. */ - - 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().index(), r_and_d)); - } - - /* "Recommends" are treated as requirements. */ -#warning Recommends are treated as requirements - - 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().index(), r_and_d)); - } - - /* StoreWorld all of the resItem's conflicts in a hash by name. */ - - 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().index(), r_and_d)); - } - - /* StoreWorld all of the resItem's freshens in a hash by name. */ - - for (CapSet::const_iterator i = resItem->freshens().begin(); i != resItem->freshens().end(); i++) { - r_and_d = new ResItemAndDependency (resItem, *i); - _freshens_by_name.insert (ResItemAndDependencyTable::value_type (r_and_d->dependency().index(), r_and_d)); - } - - finished: - - return actually_added_package; -} - - -void -StoreWorld::addResItemsFromList (const CResItemList & slist) -{ - for (CResItemList::const_iterator i = slist.begin(); i != slist.end(); i++) { - if (!addResItem (*i)) { - ERR << "addResItem failed" << endl; - break; - } - } - return; -} - -//--------------------------------------------------------------------------- - -static void -resItem_table_remove (ResItemTable & table, ResItem_constPtr resItem) -{ - const string name = resItem->name(); - for (ResItemTable::iterator pos = table.lower_bound(name); pos != table.upper_bound(name); ++pos) { - ResItem_constPtr res = pos->second; - if (res == resItem) { - table.erase (pos); - break; - } - } - return; -} - - -static void -resItem_and_dependency_table_remove (ResItemAndDependencyTable & table, ResItem_constPtr resItem) -{ - const string name = resItem->name(); -// FIXME: this is inefficient but lower_bound can't to strcasecmp :-( -// for (ResItemAndDependencyTable::iterator pos = table.lower_bound(name); pos != table.upper_bound(name); pos++) { - for (ResItemAndDependencyTable::iterator pos = table.begin(); pos != table.end(); pos++) { - ResItemAndDependency_constPtr r_and_d = pos->second; - if (r_and_d->resItem() == resItem) { - table.erase (pos); - } - } - return; -} - -void -StoreWorld::removeResItem (ResItem_constPtr resItem) -{ - _DBG("RC_SPEW") << "StoreWorld::removeResItem (" - << resItem->asString() << ")" << endl; - - Channel_constPtr channel = resItem->channel (); - - if (! (channel && channel->hidden ())) - touchResItemSequenceNumber (); - - resItem_and_dependency_table_remove (_provides_by_name, resItem); - resItem_and_dependency_table_remove (_requires_by_name, resItem); - resItem_and_dependency_table_remove (_conflicts_by_name, resItem); - resItem_and_dependency_table_remove (_freshens_by_name, resItem); - - resItem_table_remove (_resItems_by_name, resItem); - - return; -} - - -void -StoreWorld::removeResItems (Channel_constPtr channel) -{ - ERR << "StoreWorld::removeResItems(" << channel->asString() << ") not implemented" << endl; -} - - -void -StoreWorld::clear () -{ - ERR << "StoreWorld::clear() not implemented" << endl; -} - -//--------------------------------------------------------------------------- -// Single resItem queries - -static bool -installed_version_cb (ResItem_constPtr resItem, void *data) -{ - ResItem_constPtr *installed = (ResItem_constPtr *)data; - - if (resItem->isInstalled ()) { - *installed = resItem; - return false; - } - return true; -} - - -ResItem_constPtr -StoreWorld::findInstalledResItem (ResItem_constPtr resItem) -{ - ResItem_constPtr installed; - sync (); - - foreachResItemByName (resItem->name(), new Channel(CHANNEL_TYPE_ANY) /* is this right? */, installed_version_cb, &installed); - - return installed; -} - - -// -// findResItem -// @channel: A non-wildcard #Channel. -// @name: The name of a resItem. -// @kind: Kind of resItem (defaults to 'Package') -// -// Searches the world for a resItem in the specified channel -// with the specified name. @channel must be an actual -// channel, not a wildcard. -// -// Return value: The matching resItem, or %NULL if no such -// resItem exists. -// - -ResItem_constPtr -StoreWorld::findResItem (Channel_constPtr channel, const string & name, const Resolvable::Kind & kind) const -{ - syncConditional (channel); - for (ResItemTable::const_iterator pos = _resItems_by_name.lower_bound(name); pos != _resItems_by_name.upper_bound(name); pos++) { - ResItem_constPtr res = pos->second; - if (res->channel() == channel - && res->kind() == kind) { - return res; - } - } - return NULL; -} - - -ResItem_constPtr -StoreWorld::findResItemWithConstraint (Channel_constPtr channel, const string & name, const Capability & constraint, bool is_and) const -{ - ERR << "StoreWorld::findResItemWithConstraint() not implemented" << endl; - return 0; -} - - -Channel_Ptr -StoreWorld::guessResItemChannel (ResItem_constPtr resItem) const -{ - ERR << "StoreWorld::guessResItemChannel(" << resItem->asString() << ") not implemented" << endl; - return 0; -} - - -//----------------------------------------------------------------------------- -// foreach resItem - -typedef struct { - Channel_Ptr channel; - CResItemFn callback; - void *data; - int count; - bool short_circuit; -} ForeachResItemInfo; - - -static void -foreach_resItem_cb (const string &name, ResItem_constPtr resItem, void *data) -{ - ForeachResItemInfo *info = (ForeachResItemInfo *)data; - - if (info->short_circuit) - return; - - /* FIXME: we should filter out dup uninstalled resItems. */ - - if (resItem && info->channel->equals(resItem->channel ())) { - if (info->callback) { - if (! info->callback (resItem, info->data)) - info->short_circuit = true; - } - ++info->count; - } -} - - -int -StoreWorld::foreachResItem (Channel_Ptr channel, CResItemFn fn, void *data) -{ - return foreachResItemByName ("", channel, fn, data); -} - - -int -StoreWorld::foreachResItemByName (const std::string & name, Channel_Ptr channel, CResItemFn fn, void *data) -{ - if (name.empty()) { - - ForeachResItemInfo info; - - info.channel = channel; - info.callback = fn; - info.data = data; - info.count = 0; - info.short_circuit = false; - - for (ResItemTable::const_iterator iter = _resItems_by_name.begin(); iter != _resItems_by_name.end(); iter++) { - foreach_resItem_cb (iter->first, iter->second, (void *)&info); - } - - return info.short_circuit ? -1 : info.count; - } - - - ResItemTable installed; // FIXME: rc_resItem_spec_equal - int count = 0; - - for (ResItemTable::const_iterator iter = _resItems_by_name.lower_bound(name); iter != _resItems_by_name.upper_bound(name); iter++) { - ResItem_constPtr resItem = iter->second; - if (resItem->isInstalled()) { - const string str = resItem->asString(); - installed.insert (ResItemTable::value_type(str,resItem)); - } - } - - for (ResItemTable::const_iterator iter = _resItems_by_name.lower_bound(name); iter != _resItems_by_name.upper_bound(name); iter++) { - ResItem_constPtr resItem = iter->second; - if (channel->equals (resItem->channel())) { - if (resItem->isInstalled() - || installed.find(resItem->asString()) == installed.end()) { - if (fn) { - if (! fn(resItem, data)) { - count = -1; - goto finished; - } - } - ++count; - } - } - } - -finished: - - return count; -} - - -int -StoreWorld::foreachResItemByKind (const Resolvable::Kind & kind, CResItemFn fn, void *data) -{ - int count = 0; - - for (ResItemTable::const_iterator iter = _resItems_by_name.begin(); iter != _resItems_by_name.end(); ++iter) { - ResItem_constPtr resItem = iter->second; - if (resItem->kind() == kind) { - ++count; - if (fn != NULL) { - fn (resItem, data); - } - } - } - return count; -} - - -int -StoreWorld::foreachResItemByMatch (Match_constPtr match, CResItemFn fn, void *data) -{ - ERR << "StoreWorld::foreachResItemByMatch () not implemented" << endl; - return 0; -} - - -//----------------------------------------------------------------------------- -// iterater over resItems with dependency - -typedef std::map InstalledTable; - -int -StoreWorld::foreachProvidingResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - InstalledTable installed; -// ERR << "StoreWorld::foreachProvidingResItem(" << dep->asString() << ")" << endl; - for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep.index()); iter != _provides_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - ResItem_constPtr res = r_and_d->resItem(); -// ERR << "StoreWorld::foreachProvidingResItem(): " << res->asString(true) << endl; - if (res != NULL && res->isInstalled ()) { - installed[res] = r_and_d; - } - } - - for (ResItemAndDependencyTable::const_iterator iter = _provides_by_name.lower_bound(dep.index()); iter != _provides_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - - if (r_and_d && r_and_d->verifyRelation (dep) == CapMatch::yes) { -//ERR << "found: " << r_and_d->resItem()->asString(true) << endl; - /* If we have multiple identical resItems in RCWorld, - we want to only include the resItem that is installed and - skip the rest. */ - if (r_and_d->resItem()->isInstalled() - || installed.find(r_and_d->resItem()) == installed.end()) { - - if (fn) { - if (! fn(r_and_d->resItem(), r_and_d->dependency(), data)) { - count = -1; - goto finished; - } - } - ++count; - } - } - } - - finished: - - return count; -} - -int -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.index()); iter != _requires_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - ResItem_constPtr res = r_and_d->resItem(); - if (res != NULL && res->isInstalled ()) { -//ERR << "is installed: " << res->asString(true) << endl; - installed[res] = r_and_d; - } - } - - for (ResItemAndDependencyTable::const_iterator iter = _requires_by_name.lower_bound(dep.index()); iter != _requires_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - - if (r_and_d && r_and_d->dependency().matches (dep) == CapMatch::yes) { - - /* If we have multiple identical resItems in RCWorld, - we want to only include the resItem that is installed and - skip the rest. */ - if (r_and_d->resItem()->isInstalled() - || installed.find(r_and_d->resItem()) == installed.end()) { - - if (fn) { - if (! fn(r_and_d->resItem(), r_and_d->dependency(), data)) { - count = -1; - goto finished; - } - } - ++count; - } - } - } - - finished: - - return count; -} - - -int -StoreWorld::foreachConflictingResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; - InstalledTable installed; -//ERR << "StoreWorld::foreachConflictingResItem (" << dep->name() << ")" << endl; - for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep.index()); iter != _conflicts_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - ResItem_constPtr res = r_and_d->resItem(); -//ERR << "==> " << res->asString() << endl; - if (res != NULL && res->isInstalled ()) { - installed[res] = r_and_d; - } - } - - for (ResItemAndDependencyTable::const_iterator iter = _conflicts_by_name.lower_bound(dep.index()); iter != _conflicts_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - -// if (r_and_d) -//ERR << "==> " << r_and_d->asString() << " verify " << dep->asString() << " ? " << (r_and_d->verifyRelation (dep) ? "Y" : "N") << endl; - if (r_and_d && r_and_d->dependency().matches (dep) == CapMatch::yes) { - /* If we have multiple identical resItems in RCWorld, - we want to only include the resItem that is installed and - skip the rest. */ - if (r_and_d->resItem()->isInstalled() - || installed.find(r_and_d->resItem()) == installed.end()) { - - if (fn) { - if (! fn(r_and_d->resItem(), r_and_d->dependency(), data)) { - count = -1; - goto finished; - } - } - ++count; - } - } - } - - finished: - - return count; -} - - -// look at _all_ resolvables freshening us, be it installed or uninstalled ones. - -int -StoreWorld::foreachFresheningResItem (const Capability & dep, ResItemAndDepFn fn, void *data) -{ - int count = 0; -// ERR << "StoreWorld::foreachFresheningResItem (" << dep.asString() << ")" << endl; - - for (ResItemAndDependencyTable::const_iterator iter = _freshens_by_name.lower_bound(dep.index()); iter != _freshens_by_name.upper_bound(dep.index()); iter++) { - ResItemAndDependency_constPtr r_and_d = iter->second; - - if (r_and_d) { - ERR << "==> " << r_and_d->asString() << " verify " << dep.asString() << " ? " - << ((r_and_d->dependency().matches(dep) == CapMatch::yes) ? "Y" : "N") << endl; - } - if (r_and_d && r_and_d->dependency().matches (dep) == CapMatch::yes) { -//ERR << "StoreWorld::foreachFresheningResItem found !, fn <" << fn << ">" << endl; - if (fn) { - if (! fn(r_and_d->resItem(), r_and_d->dependency(), data)) { - count = -1; - goto finished; - } - } - ++count; - } - } - - finished: - - return count; -} - -//----------------------------------------------------------------------------- -// channel functions - -void -StoreWorld::addChannel (Channel_Ptr channel) -{ - if (channel == NULL) return; - - channel->setWorld (this); - channel->setImmutable (true); - - _channels.push_back (channel); - - touchChannelSequenceNumber (); -} - - -void -StoreWorld::removeChannel (Channel_constPtr channel) -{ - if (channel == NULL - || ! containsChannel (channel)) - return; - - removeResItems (channel); - - for (ChannelList::iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if ((*iter)->equals (channel)) { - _channels.erase (iter); - touchChannelSequenceNumber (); - break; - } - } -} - - -bool -StoreWorld::containsChannel (Channel_constPtr channel) const -{ - for (ChannelList::const_iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if ((*iter)->equals (channel)) { - return true; - } - } - return false; -} - - -Channel_Ptr -StoreWorld::getChannelByName (const string & channel_name) const -{ - if (channel_name.empty()) { - return NULL; - } - - for (ChannelList::const_iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if ((*iter)->name() == channel_name) { - return *iter; - } - } - return NULL; -} - - -Channel_Ptr -StoreWorld::getChannelByAlias (const string & alias) const -{ - if (alias.empty()) { - return NULL; - } - - for (ChannelList::const_iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if ((*iter)->alias() == alias) { - return *iter; - } - } - return NULL; -} - - -Channel_Ptr -StoreWorld::getChannelById (const string & channel_id) const -{ - if (channel_id.empty()) { - return NULL; - } - - for (ChannelList::const_iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if ((*iter)->id() == channel_id) { - return *iter; - } - } - return NULL; -} - - -int -StoreWorld::foreachChannel (ChannelFn fn, void *data) const -{ - int count = 0; - for (ChannelList::const_iterator iter = _channels.begin(); iter != _channels.end(); iter++) { - if (!(*fn) (*iter, data)) - return -1; - count++; - } - return count; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/StoreWorld.h b/zypp/solver/temporary/StoreWorld.h deleted file mode 100644 index ab91293..0000000 --- a/zypp/solver/temporary/StoreWorld.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* StoreWorld.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 ZYPP_SOLVER_TEMPORARY_STOREWORLD_H -#define ZYPP_SOLVER_TEMPORARY_STOREWORLD_H - -#include -#include -#include -#include - -#include "zypp/solver/detail/ResItemAndDependency.h" - -#include "zypp/solver/temporary/StoreWorldPtr.h" -#include "zypp/solver/temporary/World.h" -#include "zypp/solver/temporary/ResItem.h" -#include "zypp/solver/temporary/Match.h" - -#include "zypp/Capability.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : StoreWorld - -class StoreWorld : public World { - - - private: - - int _freeze_count; - - ResItemTable _resItems_by_name; - ResItemAndDependencyTable _provides_by_name; - ResItemAndDependencyTable _requires_by_name; - ResItemAndDependencyTable _conflicts_by_name; - ResItemAndDependencyTable _freshens_by_name; - - ChannelList _channels; - - public: - - StoreWorld (WorldType type = STORE_WORLD); - virtual ~StoreWorld(); - - // ---------------------------------- I/O - - static std::string toString (const StoreWorld & storeworld); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const StoreWorld & storeworld); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - virtual ChannelList channels () const { return _channels; } - - // ---------------------------------- methods - - // Add/remove resItems - - bool addResItem (ResItem_constPtr resItem); - void addResItemsFromList (const CResItemList & slist); - void removeResItem (ResItem_constPtr resItem); - void removeResItems (Channel_constPtr channel); - void clear (); - - // Iterate over resItems - - virtual int foreachResItem (Channel_Ptr channel, CResItemFn fn, void *data); - virtual int foreachResItemByName (const std::string & name, Channel_Ptr channel, CResItemFn fn, void *data); - virtual int foreachResItemByKind (const Resolvable::Kind & kind, CResItemFn fn, void *user_data); - virtual int foreachResItemByMatch (Match_constPtr match, CResItemFn fn, void *data); - - // Iterate across provides or requirement - - virtual int foreachProvidingResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachRequiringResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachConflictingResItem (const Capability & cap, ResItemAndDepFn fn, void *data); - virtual int foreachFresheningResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data); - - // Channels - - void addChannel (Channel_Ptr channel); - void removeChannel (Channel_constPtr channel); - - virtual bool containsChannel (Channel_constPtr channel) const; - - virtual Channel_Ptr getChannelByName (const std::string & channel_name) const; - virtual Channel_Ptr getChannelByAlias (const std::string & alias) const; - virtual Channel_Ptr getChannelById (const std::string & channel_id) const; - - virtual int foreachChannel (ChannelFn fn, void *data) const; - - // Single resItem queries - - virtual ResItem_constPtr findInstalledResItem (ResItem_constPtr resItem); - virtual ResItem_constPtr findResItem (Channel_constPtr channel, const std::string & name, const Resolvable::Kind & kind = ResTraits::kind) const; - virtual ResItem_constPtr findResItemWithConstraint (Channel_constPtr channel, const std::string & name, const Capability & constraint, bool is_and) const; - virtual Channel_Ptr guessResItemChannel (ResItem_constPtr resItem) const; - -}; -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_STOREWORLD_H diff --git a/zypp/solver/temporary/StoreWorldPtr.h b/zypp/solver/temporary/StoreWorldPtr.h deleted file mode 100644 index 0f77438..0000000 --- a/zypp/solver/temporary/StoreWorldPtr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* StoreWorld_Ptr.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 ZYPP_SOLVER_TEMPORARY_STOREWORLD_PTR_H -#define ZYPP_SOLVER_TEMPORARY_STOREWORLD_PTR_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/solver/temporary/WorldPtr.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : StoreWorld_Ptr - // CLASS NAME : StoreWorld_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(StoreWorld); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_STOREWORLD_PTR_H diff --git a/zypp/solver/temporary/Subscription.cc b/zypp/solver/temporary/Subscription.cc deleted file mode 100644 index 5088ce0..0000000 --- a/zypp/solver/temporary/Subscription.cc +++ /dev/null @@ -1,413 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Subscription.cc - * - * 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 -#include - -#include -#include -#include "zypp/solver/temporary/Subscription.h" -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/XmlNode.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -#define SUBSCRIPTION_PATH "/var/adm/zypp" -#define OLD_SUBSCRIPTION_PATH "/var/lib/rcd" -#define SUBSCRIPTION_NAME "/subscriptions.xml" - -#define DEFAULT_SUBSCRIPTION_FILE SUBSCRIPTION_PATH SUBSCRIPTION_NAME -#define OLD_SUBSCRIPTION_FILE OLD_SUBSCRIPTION_PATH SUBSCRIPTION_NAME - -/* Old subscriptions expire in 60 days */ -#define OLD_SUBSCRIPTION_EXPIRATION 60*24*60*60 - -SubscriptionList Subscription::subscriptions; -bool Subscription::subscriptions_changed = false; -string Subscription::subscription_file = DEFAULT_SUBSCRIPTION_FILE; - -//--------------------------------------------------------------------------- - -string -Subscription::asString ( void ) const -{ - return toString (*this); -} - - -string -Subscription::toString ( const Subscription & s) -{ - return ""; -} - -ostream & -Subscription::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const Subscription & s) -{ - return os << s.asString(); -} - -//--------------------------------------------------------------------------- - - -void -Subscription::save (void) -{ - xmlDoc *doc; - xmlNode *root; - char buf[64]; - time_t now; - int save_retval; - - if (! subscriptions_changed) - return; - - time (&now); - - root = xmlNewNode (NULL, (const xmlChar*)"subscriptions"); - xmlNewProp (root, (const xmlChar*)"version", (const xmlChar*)"2.0"); - - doc = xmlNewDoc ((const xmlChar*)"1.0"); - xmlDocSetRootElement (doc, root); - - for (SubscriptionList::iterator iter = subscriptions.begin(); iter != subscriptions.end(); iter++) { - xmlNode *sub_node; - - Subscription *sub = *iter; - - /* Drop "old" (i.e. imported from 1.x) subscriptions that - we haven't seen for a while. */ - if (sub->_old) { - double elapsed = difftime (now, sub->_last_seen); - if (elapsed > OLD_SUBSCRIPTION_EXPIRATION) - continue; - } - - sub_node = xmlNewChild (root, NULL, (const xmlChar*)"channel", NULL); - - xmlNewProp (sub_node, (const xmlChar*)"id", (const xmlChar*)(sub->_channel_id.c_str())); - - snprintf (buf, sizeof (buf), "%ld", (long) sub->_last_seen); - xmlNewProp (sub_node, (const xmlChar*)"last_seen", (const xmlChar*)buf); - - if (sub->_old) - xmlNewProp (sub_node, (const xmlChar*)"old", (const xmlChar*)"1"); - } -#if 0 - save_retval = xmlSaveFile (subscription_file.c_str(), doc); -#else - save_retval = 1; -#endif - xmlFreeDoc (doc); - - if (save_retval > 0) { - /* Writing out the subscription file succeeded. */ - subscriptions_changed = false; - } else { - WAR << "Unable to save subscription data to '" - << subscription_file << "'" << endl; - WAR << "Subscription will not be saved!" << endl; - } -} - - -void -Subscription::load_old_subscriptions (void) -{ -#if 1 - return; -#else - static bool tried_to_do_this_already = false; - xmlDoc *doc; - XmlNode_Ptr node; - - if (tried_to_do_this_already) - return; - tried_to_do_this_already = true; - - if (access (OLD_SUBSCRIPTION_FILE, R_OK) != 0) { - WAR << "Can't find rcd 1.x subscription file '" - << OLD_SUBSCRIPTION_FILE << "'" << endl; - return; - } - - doc = xmlParseFile (OLD_SUBSCRIPTION_FILE); - if (doc == NULL) { - ERR << "Can't parse rcd 1.x subscription file '" - << OLD_SUBSCRIPTION_FILE << "'" << endl; - return; - } - - node = new XmlNode (xmlDocGetRootElement (doc)); - - if (!node->equals("subscriptions")) { - ERR << "rcd 1.x subscription file '" - << OLD_SUBSCRIPTION_FILE << "' is malformed" << endl; - return; - } - - MIL << "Importing rcd 1.x subscriptions." << endl; - - node = node->children(); - - while (node != NULL) { - - if (node->equals ("channel")) { - string id_str; - - id_str = node->getProp ("channel_id"); - if (!id_str.empty()) { - - Subscription *sub = new Subscription (id_str); - sub->_old = true; - - subscriptions.push_back (sub); - } - } - - node = node->next(); - } - - /* If we've imported old subscriptions, we need to write them - out immediately into the new subscriptions file. */ - - subscriptions_changed = true; - save (); -#endif -} - - -void -Subscription::load (void) -{ -#if 1 - return; -#else - xmlDoc *doc; - XmlNode_Ptr node; - - if (access (subscription_file.c_str(), R_OK) != 0) { - load_old_subscriptions (); - return; - } - - doc = xmlParseFile (subscription_file.c_str()); - if (doc == NULL) { - ERR << "Can't parse subscription file '" - << subscription_file << "'" << endl; - return; - } - - node = new XmlNode (xmlDocGetRootElement (doc)); - - if (! node->equals ("subscriptions")) { - ERR << "Subscription file '" - << subscription_file << "' is malformed" << endl; - return; - } - - node = node->children(); - - while (node != NULL) { - - if (node->equals ("channel")) { - string id_str, last_seen_str; - - id_str = node->getProp ("id"); - last_seen_str = node->getProp ("last_seen"); - - if (!id_str.empty()) { - Subscription *sub = new Subscription (id_str); - - if (!last_seen_str.empty()) - sub->_last_seen = (time_t) atol (last_seen_str.c_str()); - else - sub->_last_seen = time (NULL); - - sub->_old = node->getUnsignedIntValueDefault("old", 0); - - subscriptions.push_back (sub); - } - - } - - node = node->next(); - } - - xmlFreeDoc (doc); -#endif -} - -//--------------------------------------------------------------------------- - -bool -Subscription::match (Channel_constPtr channel) -{ - bool match; - - /* Paranoia is the programmer's friend. */ - if (channel == NULL) return false; - if (channel->id().empty()) return false; - - /* If this is an old (i.e. imported from 1.x) subscription, we - compare it against the channel id's tail. */ - - if (_old) { - string id = channel->legacyId (); - int len1, len2; - - if (id.empty()) - return false; - - len1 = strlen (_channel_id.c_str()); - len2 = strlen (id.c_str()); - - if (len1 > len2) - return false; - - /* If the tails match, mutate the Subscription into a - new-style subscription for that channel. */ - if (! strcmp (id.c_str() + (len2 - len1), _channel_id.c_str())) { - _channel_id = channel->id (); - _old = false; - subscriptions_changed = true; - - return true; - } - - return false; - } - - match = (_channel_id == channel->id ()); - - if (match) { - time (&_last_seen); - } - - return match; -} - -//----------------------------------------------------------------------------- - -void -Subscription::setFile (const string & path) -{ - subscription_file = path; -} - - -bool -Subscription::status (Channel_constPtr channel) -{ - if (subscriptions.empty()) - load (); - - if (channel == NULL) - return false; - - for (SubscriptionList::iterator iter = subscriptions.begin(); iter != subscriptions.end(); iter++) { - Subscription *sub = *iter; - if (sub->match (channel)) - return true; - } - - save (); - - return false; -} - - -void -Subscription::setStatus (Channel_constPtr channel, bool subscribe_to_channel) -{ - bool currently_subscribed; - - if (channel == NULL) return; - - currently_subscribed = status (channel); - - if (currently_subscribed && !subscribe_to_channel) { - - /* Unsubscribe to the channel */ - for (SubscriptionList::iterator iter = subscriptions.begin(); iter != subscriptions.end(); iter++) { - Subscription *sub = *iter; - if (sub->match (channel)) { - subscriptions.erase (iter); - subscriptions_changed = true; - break; - } - } - - } else if (!currently_subscribed && subscribe_to_channel) { - - /* Subscribe to the channel */ - Subscription *sub; - sub = new Subscription (channel->id ()); - subscriptions.push_back(sub); - subscriptions_changed = true; - } - - save (); -} - -//--------------------------------------------------------------------------- - -Subscription::Subscription(const string & id) -{ - _channel_id = id; - _last_seen = time (NULL); - _old = false; -} - - -Subscription::~Subscription() -{ -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/Subscription.h b/zypp/solver/temporary/Subscription.h deleted file mode 100644 index e23b0de..0000000 --- a/zypp/solver/temporary/Subscription.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* Subscription.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 ZYPP_SOLVER_TEMPORARY_SUBSCRIPTION_H -#define ZYPP_SOLVER_TEMPORARY_SUBSCRIPTION_H - -#include -#include -#include -#include - -#include "zypp/solver/temporary/ChannelPtr.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : Subscription - - -class Subscription; -typedef std::list SubscriptionList; - -class Subscription { - - private: - - static SubscriptionList subscriptions; - static bool subscriptions_changed; - static std::string subscription_file; - - std::string _channel_id; - time_t _last_seen; - bool _old; // subscription imported from an old-style subs file - - bool match (Channel_constPtr channel); - static void save (void); - static void load (void); - static void load_old_subscriptions (void); - - public: - - Subscription (const std::string & id); - virtual ~Subscription(); - - // ---------------------------------- I/O - - static std::string toString ( const Subscription & section); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const Subscription & section); - - std::string asString ( void ) const; - - // ---------------------------------- accessors - - // ---------------------------------- methods - - void setFile (const std::string & file); - static bool status (Channel_constPtr channel); - static void setStatus (Channel_constPtr channel, bool channel_is_subscribed); - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_SUBSCRIPTION_H diff --git a/zypp/solver/temporary/UndumpWorld.cc b/zypp/solver/temporary/UndumpWorld.cc deleted file mode 100644 index 3bfdd5b..0000000 --- a/zypp/solver/temporary/UndumpWorld.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* UndumpWorld.cc - * - * 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 "zypp/solver/temporary/UndumpWorld.h" -#include "zypp/solver/temporary/extract.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(UndumpWorld); - -//--------------------------------------------------------------------------- - -string -UndumpWorld::asString ( void ) const -{ - return toString (*this); -} - - -string -UndumpWorld::toString ( const UndumpWorld & world ) -{ - return ""; -} - - -ostream & -UndumpWorld::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const UndumpWorld & world) -{ - return os << world.asString(); -} - -//--------------------------------------------------------------------------- - -UndumpWorld::UndumpWorld (const std::string & filename) - : StoreWorld (UNDUMP_WORLD) -{ - load (filename); -} - - -UndumpWorld::~UndumpWorld() -{ - ERR << "*** deleting undump world[" << this << "]: " << World::toString(type()) << endl; -} - -//--------------------------------------------------------------------------- - - -static bool -add_channel_cb (Channel_Ptr channel, bool subscribed, void *data) -{ - UndumpWorld *undump = (UndumpWorld *)data; - - undump->addChannel (channel); - - if (!channel->system ()) { - undump->setSubscription (channel, subscribed); - } - - return true; -} - - -static bool -add_resItem_cb (ResItem_constPtr res, void *data) -{ - UndumpWorld *undump = (UndumpWorld *)data; - - undump->addResItem (res); - - return true; -} - - -static bool -add_lock_cb (Match_constPtr lock, void *data) -{ - UndumpWorld *undump = (UndumpWorld *)data; - - undump->addLock (lock); - - return true; -} - - -void -UndumpWorld::load (const string & filename) -{ - if (!filename.empty()) { - extract_packages_from_undump_file (filename, add_channel_cb, add_resItem_cb, add_lock_cb, (void *)this); - } -} - - -void -UndumpWorld::setSubscription (Channel_constPtr channel, bool subscribe) -{ - _XXX("RC_SPEW") << "UndumpWorld::setSubscription (" << channel->asString() << " , " << (subscribe?"subscribe":"unsubscribe") - << ")" << endl; - for (ChannelSubscriptions::iterator i = _subscriptions.begin(); i != _subscriptions.end(); i++) { - if (*i == channel) { - if (!subscribe) { - _subscriptions.erase (i); - } - return; - } - } - - if (subscribe) { - _subscriptions.push_back (channel); - } - - return; -} - - -bool -UndumpWorld::isSubscribed (Channel_constPtr channel) const -{ - for (ChannelSubscriptions::const_iterator i = _subscriptions.begin(); i != _subscriptions.end(); i++) { - if (*i == channel) { - _DBG("RC_SPEW") << "UndumpWorld::isSubscribed (" << channel->asString() <<") YES" << endl; - return true; - } - } - - _DBG("RC_SPEW") << "UndumpWorld::isSubscribed (" << channel->asString() << ") NO" << endl; - return false; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/UndumpWorld.h b/zypp/solver/temporary/UndumpWorld.h deleted file mode 100644 index 827d447..0000000 --- a/zypp/solver/temporary/UndumpWorld.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* UndumpWorld.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 ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_H -#define ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_H - -#include -#include - -#include "zypp/solver/temporary/UndumpWorldPtr.h" -#include "zypp/solver/temporary/StoreWorld.h" -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/World.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : UndumpWorld - -class UndumpWorld : public StoreWorld { - - - private: - - typedef std::list ChannelSubscriptions; - ChannelSubscriptions _subscriptions; - - public: - - UndumpWorld (const std::string & filename); - virtual ~UndumpWorld(); - - // ---------------------------------- I/O - - static std::string toString (const UndumpWorld & section); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const UndumpWorld & section); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - // ---------------------------------- methods - - void load (const std::string & filename); - virtual bool isSubscribed (Channel_constPtr channel) const; - virtual void setSubscription (Channel_constPtr channel, bool is_subscribed); - -}; -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_H diff --git a/zypp/solver/temporary/UndumpWorldPtr.h b/zypp/solver/temporary/UndumpWorldPtr.h deleted file mode 100644 index 02b38fc..0000000 --- a/zypp/solver/temporary/UndumpWorldPtr.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* UndumpWorld_Ptr.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 ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_PTR_H -#define ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_PTR_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/solver/temporary/WorldPtr.h" - - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : UndumpWorld_Ptr - // CLASS NAME : UndumpWorld_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(UndumpWorld); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif // ZYPP_SOLVER_TEMPORARY_UNDUMPWORLD_PTR_H diff --git a/zypp/solver/temporary/World.cc b/zypp/solver/temporary/World.cc deleted file mode 100644 index 811bd53..0000000 --- a/zypp/solver/temporary/World.cc +++ /dev/null @@ -1,578 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* World.cc - * - * 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 - -#include "zypp/solver/temporary/MultiWorld.h" -#include "zypp/solver/temporary/Subscription.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(World); - -World_Ptr World::GlobalWorld = NULL; - -void World::setGlobalWorld( MultiWorld_Ptr world ) -{ - GlobalWorld = world; -} - -MultiWorld_Ptr World::globalWorld() -{ - return dynamic_pointer_cast(GlobalWorld); -} - -//--------------------------------------------------------------------------- - -string -World::toString (WorldType type) -{ - switch (type) { - case PLAIN_WORLD: return "plain"; - case STORE_WORLD: return "store"; - case MULTI_WORLD: return "multi"; - case SERVICE_WORLD: return "service"; - case UNDUMP_WORLD: return "undump"; - case LOCALDIR_WORLD: return "localdir"; - case SYSTEM_WORLD: return "system"; - default: - break; - } - return "???"; -} - - -string -World::asString ( void ) const -{ - return toString (*this); -} - - -string -World::toString ( const World & world ) -{ - return ""; -} - - -ostream & -World::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const World & world) -{ - return os << world.asString(); -} - -//--------------------------------------------------------------------------- - -World::World (WorldType type) - : _type (type) -{ -// ERR << "*** creating world[" << this << "]: " << toString(_type) << endl; -} - - -World::~World() -{ -// ERR "*** deleting world[" << this << "]: " << toString(_type) << endl; -} - -//--------------------------------------------------------------------------- -// sync/refresh functions - -bool -World::sync (void) const -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::sync() not implemented" << endl; - return false; -} - -bool -World::syncConditional (Channel_constPtr channel) const -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::syncConditional() not implemented" << endl; - return false; -} - - -Pending_Ptr -World::refresh (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::refresh() not implemented" << endl; - return 0; -} - -bool -World::hasRefresh (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::hasRefresh() not implemented" << endl; - return false; -} - - -bool -World::isRefreshing (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::isRefreshing() not implemented" << endl; - return false; -} - - - /* These functions are for World-implementers only! Don't call them! */ -void -World::refreshBegin (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::refreshBegin() not implemented" << endl; - return; -} - -void -World::refreshComplete (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::refreshComplete() not implemented" << endl; - return; -} - -//--------------------------------------------------------------------------- -// channels, subscriptions - -void -World::setSubscription (Channel_Ptr channel, bool is_subscribed) -{ - bool curr_subs_status; - - if (channel == NULL) return; - - _XXX("RC_SPEW") << "World::setSubscription (" << channel->asString() << ", " << - (is_subscribed?"subscribe":"unsubscribe") << ")" << endl; - - if (channel->system ()) { - ERR << "Can't subscribe to system channel '" << channel->name () << "'" << endl; - return; - } - - curr_subs_status = isSubscribed (channel); - - Subscription::setStatus (channel, is_subscribed); - - if (curr_subs_status != isSubscribed (channel)) - touchSubscriptionSequenceNumber (); - - return; -} - - -bool -World::isSubscribed (Channel_constPtr channel) const -{ - if (channel == NULL) return false; - _XXX("RC_SPEW") << "World::isSubscribed (" << channel->asString() << ")" << endl; - - if (channel->system ()) - return false; - - return Subscription::status (channel) ? true : false; -} - - - -//--------------------------------------------------------------------------- -// ResItem Locks - -typedef struct { - ResItem_constPtr resItem; - World_Ptr world; - bool is_locked; -} IsLockedInfo; - - -static bool -is_locked_cb (Match_constPtr match, void *data) -{ - IsLockedInfo *info = (IsLockedInfo *)data; - - if (match->test (info->resItem, info->world) == CapMatch::yes) { - info->is_locked = true; - return false; - } - - return true; -} - - -bool -World::resItemIsLocked (ResItem_constPtr resItem) -{ - IsLockedInfo info; - - info.resItem = resItem; - info.world = this; - info.is_locked = false; - - foreachLock (is_locked_cb, &info); - - return info.is_locked; -} - - -//--------------------------------------------------------------------------- -// Transacting - -bool -World::canTransactResItem (ResItem_constPtr resItem) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::canTransactResItem() not implemented" << endl; - return false; -} - -bool -World::transact (const ResItemList & installResItems, const ResItemList & remove_resItems, int flags) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::transact() not implemented" << endl; - return false; -} - - -//--------------------------------------------------------------------------- -// XML serialization - -void -World::serialize (XmlNode_Ptr parent) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::serialize() not implemented" << endl; - return; -} - -void -World::toFile (const std::string & filename) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::toFile() not implemented" << endl; - return; -} - - -//--------------------------------------------------------------------------- -// Duplicating (primarily for atomic refreshes) - -World_Ptr -World::dup (void) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::dup() not implemented" << endl; - return 0; -} - - -//--------------------------------------------------------------------------- -// only used for bindings - -void -World::setRefreshFunction (WorldRefreshFn refresh_fn) -{ - if (getenv("FIXME")) _ERR("FIXME") << "World::setRefreshFunction() not implemented" << endl; - return; -} - - - -//----------------------------------------------------------------------------- -// Upgrades - -typedef struct { - ResItem_constPtr original_resItem; - CResItemFn fn; - void *data; - int count; - World_Ptr world; -} ForeachUpgradeInfo; - -static bool -foreach_upgrade_cb (ResItem_constPtr resItem, void *data) -{ - ForeachUpgradeInfo *info = (ForeachUpgradeInfo *)data; - int cmp; - - cmp = ResItem::compare (info->original_resItem, resItem); - - if (cmp >= 0) // original is already better - return true; - - if (info->world->resItemIsLocked (resItem)) - return true; - - if (info->fn) - info->fn (resItem, info->data); - ++info->count; - - return true; -} - - -// rc_world_foreach_upgrade: -// @world: An #RCWorld. -// @resItem: An #RCResItem. -// @channel: An #RCChannel or channel wildcard. -// @fn: A callback function. -// @user_data: Pointer passed to the callback function. -// -// Searchs @world for all resItems whose channel matches -// @channel and that are an upgrade for @resItem. -// (To be precise, an upgrade is a resItem with the same -// name as @resItem but with a greater version number.) -// -// Return value: The number of matching resItems -// that the callback functions was invoked on, or -// -1 in the case of an error. - -int -World::foreachUpgrade (ResItem_constPtr resItem, Channel_Ptr channel, CResItemFn fn, void *data) -{ - ForeachUpgradeInfo info; - - syncConditional (channel); - - info.original_resItem = resItem; - info.fn = fn; - info.data = data; - info.count = 0; - info.world = this; - - foreachResItemByName (resItem->name(), channel, foreach_upgrade_cb, (void *)&info); - - return info.count; -} - - - -typedef struct { - World_Ptr world; - ResItem_constPtr system_resItem; - CResItemList best_upgrades; - bool subscribed_only; - ResItemPairFn fn; - void *data; - int count; -} SystemUpgradeInfo; - - -static bool -foreach_system_upgrade_cb (ResItem_constPtr upgrade, void *data) -{ - SystemUpgradeInfo *info = (SystemUpgradeInfo *)data; - Channel_constPtr channel = upgrade->channel(); - int cmp; - - if (info->subscribed_only) { - if (!(channel && channel->isSubscribed ())) - return true; - } - - if (info->world->resItemIsLocked (upgrade)) - return true; - - if (info->best_upgrades.empty()) { - info->best_upgrades.push_back (upgrade); - } - else { - /* All the versions are equal, so picking the first is fine */ - ResItem_constPtr best_up = info->best_upgrades.front(); - - cmp = ResItem::compare (best_up, upgrade); - - if (cmp <= 0) { - /* We have a new best resItem... */ - info->best_upgrades.pop_front(); - info->best_upgrades.push_back (upgrade); - } - } - - return true; -} - - -static void -foreach_system_resItem_cb (const string & name, ResItem_constPtr resItem, SystemUpgradeInfo *info) -{ - info->system_resItem = resItem; - info->best_upgrades.clear(); - - /* If the resItem is excluded, skip it. */ - if (info->world->resItemIsLocked (info->system_resItem)) - return; - - info->world->foreachUpgrade (info->system_resItem, new Channel (CHANNEL_TYPE_NONSYSTEM), foreach_system_upgrade_cb, info); - - for (CResItemList::const_iterator iter = info->best_upgrades.begin(); iter != info->best_upgrades.end(); iter++) { - ResItem_constPtr upgrade = *iter; - - if (info->fn) - info->fn (info->system_resItem, upgrade, info->data); - - ++info->count; - } - - info->best_upgrades.clear(); -} - -typedef map UniqueTable; - -static bool -build_unique_table_cb (ResItem_constPtr resItem, void *data) -{ - UniqueTable *unique_table = (UniqueTable *)data; - - UniqueTable::const_iterator pos = unique_table->find (resItem->name()); - - if (pos != unique_table->end()) { - if (ResItem::compare (resItem, pos->second) <= 0) - return true; - } - - (*unique_table)[resItem->name()] = resItem; - - return true; -} - - -/** - * foreachSystemUpgrade: - * @world: An #RCWorld. - * @subscribed_only: if TRUE, only subscribed channels are used. - * @fn: A callback function. - * @user_data: Pointer to be passed to the callback function. - * - * Iterates across all system resItems in @world for which there - * exists an upgrade, and passes both the original resItem and - * the upgrade resItem to the callback function. - * - * Return value: The number of matching resItems that the callback - * function was invoked on, or -1 in case of an error. - **/ - -int -World::foreachSystemUpgrade (bool subscribed_only, ResItemPairFn fn, void *data) -{ - SystemUpgradeInfo info; - UniqueTable unique_table; - - /* rc_world_foreach_resItem calls rc_world_sync */ - - foreachResItem (new Channel (CHANNEL_TYPE_SYSTEM), build_unique_table_cb, &unique_table); - - info.world = this; - info.subscribed_only = subscribed_only; - info.fn = fn; - info.data = data; - info.count = 0; - - for (UniqueTable::const_iterator iter = unique_table.begin(); iter != unique_table.end(); iter++) { - foreach_system_resItem_cb (iter->first, iter->second, &info); - } - - return info.count; -} - - -PackageUpdateList -World::getUpgrades (ResItem_constPtr resItem, Channel_constPtr channel) -{ - ERR << "World::getUpgrades not implemented" << endl; - return PackageUpdateList(); -} - -ResItem_constPtr -World::getBestUpgrade (ResItem_constPtr resItem, bool subscribed_only) -{ - ERR << "World::getBestUpgrade not implemented" << endl; - return 0; -} - - -//----------------------------------------------------------------------------- -// Locks - -int -World::foreachLock (MatchFn fn, void *data) const -{ - int count = 0; - - for (MatchList::const_iterator iter = _locks.begin(); iter != _locks.end(); iter++) { - if (! fn (*iter, data)) - return -1; - ++count; - } - - return count; -} - - -void -World::addLock (Match_constPtr lock) -{ - _locks.push_back (lock); -} - - -void -World::removeLock (Match_constPtr lock) -{ - for (MatchList::iterator iter = _locks.begin(); iter != _locks.end(); iter++) { - if (*iter == lock) { - _locks.erase (iter); - break; - } - } -} - - -void -World::clearLocks (void) -{ - _locks.clear(); -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/World.h b/zypp/solver/temporary/World.h deleted file mode 100644 index d8f6880..0000000 --- a/zypp/solver/temporary/World.h +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* World.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 ZYPP_SOLVER_TEMPORARY_WORLD_H -#define ZYPP_SOLVER_TEMPORARY_WORLD_H - -#include -#include -#include - -#include "zypp/Capability.h" - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/detail/Pending.h" - -#include "zypp/solver/temporary/WorldPtr.h" -#include "zypp/solver/temporary/MultiWorldPtr.h" -#include "zypp/solver/temporary/ResItem.h" -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/Match.h" -#include "zypp/solver/temporary/Package.h" -#include "zypp/solver/temporary/PackageUpdate.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef std::list WorldList; -typedef std::list CWorldList; - -class NameConflictInfo; - -////////////////////////////////////////////////////////////////// - -typedef enum { - PLAIN_WORLD = 0, - STORE_WORLD, - MULTI_WORLD, - SERVICE_WORLD, - UNDUMP_WORLD, - LOCALDIR_WORLD, - SYSTEM_WORLD -} WorldType; - -typedef bool (*CWorldFn) (World_constPtr world, void *user_data); -typedef bool (*WorldFn) (World_Ptr world, void *user_data); -typedef Pending_Ptr (*WorldRefreshFn) (World_constPtr world); - -#if 0 -typedef bool (*WorldSyncFn) (World_constPtr world, Channel_constPtr channel); -typedef void (*WorldSpewFn) (World_constPtr world, FILE *out); -typedef World_constPtr (*WorldDupFn) (World_constPtr world); - -typedef bool (*WorldCanTransactResItemFn) (World_constPtr world, ResItem_constPtr resItem); -typedef bool (*WorldTransactFn) (World_constPtr world, const ResItemList & install_resItems, const ResItemList & remove_resItems, int flags); - -typedef bool (*WorldGetSubscribedFn) (const World *world, Channel_constPtr channel); -typedef void (*WorldSetSubscribedFn) (World *world, Channel_Ptr channel, bool subs_status); - -typedef int (*WorldForeachChannelFn) (const World *world, ChannelFn callback, void *user_data); -typedef int (*WorldForeachLockFn) (World_constPtr world, MatchFn callback, void *user_data); - -typedef void (*WorldAddLockFn) (World_constPtr world, Match_constPtr lock); -typedef void (*WorldRemoveLockFn) (World_constPtr world, Match_constPtr lock); -typedef void (*WorldClearLockFn) (World_constPtr world); - -typedef int (*WorldForeachResItemFn) (World_constPtr world, const char *name, Channel_constPtr channel, ResItemFn callback, void *user_data); -typedef int (*WorldForeachPackageDepFn) (World_constPtr world, const Capability & dep, ResItemAndDepFn callback, void *user_data); - -typedef void (*WorldSerializeFn) (World_constPtr world, XmlNode_constPtr root); -typedef void (*WorldUnserializeFn) (World_constPtr world, XmlNode_constPtr node); - -#endif - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : World - -class World : public base::ReferenceCounted, private base::NonCopyable { - - - private: - static World_Ptr GlobalWorld; - - WorldType _type; - - /* The sequence numbers gets incremented every - time the RCWorld is changed. */ - - unsigned int _seq_no_resItems; - unsigned int _seq_no_channels; - unsigned int _seq_no_subscriptions; - unsigned int _seq_no_locks; - - /* Every world needs to be able to store locks, so we provide a - place for that. Of course, derived classes are allowed to - provide their own exotic lock semantics by providing their - own *_lock_fn methods. */ - MatchList _lock_store; - - bool _refresh_pending; - - /* a bad hack to keep us from emitting signals while finalizing */ - bool _no_changed_signals; - - /* For unserialized worlds currently. If a world is read only, - you can not refresh or transact on it. */ - bool _read_only; - - MatchList _locks; - - public: - - World (WorldType type = PLAIN_WORLD); - virtual ~World(); - - // ---------------------------------- I/O - - static std::string toString (const World & section); - - static std::string toString (WorldType type); - - virtual std::ostream & dumpOn(std::ostream & str ) const; - - friend std::ostream& operator<<(std::ostream&, const World & section); - - std::string asString (void ) const; - - // ---------------------------------- accessors - - WorldType type() const { return _type; } - bool isPlainWorld () const { return _type == PLAIN_WORLD; } - bool isUndumpWorld () const { return _type == UNDUMP_WORLD; } - bool isMultiWorld () const { return _type == MULTI_WORLD; } - bool isServiceWorld () const { return _type == SERVICE_WORLD; } - - unsigned int resItemSequenceNumber (void) const { return _seq_no_resItems; } - unsigned int channelSequenceNumber (void) const { return _seq_no_channels; } - unsigned int subscriptionSequenceNumber (void) const { return _seq_no_subscriptions; } - unsigned int lockSequenceNumber (void) const { return _seq_no_locks; } - - void touchResItemSequenceNumber (void) { _seq_no_resItems++; } - void touchChannelSequenceNumber (void) { _seq_no_channels++; } - void touchSubscriptionSequenceNumber (void) { _seq_no_subscriptions++; } - void touchLockSequenceNumber (void) { _seq_no_locks++; } - - MatchList locks (void) const { return _lock_store; } - - // ---------------------------------- methods - - static void setGlobalWorld (MultiWorld_Ptr world); - static MultiWorld_Ptr globalWorld (void); - - bool sync (void) const; - virtual bool syncConditional (Channel_constPtr channel) const; - Pending_Ptr refresh (void); - bool hasRefresh (void); - bool isRefreshing (void); - - /* These functions are for World-implementers only! Don't call them! */ - void refreshBegin (void); - void refreshComplete (void); - - virtual int foreachChannel (ChannelFn fn, void *user_data) const = 0; - - virtual void setSubscription (Channel_Ptr channel, bool is_subscribed); - virtual bool isSubscribed (Channel_constPtr channel) const; - - virtual ChannelList channels () const = 0; - virtual bool containsChannel (Channel_constPtr channel) const = 0; - - virtual Channel_Ptr getChannelByName (const std::string & channel_name) const = 0; - virtual Channel_Ptr getChannelByAlias (const std::string & alias) const = 0; - virtual Channel_Ptr getChannelById (const std::string & channel_id) const = 0; - - // ResItem Locks - - virtual int foreachLock (MatchFn fn, void *data) const; - - void addLock (Match_constPtr lock); - void removeLock (Match_constPtr lock); - void clearLocks (); - - bool resItemIsLocked (ResItem_constPtr resItem); - - // Single resItem queries - - virtual ResItem_constPtr findInstalledResItem (ResItem_constPtr resItem) = 0; - virtual ResItem_constPtr findResItem (Channel_constPtr channel, const std::string & name, const Resolvable::Kind & kind = ResTraits::kind) const = 0; - virtual ResItem_constPtr findResItemWithConstraint (Channel_constPtr channel, const std::string & name, const Capability & constraint, bool is_and) const = 0; - virtual Channel_Ptr guessResItemChannel (ResItem_constPtr resItem) const = 0; - - // Iterate across resItems - - virtual int foreachResItem (Channel_Ptr channel, CResItemFn fn, void *data) = 0; - virtual int foreachResItemByName (const std::string & name, Channel_Ptr channel, CResItemFn fn, void *user_data) = 0; - virtual int foreachResItemByKind (const Resolvable::Kind & kind, CResItemFn fn, void *user_data) = 0; - virtual int foreachResItemByMatch (Match_constPtr match, CResItemFn fn, void *user_data) = 0; - - // Iterate across provides or requirement - - virtual int foreachProvidingResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data) = 0; - virtual int foreachRequiringResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data) = 0; - virtual int foreachConflictingResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data) = 0; - virtual int foreachFresheningResItem (const Capability & cap, ResItemAndDepFn fn, void *user_data) = 0; - - // upgrades - - int foreachUpgrade (ResItem_constPtr resItem, Channel_Ptr channel, CResItemFn fn, void *data); - PackageUpdateList getUpgrades (ResItem_constPtr resItem, Channel_constPtr channel); - ResItem_constPtr getBestUpgrade (ResItem_constPtr resItem, bool subscribed_only); - int foreachSystemUpgrade (bool subscribed_only, ResItemPairFn fn, void *data); - - // provider - - bool getSingleProvider (const Capability & dep, Channel_constPtr channel, ResItem_constPtr *resItem); - - // Transacting - - bool canTransactResItem (ResItem_constPtr resItem); - bool transact (const ResItemList & installResItems, const ResItemList & remove_resItems, int flags); - - // XML serialization - - void serialize (XmlNode_Ptr parent); - void toFile (const std::string & filename); - - // Duplicating (primarily for atomic refreshes) - World_Ptr dup (void); - - // only used for bindings - void setRefreshFunction (WorldRefreshFn refresh_fn); - -}; - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_WORLD_H diff --git a/zypp/solver/temporary/WorldPtr.h b/zypp/solver/temporary/WorldPtr.h deleted file mode 100644 index 305fa54..0000000 --- a/zypp/solver/temporary/WorldPtr.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* World_Ptr.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 ZYPP_SOLVER_TEMPORARY_WORLD_PTR_H -#define ZYPP_SOLVER_TEMPORARY_WORLD_PTR_H - -#include "zypp/base/PtrTypes.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// CLASS NAME : World_Ptr -// CLASS NAME : World_constPtr -/////////////////////////////////////////////////////////////////// -DEFINE_PTR_TYPE(World); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_WORLD_PTR_H diff --git a/zypp/solver/temporary/XmlNode.cc b/zypp/solver/temporary/XmlNode.cc deleted file mode 100644 index d4a8c4c..0000000 --- a/zypp/solver/temporary/XmlNode.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* XmlNode.cc wrapper for xmlNodePtr from libxml2 - * - * 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 "zypp/solver/temporary/XmlNode.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -IMPL_PTR_TYPE(XmlNode); - -//--------------------------------------------------------------------------- - -XmlNode::XmlNode (const xmlNodePtr node) - : _node(node) -{ -} - -XmlNode::XmlNode (const string & name) - : _node(xmlNewNode (NULL, (const xmlChar *)name.c_str())) -{ -} - -XmlNode::~XmlNode () -{ -} - -//--------------------------------------------------------------------------- - -string -XmlNode::asString ( void ) const -{ - return toString (*this); -} - - -string -XmlNode::toString ( const XmlNode & node ) -{ - return ""; -} - - -ostream & -XmlNode::dumpOn( ostream & str ) const -{ - str << asString(); - return str; -} - - -ostream& -operator<<( ostream& os, const XmlNode& node) -{ - return os << node.asString(); -} - -//--------------------------------------------------------------------------- - -string -XmlNode::getValue (const string & name, const string & deflt) const -{ - string ret; - xmlChar *xml_s; - xmlNode *child; - - xml_s = xmlGetProp(_node, (const xmlChar *)name.c_str()); -// _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") xmlGetProp '" << (char *)xml_s << "'" << endl; - - if (xml_s) { - ret = string ((const char *)xml_s); - xmlFree (xml_s); - return ret; - } - - child = _node->xmlChildrenNode; - - while (child) { - _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") child '" << (child->name) << "'" << endl; - if (strcasecmp((const char *)(child->name), name.c_str()) == 0) { - xml_s = xmlNodeGetContent(child); - _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") xmlNodeGetContent '" << (char *)xml_s << "'" << endl; - if (xml_s) { - ret = string ((const char *)xml_s); - xmlFree (xml_s); - return ret; - } - } - child = child->next; - } - - _XXX("RC_SPEW_XML") << "XmlNode::getValue(" << name << ") deflt" << endl; - return deflt; -} - - -bool -XmlNode::hasProp (const std::string & name) const -{ - xmlChar *ret; - - ret = xmlGetProp (_node, (const xmlChar *)name.c_str()); - if (ret) { - return true; - } - return false; -} - - -string -XmlNode::getProp (const std::string & name, const std::string & deflt) const -{ - xmlChar *ret; - string gs; - - ret = xmlGetProp (_node, (const xmlChar *)name.c_str()); - - if (ret) { - _XXX("RC_SPEW_XML") << "XmlNode::getProp(" << name << ") xmlGetProp '" << (char *)ret << "'" << endl; - - gs = string ((const char *)ret); - xmlFree (ret); - return gs; - } - return deflt; -} - - -bool -XmlNode::getIntValue (const std::string & name, int *value) const -{ - string strval; - char *ret; - long z; - - strval = this->getValue (name); - if (strval.empty()) { - return false; - } - - z = strtol (strval.c_str(), &ret, 10); - if (*ret != '\0') { - return false; - } - - *value = z; - return true; -} - - -int -XmlNode::getIntValueDefault (const std::string & name, int def) const -{ - int z; - if (this->getIntValue (name, &z)) - return z; - else - return def; -} - - -unsigned int -XmlNode::getUnsignedIntValueDefault (const std::string & name, unsigned int def) const -{ - unsigned int z; - if (this->getUnsignedIntValue (name, &z)) - return z; - else - return def; -} - - -bool -XmlNode::getUnsignedIntValue (const std::string & name, unsigned int *value) const -{ - string strval; - char *ret; - int z; - - strval = this->getValue (name); - if (strval.empty()) { - return false; - } - - z = strtoul (strval.c_str(), &ret, 10); - if (*ret != '\0') { - return false; - } - - *value = z; - return true; -} - - -unsigned int -XmlNode::getUnsignedIntPropDefault (const std::string & name, unsigned int def) const -{ - xmlChar *buf; - unsigned int ret; - - buf = xmlGetProp (_node, (const xmlChar *)name.c_str()); - - if (buf) { - ret = strtol ((const char *)buf, NULL, 10); - xmlFree (buf); - return (ret); - } - return (def); -} - - -string -XmlNode::getContent (void) const -{ - xmlChar *buf; - string ret; - - buf = xmlNodeGetContent (_node); - - ret = string ((const char *)buf); - - xmlFree (buf); - - return (ret); -} - - -unsigned int -XmlNode::getUnsignedIntContentDefault (unsigned int def) const -{ - xmlChar *buf; - unsigned int ret; - - buf = xmlNodeGetContent (_node); - - if (buf) { - ret = strtol ((const char *)buf, NULL, 10); - xmlFree (buf); - return (ret); - } - return (def); -} - - -const XmlNode_Ptr -XmlNode::getNode (const std::string & name) const -{ - xmlNodePtr iter; - - for (iter = _node->xmlChildrenNode; iter; iter = iter->next) { - if (strcasecmp ((const char *)(iter->name), name.c_str()) == 0) { - return new XmlNode (iter); - } - } - - return NULL; -} - - -//--------------------------------------------------------------------------- - - -void -XmlNode::addTextChild (const std::string & name, const std::string & content) -{ - xmlNewTextChild (_node, NULL, (const xmlChar *)name.c_str(), (const xmlChar *)content.c_str()); -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - diff --git a/zypp/solver/temporary/XmlNode.h b/zypp/solver/temporary/XmlNode.h deleted file mode 100644 index baa912b..0000000 --- a/zypp/solver/temporary/XmlNode.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* XmlNode.h wrapper for xmlNode* from libxml2 - * - * Copyright (C) 2000-2003 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 ZYPP_SOLVER_TEMPORARY_XMLNODE_H -#define ZYPP_SOLVER_TEMPORARY_XMLNODE_H - -#include -#include -#include -#include -#include -#include - -#include "zypp/base/ReferenceCounted.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/PtrTypes.h" - -#include "zypp/solver/temporary/XmlNodePtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////// -// -// CLASS NAME : XmlNode - -class XmlNode : public base::ReferenceCounted, private base::NonCopyable -{ - - private: - const xmlNodePtr _node; - - public: - XmlNode (const xmlNodePtr node); - XmlNode (const std::string & name); - virtual ~XmlNode (); - - // ---------------------------------- I/O - - static std::string toString ( const XmlNode & node ); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream&, const XmlNode & ); - - std::string asString ( void ) const; - - // ---------------------------------- accessors - - const std::string name() const { return (std::string((const char *)_node->name)); } - xmlNodePtr node() const { return (_node); } - XmlNode_Ptr next() const { return (_node->next == NULL ? NULL : new XmlNode (_node->next)); } - XmlNode_Ptr children() const { return (_node->xmlChildrenNode == NULL ? NULL : new XmlNode (_node->xmlChildrenNode)); } - xmlElementType type() const { return (_node->type); } - - // ---------------------------------- methods - - bool hasProp (const std::string & name) const; - std::string getProp (const std::string & name, const std::string & deflt = "") const; - std::string getValue (const std::string & name, const std::string & deflt = "") const; - std::string getContent (void) const; - - bool equals (const std::string & n) const { return (strcasecmp (name().c_str(), n.c_str()) == 0); } - bool isElement (void) const { return (type() == XML_ELEMENT_NODE); } - - const XmlNode_Ptr getNode (const std::string & name) const; - - // The former will get either a property or a tag, whereas the latter will - // get only a property - - bool getIntValue (const std::string & name, int *value) const; - int getIntValueDefault (const std::string & name, int def) const; - - bool getUnsignedIntValue (const std::string & name, unsigned int *value) const; - unsigned int getUnsignedIntValueDefault (const std::string & name, unsigned int def) const; - - unsigned int getUnsignedIntPropDefault (const std::string & name, unsigned int def) const; - - unsigned int getUnsignedIntContentDefault (unsigned int def) const; - - void addTextChild (const std::string & name, const std::string & content); -}; - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - - -#endif // ZYPP_SOLVER_TEMPORARY_XMLNODE_H diff --git a/zypp/solver/temporary/XmlNodePtr.h b/zypp/solver/temporary/XmlNodePtr.h deleted file mode 100644 index 34504c6..0000000 --- a/zypp/solver/temporary/XmlNodePtr.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* XmlNode_Ptr.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 ZYPP_SOLVER_TEMPORARY_XMLNODE_PTR_H -#define ZYPP_SOLVER_TEMPORARY_XMLNODE_PTR_H - -#include "zypp/base/PtrTypes.h" - -/////////////////////////////////////////////////////////////////// -namespace zypp -{ ////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////// - namespace solver - { /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - - /////////////////////////////////////////////////////////////////// - // CLASS NAME : XmlNode_Ptr - // CLASS NAME : XmlNode_constPtr - /////////////////////////////////////////////////////////////////// - DEFINE_PTR_TYPE(XmlNode); - - /////////////////////////////////////////////////////////////////// - };// namespace detail - /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////// -};// namespace zypp -/////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_XMLNODE_PTR_H diff --git a/zypp/solver/temporary/XmlParser.cc b/zypp/solver/temporary/XmlParser.cc deleted file mode 100644 index 7de551f..0000000 --- a/zypp/solver/temporary/XmlParser.cc +++ /dev/null @@ -1,944 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* XmlParser.cc wrapper for XML I/O - * - * 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. - */ -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include "zypp/solver/temporary/XmlParser.h" -#include "zypp/solver/temporary/PackageUpdate.h" -#include "zypp/solver/temporary/utils.h" -#include "zypp/ResObject.h" -#include "zypp/CapFactory.h" -#include "zypp/CapSet.h" -#include "zypp/Dependencies.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -//--------------------------------------------------------------------------- - -static Resolvable::Kind -string2kind (const std::string & str) -{ - Resolvable::Kind kind = ResTraits::kind; - if (!str.empty()) { - if (str == "package") { - // empty - } - else if (str == "patch") { - kind = ResTraits::kind; - } - else if (str == "pattern") { - kind = ResTraits::kind; - } - else if (str == "script") { - kind = ResTraits::kind; - } - else if (str == "message") { - kind = ResTraits::kind; - } - else if (str == "product") { - kind = ResTraits::kind; - } - else { - ERR << "get_resItem unknown kind '" << str << "'" << endl; - } - } - return kind; -} - - -//--------------------------------------------------------------------------- - -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 */ - Resolvable::Kind kind = ResTraits::kind; - 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, "kind")) kind = string2kind (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 { - _DBG("RC_SPEW_XML") << "! Unknown attribute: " << attr << " = " << value << endl; - } - - } - - /* FIXME: should get Channel from XML */ - return factory.parse ( kind, name, relation, Edition (version, release, epoch)); -} - - -//--------------------------------------------------------------------------- -// SAX callbacks - -static void -sax_start_document(void *ptr) -{ - XmlParser *ctx = (XmlParser *)ptr; - if (ctx->processing()) return; - -// _XXX("RC_SPEW_XML") << "* Start document" << endl; - - ctx->setProcessing (true); -} - - -static void -sax_end_document(void *ptr) -{ - XmlParser *ctx = (XmlParser *)ptr; - if (!ctx->processing()) return; - -// _XXX("RC_SPEW_XML") << "* End document" << endl; - - ctx->setProcessing (false); -} - - -static void -sax_start_element(void *ptr, const xmlChar *name, const xmlChar **attrs) -{ - XmlParser *ctx = (XmlParser *)ptr; - - ctx->releaseBuffer(); - -#if 0 - _XXX("RC_SPEW_XML") << "* Start element (" << (const char *)name << ")"; - - if (attrs) { - for (int i = 0; attrs[i]; i += 2) { - _DBG("RC_SPEW_XML") << " - Attribute (" << (const char *)attrs[i] << "=" << (const char *)attrs[i+1] << ")" << endl; - } - } -#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; - -// _XXX("RC_SPEW_XML") << "* End element (" << (const char *)name << ")" << endl; - - 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) ERR << "vsnprintf overflow" << endl; - WAR << "* SAX Warning: " << tmp << endl; - - 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) ERR << "vsnprintf overflow" << endl;; - ERR << "* SAX Error: " << tmp <"; -} - - -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; - -// _XXX("RC_SPEW_XML") << "XmlParser[" << this << "]::toBuffer(" << data << "...," << (long)size << ")" << endl; -} - - -void -XmlParser::releaseBuffer () -{ - if (_text_buffer) - free (_text_buffer); - _text_buffer = NULL; - _text_buffer_size = 0; -// _XXX("RC_SPEW_XML") << "XmlParser[" << this << "]::releaseBuffer()" << endl; -} - - -void -XmlParser::parseChunk(const char *xmlbuf, size_t size) -{ -// _DBG("RC_SPEW_XML") << "XmlParser::parseChunk(" << xmlbuf << "...," << (long)size << ")" << endl; - - xmlSubstituteEntitiesDefault(true); - - if (!_xml_context) { - _xml_context = xmlCreatePushParserCtxt(&sax_handler, this, NULL, 0, NULL); - } - - xmlParseChunk(_xml_context, xmlbuf, size, 0); -} - - -PackageList -XmlParser::done() -{ -// _XXX("RC_SPEW_XML") << "XmlParser::done()" << endl; - - if (_processing) - xmlParseChunk(_xml_context, NULL, 0, 1); - - if (_xml_context) - xmlFreeParserCtxt(_xml_context); - - if (!_current_resitem_stored) { - ERR << "Incomplete package lost" << endl; - } - - if (_current_update) { - ERR << "Incomplete update lost" << endl; - } - - return _all_packages; -} - - -//--------------------------------------------------------------------------- -// Parser state callbacks - -void -XmlParser::startElement(const char *name, const xmlChar **attrs) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::startElement(" << name << ")" << endl; - - switch (_state) { - case PARSER_TOPLEVEL: - toplevelStart (name, attrs); - break; - case PARSER_RESOLVABLE: - resolvableStart (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) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::endElement(" << name << ")" << endl; - - if (name != NULL) { // sax_end_element might set name to NULL - switch (_state) { - case PARSER_RESOLVABLE: - resolvableEnd (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 std::string & name, const xmlChar **attrs) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::toplevelStart(" << name << ")" << endl; - - if ((name == "package") - || (name == "pattern") - || (name == "script") - || (name == "message") - || (name == "patch") - || (name == "product")) { - - _state = PARSER_RESOLVABLE; - - _current_resitem_stored = false; - _current_resitem_name = ""; - _current_resitem_prettyName = ""; - _current_resitem_summary = ""; - _current_resitem_description = ""; - _current_resitem_section = ""; - _current_resitem_kind = string2kind (name); // needed for .., see updateStart - _current_resitem_arch = Arch_noarch; - _current_resitem_edition = Edition::noedition; - _current_resitem_fileSize = 0; - _current_resitem_installedSize = 0; - _current_resitem_installOnly = false; - _current_resitem_packageSet = false; - _current_resitem_packageUpdateList.clear(); - - _current_requires.clear(); - _current_provides.clear(); - _current_conflicts.clear(); - _current_freshens.clear(); - _current_children.clear(); - _current_recommends.clear(); - _current_suggests.clear(); - _current_obsoletes.clear(); - - } - else { - _DBG("RC_SPEW_XML") << "! Not handling " << name << " at toplevel" << endl; - } -} - - -void -XmlParser::resolvableStart(const std::string & name, const xmlChar **attrs) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::resolvableStart(" << name << ")" << endl; - - /* Only care about the containers here */ - if (name == "history") { - _state = PARSER_HISTORY; - } - else if (name == "deps") { - /* - * We can get a tag surrounding the actual package - * dependency sections (requires, provides, conflicts, etc). - * In this case, we'll just ignore this tag quietly. - */ - } - else if (name == "requires") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_requires; - } - else if (name == "recommends") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_recommends; - } - else if (name == "suggests") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_suggests; - } - else if (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 (name == "obsoletes") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_obsoletes; - } - else if (name == "provides") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_provides; - } - else if (name == "children") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_children; - } - else if (name == "freshens") { - _state = PARSER_DEP; - _current_dep_list = _toplevel_dep_list = &_current_freshens; - } - else { -// _XXX("RC_SPEW_XML") << "! Not handling " << name << " in package start" << endl; - } -} - - -void -XmlParser::historyStart(const std::string & name, const xmlChar **attrs) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::historyStart(" << name << ")" << endl; - - if (name == "update") { - assert(_current_update == NULL); - - _current_update = new PackageUpdate(_current_resitem_name, _current_resitem_kind); - - _state = PARSER_UPDATE; - } - else { - _XXX("RC_SPEW_XML") << "! Not handling " << name << " in history" << endl; - } -} - - -void -XmlParser::dependencyStart(const std::string & name, const xmlChar **attrs) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::dependencyStart(" << name << ")" << endl; - - if (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 (name == "or") - _current_dep_list->clear(); - else { - _DBG("RC_SPEW_XML") << "! Not handling " << name << " in dependency" << endl; - } -} - - -//--------------------------------------------------------------------------- - - -void -XmlParser::resolvableEnd (const std::string & name) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::resolvableEnd(" << name << ")" << endl; - - if ((name == "package") - || (name == "pattern") - || (name == "script") - || (name == "message") - || (name == "patch") - || (name == "product")) { - - _current_resitem_kind = string2kind (name); - - PackageUpdate_Ptr 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. - */ - // searching the highest version. It is not sure anymore that the last - // has highest version - if (!_current_resitem_packageUpdateList.empty()) - { - for (PackageUpdateList::iterator iter = _current_resitem_packageUpdateList.begin(); - iter != _current_resitem_packageUpdateList.end(); - iter++) - { - if (!update) - update = *iter; - else - { - if (update->edition() < (*iter)->edition()) - update = *iter; - } - } - } - - if (update) { - _current_resitem_name = update->name(); - _current_resitem_kind = update->kind(); - _current_resitem_edition = update->edition(); - _current_resitem_fileSize = update->packageSize(); - _current_resitem_installedSize = update->installedSize(); - _current_resitem_arch = update->arch(); - } - else { - for (CapSet::const_iterator iter = _current_provides.begin(); iter != _current_provides.end(); iter++) { - std::string capString = (*iter).asString(); - std::string cmpString = _current_resitem_name + " == "; - string::size_type ret = capString.find (cmpString); - if (ret != string::npos) - { - string editionStr = capString.substr (cmpString.length()); - _current_resitem_kind = (*iter).refers(); - _current_resitem_edition = Edition (editionStr); - break; - } - } - } - - // check if we provide ourselfs properly - - CapFactory factory; - Capability selfdep = factory.parse ( _current_resitem_kind, - _current_resitem_name, - Rel::EQ, - _current_resitem_edition); - 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 - _XXX("RC_SPEW") << "Adding self-provide [" << selfdep.asString() << "]" << endl; - _current_provides.insert (selfdep); - } - - Package_Ptr package = new Package ( _channel, - _current_resitem_kind, - _current_resitem_name, - _current_resitem_edition, - _current_resitem_arch); - - if (_channel->system()) // simulate system channel by loading xml file - package->setInstalled (true); - - Dependencies deps; - deps[Dep::REQUIRES] = _current_requires; - deps[Dep::PROVIDES] = _current_provides; - deps[Dep::CONFLICTS] = _current_conflicts; - deps[Dep::OBSOLETES] = _current_obsoletes; - deps[Dep::SUGGESTS] = _current_suggests; - deps[Dep::RECOMMENDS] = _current_recommends; - deps[Dep::FRESHENS] = _current_freshens; - package->deprecatedSetDependencies (deps); - package->setPrettyName (_current_resitem_prettyName); - package->setSummary (_current_resitem_summary); - package->setDescription (_current_resitem_description); - package->setFileSize (_current_resitem_fileSize); - package->setInstalledSize (_current_resitem_installedSize); - package->setInstallOnly (_current_resitem_installOnly); - package->setPackageSet (_current_resitem_packageSet); - for (PackageUpdateList::iterator iter = _current_resitem_packageUpdateList.begin(); - iter != _current_resitem_packageUpdateList.end(); - iter++) { - PackageUpdate_Ptr update = *iter; - update->setPackage (package); - package->addUpdate (update); - } - _all_packages.push_back (package); - -// _DBG("RC_SPEW") << package->asString(true) << endl; - _DBG("RC_SPEW_XML") << "XmlParser::resolvableEnd(" << name << ") done: '" << package->asString(true) << "'" << endl; -// _XXX("RC_SPEW_XML") << "XmlParser::resolvableEnd now " << _all_packages.size() << " packages" << endl; - _current_resitem_stored = true; - _state = PARSER_TOPLEVEL; - } - else if (name == "name") { _current_resitem_name = strstrip (_text_buffer); - } else if (name == "pretty_name") { _current_resitem_prettyName = strstrip (_text_buffer); - } else if (name == "summary") { _current_resitem_summary = strstrip (_text_buffer); - } else if (name == "description") { _current_resitem_description = strstrip (_text_buffer); - } else if (name == "section") { _current_resitem_section = strstrip (_text_buffer); - } else if (name == "arch") { _current_resitem_arch = Arch(strstrip (_text_buffer)); - } else if (name == "filesize") { _current_resitem_fileSize = atoi(_text_buffer); - } else if (name == "installedsize") { _current_resitem_installedSize = atoi(_text_buffer); - } else if (name == "install_only") { _current_resitem_installOnly = true; - } else if (name == "package_set") { _current_resitem_packageSet = true; - } else { - _DBG("RC_SPEW_XML") << "XmlParser::resolvableEnd(" << name << ") unknown" << endl; - } - -// _XXX("RC_SPEW_XML") << "XmlParser::resolvableEnd(" << name << ") done" << endl; - - releaseBuffer(); -} - - -void -XmlParser::historyEnd (const std::string & name) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::historyEnd(" << name << ")" << endl; - - if (name == "history") { - assert(_current_update == NULL); - - _state = PARSER_RESOLVABLE; - } -} - - -void -XmlParser::updateEnd (const std::string & name) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::updateEnd(" << name << ")" << endl; - - Channel_constPtr channel; - string url_prefix; - - assert(_current_update != NULL); - - if (_channel != NULL) { - url_prefix = _channel->filePath (); - } - - if (name == "update") { - _current_resitem_packageUpdateList.push_back(_current_update); - - _current_update = NULL; - _state = PARSER_HISTORY; - - } else if (name == "epoch") { _current_update->setEpoch (atoi(_text_buffer)); - } else if (name == "version") { _current_update->setVersion (strstrip (_text_buffer)); - } else if (name == "release") { _current_update->setRelease (strstrip (_text_buffer)); - } else if (name == "arch") { _current_update->setArch (strstrip (_text_buffer)); - } else if (name == "filename") { - strstrip (_text_buffer); - if (!url_prefix.empty()) { - _current_update->setPackageUrl (maybe_merge_paths(url_prefix, _text_buffer)); - } - else { - _current_update->setPackageUrl (_text_buffer); - } - } else if (name == "filesize") { _current_update->setPackageSize (atoi(_text_buffer)); - } else if (name == "installedsize") { _current_update->setInstalledSize (atoi (_text_buffer)); - } else if (name == "signaturename") { - strstrip (_text_buffer); - if (!url_prefix.empty()) { - _current_update->setSignatureUrl (maybe_merge_paths(url_prefix, _text_buffer)); - } - else { - _current_update->setSignatureUrl (_text_buffer); - } - } else if (name == "signaturesize") { _current_update->setSignatureSize (atoi (_text_buffer)); - } else if (name == "md5sum") { _current_update->setMd5sum (strstrip (_text_buffer)); - } else if (name == "importance") { _current_update->setImportance (Importance::parse (strstrip (_text_buffer))); - } else if (name == "description") { _current_update->setDescription (strstrip (_text_buffer)); - } else if (name == "hid") { _current_update->setHid (atoi(_text_buffer)); - } else if (name == "license") { _current_update->setLicense (strstrip (_text_buffer)); - } else { - ERR << "XmlParser::updateEnd(" << name << ") unknown" << endl; - } - -// if (_current_update != NULL ) -// _DBG("RC_SPEW_XML") << "XmlParser::updateEnd(" << name << ") => '" << _current_update->asString() << "'" << endl; - - releaseBuffer(); - -} - - -void -XmlParser::dependencyEnd (const std::string & name) -{ -// _XXX("RC_SPEW_XML") << "XmlParser::dependencyEnd(" << name << ")" << endl; - - if (name == "or") { -#if 0 - OrDependency_Ptr or_dep = OrDependency::fromDependencyList (*_current_dep_list); - Dependency_Ptr dep = new Dependency (or_dep); - - (*_current_dep_list).clear(); - - (*_toplevel_dep_list).push_back (dep); - _current_dep_list = _toplevel_dep_list; -#endif - } - else if (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_RESOLVABLE; - } -} - - - -//=================================================================================================================== - -#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; - - 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); - - 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 -///////////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/temporary/XmlParser.h b/zypp/solver/temporary/XmlParser.h deleted file mode 100644 index 269af91..0000000 --- a/zypp/solver/temporary/XmlParser.h +++ /dev/null @@ -1,171 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* XmlParser.h: XML routines - * - * 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 ZYPP_SOLVER_TEMPORARY_XMLPARSER_H -#define ZYPP_SOLVER_TEMPORARY_XMLPARSER_H - -#include - -#include -#include - -#include "zypp/CapSet.h" - -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/Package.h" -#include "zypp/solver/temporary/XmlNode.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : XmlParser - - class XmlParser - { - public: - enum _XmlParserState { - PARSER_TOPLEVEL = 0, - PARSER_RESOLVABLE, - PARSER_HISTORY, - PARSER_UPDATE, - PARSER_DEP, - }; - typedef enum _XmlParserState XmlParserState; - - private: - Channel_constPtr _channel; - bool _processing; - xmlParserCtxtPtr _xml_context; - XmlParserState _state; - - PackageList _all_packages; - - /* Temporary state */ - bool _current_resitem_stored; - std::string _current_resitem_name; - std::string _current_resitem_prettyName; - std::string _current_resitem_summary; - std::string _current_resitem_description; - std::string _current_resitem_section; - Arch _current_resitem_arch; - Resolvable::Kind _current_resitem_kind; - Edition _current_resitem_edition; - int _current_resitem_fileSize; - int _current_resitem_installedSize; - bool _current_resitem_installOnly; - bool _current_resitem_packageSet; - PackageUpdateList _current_resitem_packageUpdateList; - - CapSet _current_requires; - CapSet _current_provides; - CapSet _current_conflicts; - CapSet _current_children; - CapSet _current_recommends; - CapSet _current_suggests; - CapSet _current_obsoletes; - CapSet _current_freshens; - PackageUpdate_Ptr _current_update; - - // these point to one of the above lists during dependency parsing - CapSet *_toplevel_dep_list; - CapSet *_current_dep_list; - - char *_text_buffer; - size_t _text_buffer_size; - - protected: - void setState (XmlParserState state) { _state = state; } - - public: - - XmlParser (Channel_constPtr channel); - virtual ~XmlParser(); - - // ---------------------------------- I/O - - static std::string toString ( const XmlParser & parser); - - virtual std::ostream & dumpOn( std::ostream & str ) const; - - friend std::ostream& operator<<( std::ostream & str, const XmlParser & parser); - - std::string asString ( void ) const; - - // ---------------------------------- accessors - - bool processing() const { return _processing; } - void setProcessing (bool processing) { _processing = processing; } - - XmlParserState state (void) const { return _state; } - - #if 0 // are they needed ? - Channel_constPtr channel() const { return _channel; } - void setChannel (Channel_constPtr channel) { _channel = channel; } - - xmlParserCtxtPtr xmlContext() const { return _xml_context; } - void setXmlContext (xmlParserCtxtPtr xml_context) { _xml_context = xml_context; } - #endif - // ---------------------------------- methods - - void toBuffer (const char *data, size_t size); - void releaseBuffer (void); // free _text_buffer - - // callbacks for XML parser, c-style - void startElement(const char *name, const xmlChar **attrs); - void endElement(const char *name); - - // internal XmlParser functions, c++-style - void toplevelStart(const std::string & name, const xmlChar **attrs); - void resolvableStart(const std::string & name, const xmlChar **attrs); - void historyStart(const std::string & name, const xmlChar **attrs); - void dependencyStart(const std::string & name, const xmlChar **attrs); - - void updateEnd(const std::string & name); - void resolvableEnd(const std::string & name); - void historyEnd(const std::string & name); - void dependencyEnd(const std::string & name); - - void parseChunk (const char *xmlbuf, size_t size); - PackageList done (void); - }; - - /////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - -#endif // ZYPP_SOLVER_TEMPORARY_XMLPARSER_H diff --git a/zypp/solver/temporary/extract.cc b/zypp/solver/temporary/extract.cc deleted file mode 100644 index d6f7730..0000000 --- a/zypp/solver/temporary/extract.cc +++ /dev/null @@ -1,956 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - * extract.cc - * - * Copyright (C) 2000-2003 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 "zypp/solver/temporary/extract.h" -#include "zypp/solver/temporary/XmlParser.h" -#include "zypp/solver/temporary/utils.h" -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - - -int -extract_packages_from_xml_node (XmlNode_Ptr node, Channel_Ptr channel, CResItemFn callback, void *data) -{ - Package_Ptr package; - int count = 0; - -// _DBG("RC_SPEW_XML") << "extract_packages_from_xml_node ()" << endl; - // search the 'package' node - - while (node && !node->equals("package")) { - if (!node->isElement()) { - node = node->next(); - continue; - } - - node = node->children(); - } - - // extract the 'package' node, if found - - while (node) { - if (node->equals("package")) { - package = new Package (node, channel, ResTraits::kind); - if (package) { -// _DBG("RC_SPEW") << package->asString(true) << endl; - bool ok = true; - if (callback) - ok = callback (package, data); - if (! ok) - return -1; - ++count; - } - } - node = node->next(); - } - - return count; -} - - -int -extract_packages_from_helix_buffer (const char *buf, size_t len, Channel_Ptr channel, CResItemFn callback, void *data) -{ - unsigned int count = 0; - PackageList packages; - -// _DBG("RC_SPEW_XML") << "extract_packages_from_helix_buffer(" << buf << "...," << (long)len << ",...)" << endl; - - if (buf == NULL || len == 0) - return 0; - - XmlParser parser (channel); - parser.parseChunk (buf, len); - packages = parser.done (); - - if (packages.empty()) - return 0; - - count = packages.size(); - -// _DBG("RC_SPEW_XML") << "extract_packages_from_helix_buffer: parsed " << count << "packages" << endl; - - if (callback != NULL) { - for (PackageList::iterator iter = packages.begin(); iter != packages.end(); iter++) { - callback (*iter, data); - } - } - - return count; -} - - -int -extract_packages_from_helix_file (const string & filename, Channel_Ptr channel, CResItemFn callback, void *data) -{ - Buffer *buf; - int count; - - if (filename.empty()) - return -1; - - buf = buffer_map_file (filename); - if (buf == NULL) - return -1; - - count = extract_packages_from_helix_buffer ((const char *)(buf->data), buf->size, channel, callback, data); - - buffer_unmap_file (buf); - - return count; -} - - -int -extract_packages_from_undump_buffer (const char *buf, size_t len, ChannelAndSubscribedFn channel_callback, CResItemFn resItem_callback, MatchFn lock_callback, void *data) -{ - xmlDoc *doc; - XmlNode_Ptr dump_node; - Channel_Ptr system_channel = NULL; - Channel_Ptr current_channel = NULL; - XmlNode_Ptr channel_node; - int count = 0; - - doc = parse_xml_from_buffer (buf, len); - if (doc == NULL) - return -1; - - dump_node = new XmlNode (xmlDocGetRootElement (doc)); - if (dump_node == NULL) - return -1; - - if (!dump_node->equals("world")) { - WAR << "Unrecognized top-level node for undump: '" << dump_node->name() << "'" << endl; - return -1; - } - - channel_node = dump_node->children(); - - while (channel_node != NULL) { - - if (channel_node->equals("locks")) { - XmlNode_Ptr lock_node = channel_node->children(); - - while (lock_node) { - Match_Ptr lock; - - lock = new Match (lock_node); - - if (lock_callback) - lock_callback (lock, data); - - lock_node = lock_node->next(); - } - - } else if (channel_node->equals("system_packages")) { - - int subcount; - - if (!system_channel) { - system_channel = new Channel ("@system", "System Packages", "@system", "System Packages"); - system_channel->setSystem (true); - system_channel->setHidden (true); - } - - if (channel_callback) { - channel_callback (system_channel, false, data); - } - - subcount = extract_packages_from_xml_node (channel_node, system_channel, resItem_callback, data); - - if (subcount < 0) { - /* Do something clever */ - ERR << "No packages found" << endl; - abort (); - } - - count += subcount; - - } else if (channel_node->equals("channel")) { - - int subscribed; - current_channel = new Channel (channel_node, &subscribed, (World *)data); - - if (channel_callback) { - channel_callback (current_channel, subscribed != 0, data); - } - - if (resItem_callback) { - int subcount; - subcount = extract_packages_from_xml_node (channel_node, current_channel, resItem_callback, data); - if (subcount < 0) { - /* FIXME: do something clever */ - ERR << "No packages found" << endl; - abort (); - } - count += subcount; - } - } - - channel_node = channel_node->next(); - } - - xmlFreeDoc (doc); - - return count; -} - - -int -extract_packages_from_undump_file (const string & filename, ChannelAndSubscribedFn channel_callback, CResItemFn resItem_callback, MatchFn lock_callback, void *data) -{ - Buffer *buf; - int count; - - if (filename.empty()) - return -1; - - buf = buffer_map_file (filename); - if (buf == NULL) - return -1; - - count = extract_packages_from_undump_buffer ((const char *)(buf->data), buf->size, channel_callback, resItem_callback, lock_callback, data); - - buffer_unmap_file (buf); - - return count; -} - -#if 0 -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static ResItem_Ptr -fill_debian_package (const char *buf, const char *url_prefix, int *off) -{ - const char *ibuf; - RCPackageUpdate *up = NULL; - ResItem_Ptr r; - ResItemList requires, provides, conflicts, suggests, recommends; - - up = rc_package_update_new (); - - ibuf = buf; - while (1) { - char *key; - GString *value = NULL; - const char *p; - int ind; - - /* Linebreaks indicate the end of a package block. */ - if (*ibuf == '\0' || *ibuf == '\n') break; - - p = strchr (ibuf, ':'); - - /* Something bad happened, we're supposed to have a colon. */ - if (!p) break; - - /* Copy the name of the key and lowercase it */ - key = g_ascii_strdown (ibuf, p - ibuf); - - /* Move past the colon and any spaces */ - ibuf = p; - while (*ibuf && (*ibuf == ':' || *ibuf == ' ')) ibuf++; - - ind = 0; - while ((p = strchr (ibuf, '\n'))) { - if (!value) - value = g_string_new (""); - - g_string_append_len (value, ibuf, p - ibuf); - ind += p - ibuf; - - ibuf = p; - - /* Move past the newline */ - ibuf++; - - /* Check to see if this is a continuation of the previous line */ - if (*ibuf == ' ') { - /* It is. Move past the space */ - ibuf++; - - /* - * This is a hack. Description is special because it's - * intended to be multiline and user-visible. So if we're - * dealing with description, add a newline. - */ - - if (strncmp (key, "description", - strlen ("description")) == 0) { - g_string_append_c (value, '\n'); - - /* - * A period on a line by itself indicates that it - * should be a blank line. A newline will follow the - * period, so we'll just skip over it. - */ - if (*ibuf == '.') - ibuf++; - } - } - else { - /* It isn't. Break out. */ - break; - } - } - - if (!strncmp (key, "package", strlen ("package"))) { - rc_resItem_spec_set_name (RC_RESOLVABLE_SPEC (pkg), value->str); - } else if (!strncmp (key, "installed-size", - strlen ("installed-size"))) { - up->installed_size = strtoul (value->str, NULL, 10) * 1024; - } else if (!strncmp (key, "size", strlen ("size"))) { - up->package_size = strtoul(value->str, NULL, 10); - } else if (!strncmp (key, "description", strlen ("description"))) { - char *newline; - - /* - * We only want the first line for the summary, and all the - * other lines for the description. - */ - - newline = strchr (value->str, '\n'); - if (!newline) { - pkg->summary = strdup (value->str); - pkg->description = g_strconcat (value->str, "\n", NULL); - } - else { - pkg->summary = g_strndup (value->str, newline - value->str); - pkg->description = g_strconcat (newline + 1, "\n", NULL); - } - } else if (!strncmp (key, "version", strlen ("version"))) { - RCResItemSpec *spec = RC_RESOLVABLE_SPEC (pkg); - rc_version_parse (value->str, spec); - } else if (!strncmp (key, "section", strlen ("section"))) { - pkg->section = rc_debman_section_to_package_section (value->str); - } else if (!strncmp (key, "depends", strlen ("depends"))) { - requires = g_slist_concat ( - requires, - rc_debman_fill_depends (value->str, false)); - } else if (!strncmp (key, "recommends", strlen ("recommends"))) { - recommends = g_slist_concat ( - recommends, - rc_debman_fill_depends (value->str, false)); - } else if (!strncmp (key, "suggests", strlen ("suggests"))) { - suggests = g_slist_concat ( - suggests, - rc_debman_fill_depends (value->str, false)); - } else if (!strncmp (key, "pre-depends", strlen ("pre-depends"))) { - requires = g_slist_concat ( - requires, - rc_debman_fill_depends (value->str, true)); - } else if (!strncmp (key, "conflicts", strlen ("conflicts"))) { - conflicts = g_slist_concat ( - conflicts, - rc_debman_fill_depends (value->str, false)); - } else if (!strncmp (key, "provides", strlen ("provides"))) { - provides = g_slist_concat ( - provides, - rc_debman_fill_depends (value->str, false)); - } else if (!strncmp (key, "filename", strlen ("filename"))) { - /* Build a new update with just this version */ - if (url_prefix) { - up->package_url = g_strconcat (url_prefix, "/", - value->str, - NULL); - } else { - up->package_url = strdup (value->str); - } - } else if (!strncmp (key, "md5sum", strlen ("md5sum"))) { - up->md5sum = strdup (value->str); - } else if (!strncmp (key, "architecture", strlen ("architecture"))) { - rc_resItem_spec_set_arch (RC_RESOLVABLE_SPEC (pkg), rc_arch_from_string (value->str)); - } - - g_string_free (value, true); - } - - up->importance = RC_IMPORTANCE_SUGGESTED; - up->description = strdup ("Upstream Debian release"); - rc_resItem_spec_copy (rc_package_update_get_spec(up), RC_RESOLVABLE_SPEC (pkg)); - rc_package_add_update (pkg, up); - - r = RC_RESOLVABLE (pkg); - - /* Make sure to provide myself, for the dep code! */ - provides = g_slist_append (provides, rc_resItem_dep_new_from_spec - (RC_RESOLVABLE_SPEC (pkg), - RC_RELATION_EQUAL, - RC_TYPE_PACKAGE, - rc_resItem_get_channel (r), - false, false)); - - rc_resItem_set_requires (r, requires); - rc_resItem_set_provides (r, provides); - rc_resItem_set_conflicts (r, conflicts); - rc_resItem_set_obsoletes (r, NULL); - rc_resItem_set_suggests (r, suggests); - rc_resItem_set_recommends(r, recommends); - /* returns the number of characters we processed */ - return ibuf - buf; -} - -#endif - -int -extract_packages_from_debian_buffer (const char *buf, size_t len, Channel_Ptr channel, CResItemFn callback, void *data) -{ - const char *pos; - int count = 0; - - /* Keep looking for a "Package: " */ - pos = buf; -#if 0 - while ((pos = strstr (pos, "Package: ")) != NULL) { - int off; - - /* All debian packages "have" epochs */ - ResItem_Ptr resItem = fill_debian_package (iter, channel->getFilePath (), &off); - - resItem->setEpoch (0); - resItem->setArch ( Arch()); - resItem->setChannel (channel); - - if (callback) - callback (resItem, data); - - ++count; - - iter += off; - } -#endif - return count; -} - - -int -extract_packages_from_debian_file (const string & filename, Channel_Ptr channel, CResItemFn callback, void *data) -{ - Buffer *buf; - int count; - - if (filename.empty()) - return -1; - - buf = buffer_map_file (filename); - if (buf == NULL) - return -1; - - count = extract_packages_from_debian_buffer ((const char *)(buf->data), buf->size, channel, callback, data); - buffer_unmap_file (buf); - - return count; -} - -#if 0 -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -Package_Ptr -extract_yum_package (const guint8 *data, size_t len, - RCPackman *packman, char *url) -{ -#ifndef ENABLE_RPM - /* We can't support yum without rpm support */ - ERR << "RPM support is not enabled" << endl; - return NULL; -#else - RCRpmman *rpmman; - Header h; - Package_Ptr p; - RCPackageUpdate *pu; - char *tmpc; - int typ, n; - - g_return_val_if_fail (packman != NULL, NULL); - - if (!g_type_is_a (G_TYPE_FROM_INSTANCE (packman), RC_TYPE_RPMMAN)) { - DBG << "yum support is not available on non-RPM systems" << endl; - return NULL; - } - - rpmman = RC_RPMMAN (packman); - - h = rpmman->headerLoad (data); - - if (h == NULL) { - DBG << "Unable to get header from headerCopyLoad!" << endl; - return NULL; - } - - rpmman->headerGetEntry (h, RPMTAG_ARCH, &typ, (void **) &tmpc, &n); - - p = rc_package_new (); - - rc_rpmman_read_header (rpmman, h, p); - rc_rpmman_depends_fill (rpmman, h, p, true); - - pu = rc_package_update_new (); - rc_resItem_spec_copy (rc_package_update_get_spec (pu), RC_RESOLVABLE_SPEC (p)); - pu->importance = RC_IMPORTANCE_SUGGESTED; - pu->description = strdup ("No information available."); - pu->package_url = url; - - p->history = g_slist_append (p->history, pu); - - rpmman->headerFree (h); - - return p; -#endif -} - -int -extract_packages_from_aptrpm_buffer (const guint8 *data, size_t len, - RCPackman *packman, - Channel_Ptr channel, - CResItemFn callback, - void * user_data) -{ -#ifndef ENABLE_RPM - /* We can't support apt-rpm without rpm support */ - ERR << "RPM support is not enabled" << endl; - return -1; -#else - RCRpmman *rpmman; - int count = 0; - const int hdrmagic_len = 8; - const char *hdrmagic; - const guint8 *cur_ptr; - RCResItemSpec *spec; - - - g_return_val_if_fail (packman != NULL, -1); - - if (!g_type_is_a (G_TYPE_FROM_INSTANCE (packman), RC_TYPE_RPMMAN)) { - ERR << "apt-rpm support is not available on non-RPM systems" << endl; - return -1; - } - - rpmman = RC_RPMMAN (packman); - - if (len < hdrmagic_len) { - ERR << "Data is too small to possibly be correct" << endl; - return 0; - } - - /* - * The apt-rpm pkglist files are a set of rpm headers, each prefixed - * with the header magic, one right after the other. If opened on disk, - * they can be iterated using headerRead(). Since we have an in-memory - * buffer, we use headerCopyLoad to read them. We could, potentially, - * use headerLoad(); but I'm unsure as to what happens when headerFree - * is called on a Header returned from headerLoad. It may be a small - * memory savings to do so. - */ - - /* Skip the inital RPM header magic */ - hdrmagic = data; - cur_ptr = data + hdrmagic_len; - - while (cur_ptr != NULL) { - Header h; - Package_Ptr p; - RCPackageUpdate *pu; - int bytesleft, i; - char *tmpc; - int typ, n; - char *archstr; - - h = rpmman->headerLoad (cur_ptr); - - if (h == NULL) { - ERR << "Unable to get header from headerCopyLoad!" << endl; - return 0; - } - - rpmman->headerGetEntry (h, RPMTAG_ARCH, &typ, (void **) &tmpc, &n); - - if (n && typ == RPM_STRING_TYPE) - archstr = tmpc; - else { - WAR << "No arch available!" << endl; - goto cleanup; - } - - p = rc_package_new (); - - rc_rpmman_read_header (rpmman, h, p); - rc_rpmman_depends_fill (rpmman, h, p, true); - - rc_resItem_set_channel (RC_RESOLVABLE (p), channel); - - pu = rc_package_update_new (); - rc_resItem_spec_copy (rc_package_update_get_spec (pu), RC_RESOLVABLE_SPEC (p)); - pu->importance = RC_IMPORTANCE_SUGGESTED; - pu->description = strdup ("No information available."); - - /* Build a filename from the spec */ - spec = RC_RESOLVABLE_SPEC (p); - pu->package_url = strdup_printf ("%s/%s-%s-%s.%s.rpm", - rc_channel_get_file_path (channel), - rc_resItem_spec_get_name (spec), - rc_resItem_spec_get_version (spec), - rc_resItem_spec_get_release (spec), - archstr); - - p->history = g_slist_append (p->history, pu); - - if (callback) - callback ((RCResItem *) p, user_data); - - g_object_unref (p); - - ++count; - - cleanup: - rpmman->headerFree (h); - - /* This chunk of ugly could be removed if a) memmem() was portable; - * or b) if rpmlib didn't suck, and I could figure out how much - * data it read from the buffer. - */ - bytesleft = len - (cur_ptr - data); - for (i = 0; i < bytesleft - hdrmagic_len; i++) { - if (memcmp (cur_ptr + i, hdrmagic, hdrmagic_len) == 0) { - /* We found a match */ - cur_ptr = cur_ptr + i + hdrmagic_len; - break; - } - } - - if (i >= bytesleft - hdrmagic_len) { - /* No match was found */ - cur_ptr = NULL; - } - } - - return count; -#endif -} - -int -extract_packages_from_aptrpm_file (const char *filename, - RCPackman *packman, - Channel_Ptr channel, - CResItemFn callback, - void * user_data) -{ - World_Ptr world = *((World_Ptr *)data); - RCBuffer *buf; - int count; - - g_return_val_if_fail (filename != NULL, -1); - g_return_val_if_fail (packman != NULL, -1); - - buf = rc_buffer_map_file (filename); - if (buf == NULL) - return -1; - - count = extract_packages_from_aptrpm_buffer (buf->data, buf->size, - packman, channel, - callback, user_data); - - rc_buffer_unmap_file (buf); - - return count; -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -package_into_hash (Package_Ptr pkg, GHashTable *hash) -{ - void * nameq; - Package_Ptr hashed_pkg; - - nameq = GINT_TO_POINTER (RC_RESOLVABLE_SPEC (pkg)->nameq); - hashed_pkg = g_hash_table_lookup (hash, nameq); - if (hashed_pkg == NULL) { - g_hash_table_insert (hash, nameq, g_object_ref (pkg)); - } else if (rc_version_compare (RC_RESOLVABLE_SPEC (pkg), - RC_RESOLVABLE_SPEC (hashed_pkg)) > 0) { - g_hash_table_replace (hash, nameq, g_object_ref (pkg)); - g_object_unref (hashed_pkg); - } -} - -static bool -hash_recurse_cb (Package_Ptr pkg, void * user_data) -{ - GHashTable *hash = user_data; - package_into_hash (pkg, hash); - return true; -} - -struct HashIterInfo { - CResItemFn callback; - void * user_data; - int count; -}; - -static void -hash_iter_cb (void * key, void * val, void * user_data) -{ - RCResItem *r = val; - struct HashIterInfo *info = user_data; - - if (info->callback) - info->callback (r, info->user_data); - - g_object_unref (r); - ++info->count; -} - - -static void -add_fake_history (Package_Ptr pkg) -{ - RCPackageUpdate *up; - - up = rc_package_update_new (); - rc_resItem_spec_copy ((RCResItemSpec *) up, - RC_RESOLVABLE_SPEC (pkg)); - up->importance = RC_IMPORTANCE_SUGGESTED; - rc_package_add_update (pkg, up); -} - -typedef struct { - CResItemFn user_callback; - void * user_data; - const gchar *path; -} PackagesFromDirInfo; - -static bool -packages_from_dir_cb (Package_Ptr package, void * user_data) -{ - PackagesFromDirInfo *info = user_data; - RCPackageUpdate *update; - - /* Set package path */ - update = rc_package_get_latest_update (package); - if (update && update->package_url) - package->package_filename = g_build_path (G_DIR_SEPARATOR_S, - info->path, - update->package_url, - NULL); - if (info->user_callback) - return info->user_callback ((RCResItem *)package, info->user_data); - - return true; -} - -int -extract_packages_from_directory (const char *path, - Channel_Ptr channel, - RCPackman *packman, - bool recursive, - CResItemFn callback, - void * user_data) -{ - World_Ptr world = *((World_Ptr *)data); - GDir *dir; - GHashTable *hash; - struct HashIterInfo info; - const char *filename; - char *magic; - bool distro_magic, pkginfo_magic; - - g_return_val_if_fail (path && *path, -1); - g_return_val_if_fail (channel != NULL, -1); - - /* - Check for magic files that indicate how to treat the - directory. The files aren't read -- it is sufficient that - they exist. - */ - - magic = g_strconcat (path, "/RC_SKIP", NULL); - if (g_file_test (magic, G_FILE_TEST_EXISTS)) { - g_free (magic); - return 0; - } - g_free (magic); - - magic = g_strconcat (path, "/RC_RECURSIVE", NULL); - if (g_file_test (magic, G_FILE_TEST_EXISTS)) - recursive = true; - g_free (magic); - - magic = g_strconcat (path, "/RC_BY_DISTRO", NULL); - distro_magic = g_file_test (magic, G_FILE_TEST_EXISTS); - g_free (magic); - - pkginfo_magic = true; - magic = g_strconcat (path, "/RC_IGNORE_PKGINFO", NULL); - if (g_file_test (magic, G_FILE_TEST_EXISTS)) - pkginfo_magic = false; - g_free (magic); - - /* If distro_magic is set, we search for packages in two - subdirectories of path: path/distro-target (i.e. - path/redhat-9-i386) and path/x-cross. - */ - -#if 0 - if (distro_magic) { - char *distro_path, *cross_distro_path; - bool found_distro_magic = false; - int count = 0, c; - - distro_path = g_strconcat (path, "/", rc_distro_get_target (), NULL); - if (g_file_test (distro_path, G_FILE_TEST_IS_DIR)) { - found_distro_magic = true; - - c = extract_packages_from_directory (distro_path, - channel, packman, - callback, user_data); - if (c >= 0) - count += c; - } - - cross_distro_path = g_strconcat (path, "/x-distro", NULL); - if (g_file_test (cross_distro_path, G_FILE_TEST_IS_DIR)) { - c = extract_packages_from_directory (cross_distro_path, - channel, packman, - callback, user_data); - if (c >= 0) - count += c; - } - - g_free (cross_distro_path); - g_free (distro_path); - - return count; - } -#endif - - /* If pkginfo_magic is set and if a packageinfo.xml or - packageinfo.xml.gz file exists in the directory, use it - instead of just scanning the files in the directory - looking for packages. */ - - if (pkginfo_magic) { - int i, count; - gchar *pkginfo_path = NULL; - const gchar *pkginfo[] = { "packageinfo.xml", - "packageinfo.xml.gz", - NULL }; - - for (i = 0; pkginfo[i]; i++) { - pkginfo_path = g_build_path (G_DIR_SEPARATOR_S, path, pkginfo[i], NULL); - if (g_file_test (pkginfo_path, G_FILE_TEST_EXISTS)) - break; - - g_free (pkginfo_path); - pkginfo_path = NULL; - } - - if (pkginfo_path) { - PackagesFromDirInfo info; - - info.user_callback = callback; - info.user_data = user_data; - info.path = path; - - count = extract_packages_from_helix_file (pkginfo_path, channel, packages_from_dir_cb, &info); - g_free (pkginfo_path); - return count; - } - } - - dir = g_dir_open (path, 0, NULL); - if (dir == NULL) - return -1; - - hash = g_hash_table_new (NULL, NULL); - - while ( (filename = g_dir_read_name (dir)) ) { - gchar *file_path; - - file_path = g_strconcat (path, "/", filename, NULL); - - if (recursive && g_file_test (file_path, G_FILE_TEST_IS_DIR)) { - extract_packages_from_directory (file_path, - channel, - packman, - true, - hash_recurse_cb, - hash); - } else if (g_file_test (file_path, G_FILE_TEST_IS_REGULAR)) { - Package_Ptr pkg; - - pkg = rc_packman_query_file (packman, file_path, true); - if (pkg != NULL) { - rc_resItem_set_channel (RC_RESOLVABLE (pkg), channel); - pkg->package_filename = strdup (file_path); - pkg->local_package = false; - add_fake_history (pkg); - package_into_hash (pkg, hash); - g_object_unref (pkg); - } - } - - g_free (file_path); - } - - g_dir_close (dir); - - info.callback = callback; - info.user_data = user_data; - info.count = 0; - - /* Walk across the hash and: - 1) Invoke the callback on each package - 2) Unref each package - */ - g_hash_table_foreach (hash, hash_iter_cb, &info); - - g_hash_table_destroy (hash); - - return info.count; -} -#endif - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - diff --git a/zypp/solver/temporary/extract.h b/zypp/solver/temporary/extract.h deleted file mode 100644 index 8670085..0000000 --- a/zypp/solver/temporary/extract.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* - * extract.h - * - * Copyright (C) 2003 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 ZYPP_SOLVER_TEMPORARY_EXTRACT_H -#define ZYPP_SOLVER_TEMPORARY_EXTRACT_H - -#include "zypp/solver/detail/Pending.h" - -#include "zypp/solver/temporary/Channel.h" -#include "zypp/solver/temporary/XmlNode.h" -#include "zypp/solver/temporary/ResItem.h" -#include "zypp/solver/temporary/Package.h" -#include "zypp/solver/temporary/Match.h" -#include "zypp/solver/temporary/StoreWorldPtr.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -int extract_packages_from_helix_buffer (const char data[], size_t len, Channel_Ptr channel, CResItemFn callback, void *data); -int extract_packages_from_helix_file (const std::string & filename, Channel_Ptr channel, CResItemFn callback, void *data); - -int extract_packages_from_undump_buffer (const char *data, size_t len, ChannelAndSubscribedFn channel_callback, CResItemFn package_callback, MatchFn lock_callback, void *data); -int extract_packages_from_undump_file (const std::string & filename, ChannelAndSubscribedFn channel_callback, CResItemFn package_callback, MatchFn lock_callback, void *data); - -int extract_packages_from_xml_node (XmlNode_constPtr node, Channel_Ptr channel, ResItemFn callback, void *data); - -#if 0 -int extract_packages_from_debian_buffer (const char *data, size_t len, Channel_Ptr channel, CResItemFn callback, void *data); -int extract_packages_from_debian_file (const std::string & filename, Channel_Ptr channel, CResItemFn callback, void *data); - -Package_Ptr extract_yum_package (const char *data, size_t len, Packman_Ptr packman, const std::string & url); - -int extract_packages_from_aptrpm_buffer (const char *data, size_t len, Packman_Ptr packman, Channel_Ptr channel, ResItemFn callback, void *data); -int extract_packages_from_aptrpm_file (const std::string & filename, Packman_Ptr packman, Channel_Ptr channel, ResItemFn callback, void *data); - -int extract_packages_from_directory (const std::string & path, Channel_Ptr channel, Packman_Ptr packman, bool recursive, ResItemFn callback, void *data); -#endif - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// -#endif /* ZYPP_SOLVER_TEMPORARY_EXTRACT_H */ - diff --git a/zypp/solver/temporary/utils.cc b/zypp/solver/temporary/utils.cc deleted file mode 100644 index 0b753e6..0000000 --- a/zypp/solver/temporary/utils.cc +++ /dev/null @@ -1,697 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* utils.cc utility 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 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "zypp/solver/temporary/utils.h" - -#include "zlib.h" -#ifdef HAVE_BZ2 -/* Older bzlib didn't icnlude stdio.h */ -# include -#endif - -#include "zypp/base/Logger.h" - -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -using namespace std; - -//--------------------------------------------------------------------------- -// string stuff - -/* Like g_strstrip(), only returns NULL on an empty string */ -char * -strstrip (const char *str) -{ - const char *start; - const char *end; - - if (str == NULL) - return ""; - - start = str; - while (isblank (*start)) { - start++; - } - - end = start + strlen (start) - 1; - while (end > start - && isblank (*end)) { - end--; - } - - if (start > end) { // empty string - return NULL; - } - - if (start > str - || *(end+1) != 0) { // we stripped at least one blank somewhere - return strndup (start, end - start + 1); - } - return strdup (str); // no blanks stripped -} - - -//--------------------------------------------------------------------------- -// url and path stuff - -string -maybe_merge_paths(const std::string & parent_path, const std::string & child_path) -{ - /* Child path is "", so we return a dup of the parent path. - Ex: maybe_merge_paths("/foo", "") => "/foo" */ - if (child_path.empty()) - return parent_path; - - /* Child path is a fully qualified URL, so we return a dup of it. - Ex: maybe_merge_paths("/foo", "http://www.ximian.com") => - "http://www.ximian.com" - - OR - - Child path is an absolute path, so we just return a dup of it. - Ex: maybe_merge_paths("/foo", "/bar/baz") => "/bar/baz" */ - - if (url_is_absolute(child_path) || child_path[0] == '/') - return child_path; - - /* Child path is a relative path, so we tack child path onto the end of - parent path. - Ex: maybe_merge_paths("/foo", "bar/baz") => "/foo/bar/baz" */ - - string s = parent_path; - - if (parent_path[parent_path.length() - 1] != '/') - s += "/"; - - s += child_path; - - return s; -} - - -bool -url_is_absolute (const std::string & url) -{ - if (strncasecmp (url.c_str(), "http:", 5) == 0 || - strncasecmp (url.c_str(), "https:", 6) == 0 || - strncasecmp (url.c_str(), "ftp:", 4) == 0 || - strncasecmp (url.c_str(), "cd:", 3) == 0 || - strncasecmp (url.c_str(), "dvd:", 4) == 0 || - strncasecmp (url.c_str(), "dir:", 4) == 0 || - strncasecmp (url.c_str(), "file:", 5) == 0) - { - return true; - } - - return false; -} - - -//--------------------------------------------------------------------------- -// compress/uncompress stuff - -/* - * Magic gunzipping goodness - */ - -/* - * Count number of bytes to skip at start of buf - */ -static int gz_magic[2] = {0x1f, 0x8b}; -/* gzip flag byte */ -#define GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define GZ_COMMENT 0x10 /* bit 4 set: file comment present */ -#define GZ_RESERVED 0xE0 /* bits 5..7: reserved */ - -static int -count_gzip_header (const unsigned char *buf, unsigned int input_length) -{ - int method, flags; - const unsigned char *s = buf; - unsigned int left_len = input_length; - - if (left_len < 4) return -1; - if (*s++ != gz_magic[0] || *s++ != gz_magic[1]) { - return -2; - } - - method = *s++; - flags = *s++; - left_len -= 4; - - if (method != Z_DEFLATED || (flags & GZ_RESERVED) != 0) { - /* If it's not deflated, or the reserved isn't 0 */ - return -3; - } - - /* Skip time, xflags, OS code */ - if (left_len < 6) return -4; - s += 6; - left_len -= 6; - - if (flags & GZ_EXTRA_FIELD) { - unsigned int len; - if (left_len < 2) return -5; - len = (unsigned int)(*s++); - len += ((unsigned int)(*s++)) << 8; - if (left_len < len) return -6; - s += len; - left_len -= len; - } - - /* Skip filename */ - if (flags & GZ_ORIG_NAME) { - while (--left_len != 0 && *s++ != '\0') ; - if (left_len == 0) return -7; - } - /* Skip comment */ - if (flags & GZ_COMMENT) { - while (--left_len != 0 && *s++ != '\0') ; - if (left_len == 0) return -7; - } - /* Skip CRC */ - if (flags & GZ_HEAD_CRC) { - if (left_len < 2) return -7; - s += 2; - left_len -= 2; - } - - return input_length - left_len; -} - - -int -gunzip_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba) -{ - z_stream zs; - char *outbuf = NULL; - ByteArray *ba = NULL; - int zret; - - int gzip_hdr; - - if (input_buffer == NULL) return -1; - if (input_length == 0) return -2; - if (out_ba == NULL) return -3; - - ba = (ByteArray *)malloc (sizeof (ByteArray)); - ba->data = NULL; - ba->len = 0; - - gzip_hdr = count_gzip_header (input_buffer, input_length); - if (gzip_hdr < 0) - return -1; - - zs.next_in = (unsigned char *) input_buffer + gzip_hdr; - zs.avail_in = input_length - gzip_hdr; - zs.zalloc = NULL; - zs.zfree = NULL; - zs.opaque = NULL; - -#define OUTBUFSIZE 10000 - outbuf = (char *)malloc (OUTBUFSIZE); - zs.next_out = (Bytef *)outbuf; - zs.avail_out = OUTBUFSIZE; - - /* Negative inflateinit is magic to tell zlib that there is no - * zlib header */ - inflateInit2 (&zs, -MAX_WBITS); - - while (1) { - zret = inflate (&zs, Z_SYNC_FLUSH); - if (zret != Z_OK && zret != Z_STREAM_END) - break; - - ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out)); - memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out); - ba->len += (OUTBUFSIZE - zs.avail_out); - - zs.next_out = (Bytef *)outbuf; - zs.avail_out = OUTBUFSIZE; - - if (zret == Z_STREAM_END) - break; - } - - inflateEnd (&zs); - free ((void *)outbuf); - - if (zret != Z_STREAM_END) { - ERR << "libz inflate failed! (" << zret << ")" << endl; - free (ba->data); - free (ba); - ba = NULL; - } else { - zret = 0; - } - - *out_ba = ba; - return zret; -} - - -int -gzip_memory (const char *input_buffer, unsigned int input_length, ByteArray **out_ba) -{ - z_stream zs; - char *outbuf = NULL; - ByteArray *ba = NULL; - int zret; - - if (input_buffer == NULL) return -1; - if (input_length == 0) return -2; - if (out_ba == NULL) return -3; - - ba = (ByteArray *)malloc (sizeof (ByteArray)); - ba->data = NULL; - ba->len = 0; - - zs.next_in = (unsigned char *) input_buffer; - zs.avail_in = input_length; - zs.zalloc = NULL; - zs.zfree = NULL; - zs.opaque = NULL; - - outbuf = (char *)malloc (OUTBUFSIZE); - zs.next_out = (Bytef *)outbuf; - zs.avail_out = OUTBUFSIZE; - - deflateInit (&zs, Z_DEFAULT_COMPRESSION); - - while (1) { - if (zs.avail_in) - zret = deflate (&zs, Z_SYNC_FLUSH); - else - zret = deflate (&zs, Z_FINISH); - - if (zret != Z_OK && zret != Z_STREAM_END) - break; - - ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out)); - memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out); - ba->len += (OUTBUFSIZE - zs.avail_out); - - zs.next_out = (Bytef *)outbuf; - zs.avail_out = OUTBUFSIZE; - - if (zret == Z_STREAM_END) - break; - } - - deflateEnd (&zs); - free ((void *)outbuf); - - if (zret != Z_STREAM_END) { - ERR << "libz deflate failed! (" << zret << ")" << endl; - free (ba->data); - free (ba); - ba = NULL; - } else { - zret = 0; - } - - *out_ba = ba; - return zret; -} /* gzip_memory */ - - -bool -memory_looks_gzipped (const unsigned char *buffer) -{ - if (buffer == NULL) - return false; - - /* This is from RFC 1952 */ - - return buffer[0] == gz_magic[0] /* ID1 */ - && buffer[1] == gz_magic[1]; /* ID2 */ -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static char bz2_magic[3] = { 'B', 'Z', 'h' }; - -int -bunzip2_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba) -{ -#ifndef HAVE_BZ2 - - ERR << "bz2 support not compiled in" << endl; - *out_ba = NULL; - - return -1; - -#else - - bz_stream bzs; - ByteArray *ba; - char *outbuf; - int bzret; - - if (input_buffer == NULL) return -1; - if (input_length == 0) return -2; - if (out_ba == NULL) return -3; - - ba = (ByteArray *)malloc (sizeof (ByteArray)); - ba->data = NULL; - ba->len = 0; - - bzs.next_in = (unsigned char *) input_buffer; - bzs.avail_in = input_length; - bzs.bzalloc = NULL; - bzs.bzfree = NULL; - bzs.opaque = NULL; - - outbuf = (char *)malloc (OUTBUFSIZE); - bzs.next_out = (Bytef *)outbuf; - bzs.avail_out = OUTBUFSIZE; - - BZ2_bzDecompressInit (&bzs, 1, 0); - - while (1) { - bzret = BZ2_bzDecompress (&bzs); - if (bzret != BZ_OK && bzret != BZ_STREAM_END) - break; - - ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out)); - memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out); - ba->len += (OUTBUFSIZE - zs.avail_out); - - bzs.next_out = (Bytef *)outbuf; - bzs.avail_out = OUTBUFSIZE; - - if (bzret == BZ_STREAM_END) - break; - - if (bzs.avail_in == 0) { - /* The data is incomplete */ - bzret = -1; - break; - } - } - - BZ2_bzDecompressEnd (&bzs); - free ((void *)outbuf); - - if (bzret != BZ_STREAM_END) { - ERR << "libbzip2 decompress failed (" << bzret << ")" << endl; - free (ba->data); - free (ba); - ba = NULL; - } else { - bzret = 0; - } - - *out_ba = ba; - return bzret; -#endif -} - - -int -bzip2_memory (const char *input_buffer, unsigned int input_length, ByteArray **out_ba) -{ -#ifndef HAVE_BZ2 - - ERR << "bz2 support not compiled in" << endl; - *out_ba = NULL; - - return -1; - -#else - - bz_stream bzs; - ByteArray *ba; - char *outbuf; - int bzret; - - if (input_buffer == NULL) return -1; - if (input_length == 0) return -2; - if (out_ba == NULL) return -3; - - ba = (ByteArray *)malloc (sizeof (ByteArray)); - ba->data = NULL; - ba->len = 0; - - bzs.next_in = (unsigned char *) input_buffer; - bzs.avail_in = input_length; - bzs.bzalloc = NULL; - bzs.bzfree = NULL; - bzs.opaque = NULL; - - outbuf = (char *)malloc (OUTBUFSIZE); - bzs.next_out = (Bytef *)outbuf; - bzs.avail_out = OUTBUFSIZE; - - BZ2_bzCompressInit (&bzs, 5, 1, 0); - - while (1) { - if (bzs.avail_in) - bzret = BZ2_bzCompress (&bzs, BZ_RUN); - else - bzret = BZ2_bzCompress (&bzs, BZ_FINISH); - - if (bzret != BZ_OK && bzret != BZ_STREAM_END) - break; - - ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out)); - memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out); - ba->len += (OUTBUFSIZE - zs.avail_out); - - bzs.next_out = (Bytef *)outbuf; - bzs.avail_out = OUTBUFSIZE; - - if (bzret == BZ_STREAM_END) - break; - } - - BZ2_bzCompressEnd (&bzs); - free ((void *)outbuf); - - if (bzret != BZ_STREAM_END) { - ERR << "bz2 compress failed! (" << bzret << ")" << endl; - free (ba->data); - free (ba); - ba = NULL; - } else { - bzret = 0; - } - - *out_ba = ba; - return bzret; -#endif -} - - -bool -memory_looks_bzip2ed (const unsigned char *buffer) -{ - if (buffer == NULL) - return false; - - return buffer[0] == bz2_magic[0] - && buffer[1] == bz2_magic[1] - && buffer[2] == bz2_magic[2]; -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -int -uncompress_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba) -{ - if (input_length > 2 && memory_looks_bzip2ed (input_buffer)) - return bunzip2_memory (input_buffer, input_length, out_ba); - else if (input_length > 3 && memory_looks_gzipped (input_buffer)) - return gunzip_memory (input_buffer, input_length, out_ba); - else - return -1; -} - -bool -memory_looks_compressed (const unsigned char *buffer, size_t size) -{ -#ifdef HAVE_BZ2 - if (size > 2 && memory_looks_bzip2ed (buffer)) - return true; -#endif - - if (size > 4 && memory_looks_gzipped (buffer)) - return true; - - return false; -} - -//--------------------------------------------------------------------------- -// I/O stuff - -/* - * This just allows reading from the buffer for now. It could be extended to - * do writing if necessary. - */ - -Buffer * -buffer_map_file (const string & filename) -{ - struct stat s; - int fd; - unsigned char *data; - Buffer *buf = NULL; - - if (filename.empty()) - return NULL; - - if (stat(filename.c_str(), &s) < 0) - return NULL; - - fd = open(filename.c_str(), O_RDONLY); - - if (fd < 0) - return NULL; - - data = (unsigned char *)mmap(NULL, s.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); - - close (fd); - - if (data == MAP_FAILED) - return NULL; - - /* Transparently uncompress */ - if (memory_looks_compressed (data, s.st_size)) { - ByteArray *byte_array = NULL; - - if (uncompress_memory (data, s.st_size, &byte_array)) { - WAR << "Uncompression of '" << filename - << "' failed" << endl; - } else { - buf = (Buffer *)malloc(sizeof (Buffer)); - buf->data = byte_array->data; - buf->size = byte_array->len; - buf->is_mmapped = false; - } - - munmap (data, s.st_size); - - if (byte_array) { - free (byte_array); - } - - } else { - buf = (Buffer *)malloc(sizeof (Buffer)); - buf->data = (byte *)data; - buf->size = s.st_size; - buf->is_mmapped = true; - } - - return buf; -} /* buffer_map_file */ - -void -buffer_unmap_file (Buffer *buf) -{ - if (buf == NULL) return; - - if (buf->is_mmapped) - munmap (buf->data, buf->size); - else - free (buf->data); - - free (buf); -} - -//--------------------------------------------------------------------------- -// XML stuff - -xmlDoc * -parse_xml_from_buffer (const char *input_buffer, size_t input_length) -{ - xmlDoc *doc = NULL; - - if (input_buffer == NULL) return NULL; - - if (input_length > 3 && memory_looks_gzipped ((const unsigned char *)input_buffer)) { - ByteArray *buf; - - if (uncompress_memory ((const unsigned char *)input_buffer, input_length, &buf)) { - return NULL; - } - doc = xmlParseMemory ((const char *)(buf->data), buf->len); - free (buf->data); - free (buf); - } else { - doc = xmlParseMemory (input_buffer, input_length); - } - - return doc; -} - - -xmlDoc * -parse_xml_from_file (const string & filename) -{ - Buffer *buf; - xmlDoc *doc = NULL; - - if (filename.empty()) return NULL; - - buf = buffer_map_file (filename); - if (buf) { - doc = xmlParseMemory ((const char *)(buf->data), buf->size); - buffer_unmap_file (buf); - } - - return doc; -} - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - - diff --git a/zypp/solver/temporary/utils.h b/zypp/solver/temporary/utils.h deleted file mode 100644 index dca3719..0000000 --- a/zypp/solver/temporary/utils.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ - -/* - * utils.h - * - * Copyright (C) 2003 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 ZYPP_SOLVER_TEMPORARY_UTILS_H -#define ZYPP_SOLVER_TEMPORARY_UTILS_H - -#include -#include -#include -#include -///////////////////////////////////////////////////////////////////////// -namespace zypp -{ /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// - namespace solver - { ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - namespace detail - { /////////////////////////////////////////////////////////////////// - -typedef unsigned char byte; - -char *strstrip (const char *str); -std::string maybe_merge_paths(const std::string & parent_path, const std::string & child_path); -bool url_is_absolute (const std::string & url); - -typedef struct { - byte *data; - size_t len; -} ByteArray; - -// An easy way to map files. If we map a compressed file, -// it will be magically uncompressed for us. - -typedef struct { - byte *data; - size_t size; - bool is_mmapped; -} Buffer; - -Buffer *buffer_map_file (const std::string & filename); -void buffer_unmap_file (Buffer *buffer); - - -xmlDoc *parse_xml_from_buffer (const char *input_buffer, size_t input_length); -xmlDoc *parse_xml_from_file (const std::string & filename); - -/////////////////////////////////////////////////////////////////// - };// namespace detail - ///////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////// - };// namespace solver - /////////////////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////////////////// -};// namespace zypp -///////////////////////////////////////////////////////////////////////// - -#endif // ZYPP_SOLVER_TEMPORARY_UTILS_H - -- 2.7.4