ByteArray *byte_array = NULL;
if (uncompress_memory (data, s.st_size, &byte_array)) {
- WAR << "Uncompression of '" << filename
- << "' failed" << endl;
+ WAR << "Uncompression of '" << filename << "' failed" << endl;
} else {
buf = (Buffer *)malloc(sizeof (Buffer));
buf->data = byte_array->data;
using namespace std;
using namespace zypp;
-using namespace zypp::solver::detail;
+
+namespace zypp {
int
-extractHelixBuffer (const char buf[], size_t len, Channel_Ptr channel, ResolvableStoreCallback callback, ResStore *store)
+extractHelixBuffer (const char *buf, size_t len, solver::detail::Channel_Ptr channel, HelixSourceImpl *impl)
{
// _DBG("HelixExtract") << "extract_packages_from_helix_buffer(" << buf << "...," << (long)len << ",...)" << endl;
return 1;
HelixParser parser (channel);
- parser.parseChunk (buf, len, callback, store);
+ parser.parseChunk (buf, len, impl);
parser.done ();
return 0;
int
-extractHelixFile (const std::string & filename, Channel_Ptr channel, ResolvableStoreCallback callback, ResStore *store)
+extractHelixFile (const std::string & filename, solver::detail::Channel_Ptr channel, HelixSourceImpl *impl)
{
Buffer *buf;
if (buf == NULL)
return -1;
- extractHelixBuffer ((const char *)(buf->data), buf->size, channel, callback, store);
+ extractHelixBuffer ((const char *)(buf->data), buf->size, channel, impl);
bufferUnmapFile (buf);
return 0;
}
+} // namespace zypp
#include "zypp/solver/temporary/XmlNodePtr.h"
#include "zypp/solver/temporary/ChannelPtr.h"
-typedef bool (*ResolvableStoreCallback) (zypp::Resolvable::Ptr res, zypp::ResStore *store);
+#include "HelixParser.h"
-int extractHelixBuffer (const char data[], size_t len, zypp::solver::detail::Channel_Ptr channel, ResolvableStoreCallback callback, zypp::ResStore *store);
-int extractHelixFile (const std::string & filename, zypp::solver::detail::Channel_Ptr channel, ResolvableStoreCallback callback, zypp::ResStore *store);
+namespace zypp {
+
+class HelixSourceImpl;
+
+int extractHelixBuffer (const char *data, size_t len, solver::detail::Channel_Ptr channel, HelixSourceImpl *impl);
+int extractHelixFile (const std::string & filename, solver::detail::Channel_Ptr channel, HelixSourceImpl *impl);
+
+}
#endif /* HELIXEXTRACT_H */
using namespace std;
using namespace zypp::detail;
-using namespace zypp::solver::detail;
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////
- namespace detail
- {
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : HelixPackageImpl
- //
- ///////////////////////////////////////////////////////////////////
-
- /** Default ctor
- */
- HelixPackageImpl::HelixPackageImpl(
- const HelixParser & parsed
- )
- : _summary(parsed.summary),
- _description(parsed.description),
- _group(parsed.group),
- _install_only(parsed.installOnly),
- _size_package(parsed.fileSize),
- _size_installed(parsed.installedSize)
- {
- }
-
- /** Package summary */
- Label HelixPackageImpl::summary() const
- { return _summary; }
-
- /** Package description */
- Text HelixPackageImpl::description() const
- { return _description; }
-
- Text HelixPackageImpl::insnotify() const
- // metadata doesn't priovide this attribute
- { return ResObjectImplIf::insnotify(); }
-
- Text HelixPackageImpl::delnotify() const
- // metadata doesn't priovide this attribute
- { return ResObjectImplIf::delnotify(); }
-
- ByteCount HelixPackageImpl::size() const
-#warning fixme
- { return 0; }
-
- bool HelixPackageImpl::providesSources() const
- { return ResObjectImplIf::providesSources(); }
-
- Label HelixPackageImpl::instSrcLabel() const
- { return ResObjectImplIf::instSrcLabel(); }
-
- Vendor HelixPackageImpl::instSrcVendor() const
- { return ResObjectImplIf::instSrcVendor(); }
-
- /** */
- Date HelixPackageImpl::buildtime() const
- { return _buildtime; }
-
- /** */
- std::string HelixPackageImpl::buildhost() const
- { return _buildhost; }
-
- /** */
- Date HelixPackageImpl::installtime() const
- { return PackageImplIf::installtime(); }
-
- /** */
- std::string HelixPackageImpl::distribution() const
-#warning fixme
- { return string(); }
-
- /** */
- Vendor HelixPackageImpl::vendor() const
- { return _vendor; }
-
- /** */
- Label HelixPackageImpl::license() const
- { return _license; }
-
- /** */
- std::string HelixPackageImpl::packager() const
- { return _packager; }
-
- /** */
- PackageGroup HelixPackageImpl::group() const
- { return _group; }
-
- /** */
- Changelog HelixPackageImpl::changelog() const
- { return _changelog; }
-
- /** Don't ship it as class Url, because it might be
- * in fact anything but a legal Url. */
- std::string HelixPackageImpl::url() const
- { return _url; }
-
- /** */
- std::string HelixPackageImpl::os() const
- // metadata doesn't priovide this attribute
- { return PackageImplIf::os(); }
-
- /** */
- Text HelixPackageImpl::prein() const
- // metadata doesn't priovide this attribute
- { return PackageImplIf::prein(); }
-
- /** */
- Text HelixPackageImpl::postin() const
- // metadata doesn't priovide this attribute
- { return PackageImplIf::postin(); }
-
- /** */
- Text HelixPackageImpl::preun() const
- // metadata doesn't priovide this attribute
- { return PackageImplIf::preun(); }
-
- /** */
- Text HelixPackageImpl::postun() const
- // metadata doesn't priovide this attribute
- { return PackageImplIf::postun(); }
-
- /** */
- ByteCount HelixPackageImpl::sourcesize() const
-#warning fixme
- { return 0; }
-
- /** */
- ByteCount HelixPackageImpl::archivesize() const
-#warning fixme
- { return 0; }
-
- /** */
- Text HelixPackageImpl::authors() const
- { return _authors; }
-
- /** */
- Text HelixPackageImpl::filenames() const
- { return _filenames; }
-
- License HelixPackageImpl::licenseToConfirm() const
- { return _license_to_confirm; }
-
- /** */
- std::string HelixPackageImpl::type() const
- { return _type; }
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : HelixPackageImpl
+//
+///////////////////////////////////////////////////////////////////
- /** */
- std::list<std::string> HelixPackageImpl::keywords() const
- { return _keywords; }
+/** Default ctor
+*/
+HelixPackageImpl::HelixPackageImpl (const zypp::HelixParser & parsed)
+ : _summary(parsed.summary)
+ , _description()
+ , _group(parsed.section)
+ , _install_only(parsed.installOnly)
+ , _size_installed(parsed.installedSize)
+ , _size_archive(parsed.fileSize)
+{
+ _description.push_back(parsed.description);
+}
- bool HelixPackageImpl::installOnly() const
- { return _install_only; }
+/** Package summary */
+Label HelixPackageImpl::summary() const
+{ return _summary; }
- unsigned HelixPackageImpl::mediaId() const
- { return _mediaid; }
+/** Package description */
+Text HelixPackageImpl::description() const
+{ return _description; }
- CheckSum HelixPackageImpl::checksum() const
- { return _checksum; }
+PackageGroup HelixPackageImpl::group() const
+{ return _group; }
- std::list<DeltaRpm> HelixPackageImpl::deltaRpms() const
- { return _delta_rpms; }
+ByteCount HelixPackageImpl::size() const
+{ return _size_installed; }
- std::list<PatchRpm> HelixPackageImpl::patchRpms() const
- { return _patch_rpms; }
+/** */
+ByteCount HelixPackageImpl::archivesize() const
+{ return _size_archive; }
-#if 0
- /** */
- std::list<std::string> HelixPackageImpl::insnotify() const
- { return std::list<std::string>(); }
- /** */
- std::list<std::string> HelixPackageImpl::delnotify() const
- { return std::list<std::string>(); }
- /** */
- unsigned HelixPackageImpl::packageSize() const
- { return _size_package; }
- /** */
- unsigned HelixPackageImpl::archiveSize() const
- { return _size_archive; }
- /** */
- unsigned HelixPackageImpl::installedSize() const
- { return _size_installed; }
-// FIXME do not understand items below
- /** */
- bool HelixPackageImpl::providesSources() const
- {
- return false;
- }
- /** */
- std::string HelixPackageImpl::instSrcLabel() const
- {
- return "";
- }
- /** */
- std::string HelixPackageImpl::instSrcVendor() const
- {
- return "";
- }
- /** */
- unsigned HelixPackageImpl::instSrcRank() const
- {
- return 0;
- }
- /** */
- std::string HelixPackageImpl::buildhost() const
- {
- return _buildhost;
- }
- /** */
- std::string HelixPackageImpl::distribution() const
- {
- return "";
- }
- /** */
- std::string HelixPackageImpl::vendor() const
- {
- return _vendor;
- }
- /** */
- std::string HelixPackageImpl::license() const
- {
- return _license;
- }
- /** */
- std::list<std::string> HelixPackageImpl::licenseToConfirm() const
- {
- return std::list<std::string>();
- }
- /** */
- std::string HelixPackageImpl::packager() const
- {
- return _packager;
- }
- /** */
- std::string HelixPackageImpl::group() const
- {
- return _group;
- }
- /** */
- std::list<std::string> HelixPackageImpl::changelog() const
- {}
- /** */
- std::string HelixPackageImpl::url() const
- {
- return _url;
- }
- /** */
- std::string HelixPackageImpl::os() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::prein() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::postin() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::preun() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::postun() const
- {}
- /** */
- std::string HelixPackageImpl::sourcepkg() const
- { return _sourcepkg; }
- /** */
- std::list<std::string> HelixPackageImpl::authors() const
- { return _authors; }
- /** */
- std::list<std::string> HelixPackageImpl::filenames() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::recommends() const
- {}
- /** */
- std::list<std::string> HelixPackageImpl::suggests() const
- {}
- /** */
- std::string HelixPackageImpl::location() const
- {}
- /** */
- std::string HelixPackageImpl::md5sum() const
- {}
- /** */
- std::string HelixPackageImpl::externalUrl() const
- {}
- /** */
- std::list<Edition> HelixPackageImpl::patchRpmBaseVersions() const
- {}
- /** */
- unsigned HelixPackageImpl::patchRpmSize() const
- {}
- /** */
- bool HelixPackageImpl::forceInstall() const
- {}
- /** */
- std::string HelixPackageImpl::patchRpmMD5() const
- {}
- /** */
- bool HelixPackageImpl::isRemote() const
- {}
- /** */
- bool HelixPackageImpl::prefererCandidate() const
- {}
+bool HelixPackageImpl::installOnly() const
+{ return _install_only; }
-#endif
- } // namespace yum
- /////////////////////////////////////////////////////////////////
- } // namespace source
- ///////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////
- namespace detail
- { //////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : HelixPackageImpl
- //
- /** Class representing a package
- */
- class HelixPackageImpl : public zypp::detail::PackageImplIf
- {
- public:
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : HelixPackageImpl
+//
+/** Class representing a package
+*/
+class HelixPackageImpl : public detail::PackageImplIf
+{
+public:
class HelixParser;
/** Default ctor
*/
- HelixPackageImpl(
- const HelixParser & data
- );
-#if 0
+ HelixPackageImpl( const zypp::HelixParser & data );
+
/** Package summary */
virtual Label summary() const;
/** Package description */
/** */
virtual ByteCount archivesize() const;
/** */
+ virtual bool installOnly() const;
+ /** */
- protected:
+protected:
Label _summary;
Text _description;
PackageGroup _group;
+ bool _install_only;
ByteCount _size_installed;
ByteCount _size_archive;
-#endif
- };
- ///////////////////////////////////////////////////////////////////
- } // namespace detail
- /////////////////////////////////////////////////////////////////
- } // namespace solver
- ///////////////////////////////////////////////////////////////////
+
+ };
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include <ctype.h>
#include <assert.h>
#include "HelixParser.h"
+#include "HelixPackageImpl.h"
+#include "HelixSourceImpl.h"
#include "zypp/ResObject.h"
#include "zypp/CapFactory.h"
#include "zypp/base/String.h"
#include "zypp/base/Logger.h"
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
using namespace std;
+using namespace zypp;
//---------------------------------------------------------------------------
static Resolvable::Kind
string2kind (const std::string & str)
{
- Resolvable::Kind kind = ResTraits<zypp::Package>::kind;
+ Resolvable::Kind kind = ResTraits<Package>::kind;
if (!str.empty()) {
if (str == "package") {
// empty
}
else if (str == "patch") {
- kind = ResTraits<zypp::Patch>::kind;
+ kind = ResTraits<Patch>::kind;
}
else if (str == "pattern") {
- kind = ResTraits<zypp::Pattern>::kind;
+ kind = ResTraits<Pattern>::kind;
}
else if (str == "script") {
- kind = ResTraits<zypp::Script>::kind;
+ kind = ResTraits<Script>::kind;
}
else if (str == "message") {
- kind = ResTraits<zypp::Message>::kind;
+ kind = ResTraits<Message>::kind;
}
else if (str == "product") {
- kind = ResTraits<zypp::Product>::kind;
+ kind = ResTraits<Product>::kind;
}
else {
ERR << "get_resItem unknown kind '" << str << "'" << endl;
//---------------------------------------------------------------------------
static Capability
-parse_dep_attrs(bool *is_obsolete, const xmlChar **attrs)
+parse_dep_attrs(bool *is_obsolete, bool *is_pre, const xmlChar **attrs)
{
CapFactory factory;
int i;
bool op_present = false;
/* Temporary variables dependent upon the presense of an 'op' attribute */
- Resolvable::Kind dkind = ResTraits<zypp::Package>::kind; // default to package
+ Resolvable::Kind dkind = ResTraits<Package>::kind; // default to package
string dname;
int depoch = Edition::noepoch;
string dversion;
Rel relation = Rel::ANY;
*is_obsolete = false;
+ *is_pre = false;
for (i = 0; attrs[i]; i++) {
const string attr ((const char *)attrs[i++]);
else if (attr == "release") drelease = value;
else if (attr == "arch") darch = value;
else if (attr == "obsoletes") *is_obsolete = true;
+ else if (attr == "pre") if (value && *value == '1') *is_pre = true;
else {
_DBG("HelixParser") << "! Unknown attribute: " << attr << " = " << value << endl;
}
{
HelixParser *ctx = (HelixParser *)ptr;
- ctx->toBuffer (str::trim (string ((const char *)ch)));
+ ctx->toBuffer (str::trim (string ((const char *)ch, len)));
return;
}
//---------------------------------------------------------------------------
-HelixParser::HelixParser (Channel_constPtr channel)
+HelixParser::HelixParser (solver::detail::Channel_constPtr channel)
: _channel (channel)
, _processing (false)
, _xml_context (NULL)
, _state (PARSER_TOPLEVEL)
, _stored(true)
- , _toplevel_dep_list (NULL)
- , _dep_list (NULL)
+ , _dep_set (NULL)
+ , _toplevel_dep_set (NULL)
+ , _impl (NULL)
{
// _XXX("HelixParser") << "* Context created (" << this << ")" << endl;
}
// called for extracting
void
-HelixParser::parseChunk(const char *xmlbuf, size_t size, ResolvableStoreCallback callback, ResStore *store)
+HelixParser::parseChunk(const char *xmlbuf, size_t size, HelixSourceImpl *impl)
{
// _DBG("HelixParser") << "HelixParser::parseChunk(" << xmlbuf << "...," << (long)size << ")" << endl;
_xml_context = xmlCreatePushParserCtxt(&sax_handler, this, NULL, 0, NULL);
}
- _callback = callback;
- _store = store;
+ _impl = impl;
xmlParseChunk(_xml_context, xmlbuf, size, 0);
}
fileSize = 0;
installedSize = 0;
installOnly = false;
+ installed = false;
requires.clear();
provides.clear();
conflicts.clear();
freshens.clear();
enhances.clear();
- children.clear();
recommends.clear();
suggests.clear();
obsoletes.clear();
}
else if (token == "requires") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &requires;
+ _dep_set = _toplevel_dep_set = &requires;
}
else if (token == "recommends") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &recommends;
+ _dep_set = _toplevel_dep_set = &recommends;
}
else if (token == "suggests") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &suggests;
+ _dep_set = _toplevel_dep_set = &suggests;
}
else if (token == "conflicts") {
bool is_obsolete = false;
}
if (is_obsolete)
- _dep_list = _toplevel_dep_list = &obsoletes;
+ _dep_set = _toplevel_dep_set = &obsoletes;
else {
- _dep_list = _toplevel_dep_list = &conflicts;
+ _dep_set = _toplevel_dep_set = &conflicts;
}
}
else if (token == "obsoletes") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &obsoletes;
+ _dep_set = _toplevel_dep_set = &obsoletes;
}
else if (token == "provides") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &provides;
+ _dep_set = _toplevel_dep_set = &provides;
}
+#if 0 // disabled
else if (token == "children") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &children;
+ _dep_set = _toplevel_dep_set = &children;
}
+#endif
else if (token == "freshens") {
_state = PARSER_DEP;
- _dep_list = _toplevel_dep_list = &freshens;
+ _dep_set = _toplevel_dep_set = &freshens;
+ }
+ else if (token == "enhances") {
+ _state = PARSER_DEP;
+ _dep_set = _toplevel_dep_set = &enhances;
}
else {
// _XXX("HelixParser") << "! Not handling " << token << " in package start" << endl;
if (token == "dep") {
Capability dep;
bool is_obsolete;
+ bool is_pre;
- dep = parse_dep_attrs(&is_obsolete, attrs);
+ dep = parse_dep_attrs(&is_obsolete, &is_pre, attrs);
if (is_obsolete)
obsoletes.insert (dep);
+ else if (is_pre)
+ prerequires.insert (dep);
else {
- _dep_list->insert (dep);
+ _dep_set->insert (dep);
}
}
else if (token == "or")
- _dep_list->clear();
+ _dep_set->clear();
else {
_DBG("HelixParser") << "! Not handling " << token << " in dependency" << endl;
}
}
if (piter == provides.end()) { // no self provide found, construct one
- _XXX("RC_SPEW") << "Adding self-provide [" << selfdep.asString() << "]" << endl;
+// _XXX("HelixParser") << "Adding self-provide [" << selfdep.asString() << "]" << endl;
provides.insert (selfdep);
}
- Dependencies deps;
- deps.requires = requires;
- deps.provides = provides;
- deps.conflicts = conflicts;
- deps.obsoletes = obsoletes;
- deps.suggests = suggests;
- deps.recommends = recommends;
- deps.freshens = freshens;
-
-#warning Resolvable complete
-#if 0
- Package_Ptr package = new Package ( channel, kind, name, edition, arch);
+ if (_channel->system())
+ installed = true;
- if (_channel->system()) // simulate system channel by loading xml file
- package->setInstalled (true);
-#endif
+ if (_impl) {
+ _impl->parserCallback (*this);
+ }
-// _DBG("RC_SPEW") << package->asString(true) << endl;
+// _DBG("HelixParser") << package->asString(true) << endl;
// _DBG("HelixParser") << "HelixParser::resolvableEnd(" << token << ") done: '" << package->asString(true) << "'" << endl;
// _XXX("HelixParser") << "HelixParser::resolvableEnd now " << _all_packages.size() << " packages" << endl;
_stored = true;
} else if (token == "filesize") { fileSize = str::strtonum<long>(_text_buffer);
} else if (token == "installedsize") { installedSize = str::strtonum<long>(_text_buffer);
} else if (token == "install_only") { installOnly = true;
+ } else if (token == "md5sum") { // ignore
} else {
_DBG("HelixParser") << "HelixParser::resolvableEnd(" << token << ") unknown" << endl;
}
{
// _XXX("HelixParser") << "HelixParser::updateEnd(" << token << ")" << endl;
- Channel_constPtr channel;
-
if (token == "update") {
_state = PARSER_HISTORY;
} else if (token == "epoch") { epoch = str::strtonum<int>(_text_buffer);
if (token == "or") {
#if 0
- OrDependency_Ptr or_dep = OrDependency::fromDependencyList (*_dep_list);
+ OrDependency_Ptr or_dep = OrDependency::fromDependencyList (*_dep_set);
Dependency_Ptr dep = new Dependency (or_dep);
- (*_dep_list).clear();
+ (*_dep_set).clear();
- (*_toplevel_dep_list).push_back (dep);
- _dep_list = _toplevel_dep_list;
+ (*_toplevel_dep_set).push_back (dep);
+ _dep_set = _toplevel_dep_set;
#endif
}
else if (token == "dep") {
}
else {
/* All of the dep lists (requires, provides, etc.) */
- _toplevel_dep_list = NULL;
- _dep_list = NULL;
+ _toplevel_dep_set = NULL;
+ _dep_set = NULL;
_state = PARSER_RESOLVABLE;
}
}
-
-///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
#include <list>
#include "zypp/CapSet.h"
-
-#include "HelixExtract.h"
+#include "zypp/ResStore.h"
+#include "zypp/Dependencies.h"
#include "zypp/solver/temporary/Channel.h"
#include "zypp/solver/temporary/XmlNode.h"
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
+namespace zypp {
+
+class HelixParser;
+class HelixSourceImpl;
+typedef bool (*ParserCallback) (const HelixParser & parsed, HelixSourceImpl *impl);
+
///////////////////////////////////////////////////////////////////
//
typedef enum _HelixParserState HelixParserState;
private:
- Channel_constPtr _channel;
+ solver::detail::Channel_constPtr _channel;
bool _processing;
xmlParserCtxtPtr _xml_context;
HelixParserState _state;
int fileSize;
int installedSize;
bool installOnly;
+ bool installed;
- CapSet requires;
CapSet provides;
+ CapSet prerequires;
+ CapSet requires;
CapSet conflicts;
- CapSet children;
+ CapSet obsoletes;
CapSet recommends;
CapSet suggests;
- CapSet obsoletes;
CapSet freshens;
CapSet enhances;
private:
- // these point to one of the above lists during dependency parsing
- CapSet *_toplevel_dep_list;
- CapSet *_dep_list;
+ // these point to one of the Dependency sets during dependency parsing
+ CapSet *_dep_set;
+ CapSet *_toplevel_dep_set; // just needed during 'or' parsing
std::string _text_buffer;
public:
- HelixParser (Channel_constPtr channel);
+ HelixParser (solver::detail::Channel_constPtr channel);
virtual ~HelixParser();
// ---------------------------------- I/O
void startElement(const std::string & token, const xmlChar **attrs);
void endElement(const std::string & token);
- void parseChunk (const char *xmlbuf, size_t size, ResolvableStoreCallback callback, ResStore *store);
+ void parseChunk (const char *xmlbuf, size_t size, HelixSourceImpl *impl);
void done (void);
private:
- ResolvableStoreCallback _callback;
- ResStore *_store;
+ HelixSourceImpl *_impl;
// internal HelixParser functions, c++-style
void toplevelStart(const std::string & token, const xmlChar **attrs);
};
-///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+} // namespace zypp
#endif // ZYPP_SOLVER_TEMPORARY_HELIXPARSER_H
* 02111-1307, USA.
*/
+#include "HelixExtract.h"
#include "HelixSourceImpl.h"
+#include "HelixPackageImpl.h"
+
#include "zypp/solver/temporary/Channel.h"
#include "zypp/solver/temporary/extract.h"
#include "zypp/base/Logger.h"
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
using namespace std;
+using namespace zypp;
//---------------------------------------------------------------------------
load (path_r.asString());
}
+Dependencies
+HelixSourceImpl::createDependencies (const HelixParser & parsed)
+{
+ Dependencies deps;
+
+ deps.provides = parsed.provides;
+ deps.prerequires = parsed.prerequires;
+ deps.requires = parsed.requires;
+ deps.conflicts = parsed.conflicts;
+ deps.obsoletes = parsed.obsoletes;
+ deps.recommends = parsed.recommends;
+ deps.suggests = parsed.suggests;
+ deps.freshens = parsed.freshens;
+ deps.enhances = parsed.enhances;
+
+ return deps;
+}
-//---------------------------------------------------------------------------
+Package::Ptr
+HelixSourceImpl::createPackage (const HelixParser & parsed)
+{
+ try
+ {
+ shared_ptr<HelixPackageImpl> impl(new HelixPackageImpl(parsed));
+
+ // Collect basic Resolvable data
+ NVRAD dataCollect( parsed.name,
+ Edition( parsed.version, parsed.release, parsed.epoch ),
+ Arch( parsed.arch ),
+ createDependencies (parsed));
+ Package::Ptr package = detail::makeResolvableFromImpl(dataCollect, impl);
+ return package;
+ }
+ catch (const Exception & excpt_r)
+ {
+ ERR << excpt_r << endl;
+ throw "Cannot create package object";
+ }
+ return NULL;
+}
-static bool
-add_resolvable_cb (Resolvable::Ptr res, ResStore *store)
+Message::Ptr
+HelixSourceImpl::createMessage (const HelixParser & data)
{
-#if 0
- HelixSourceImpl *undump = (HelixSourceImpl *)data;
+ return NULL;
+}
+
+
+Script::Ptr
+HelixSourceImpl::createScript (const HelixParser & data)
+{
+ return NULL;
+}
- undump->addResItem (res);
-#else
- MIL << "add_resItem_cb()" << endl;
-#endif
- return true;
+Patch::Ptr
+HelixSourceImpl::createPatch (const HelixParser & data)
+{
+ return NULL;
}
+Pattern::Ptr
+HelixSourceImpl::createPattern (const HelixParser & data)
+{
+ return NULL;
+}
+
+
+Product::Ptr
+HelixSourceImpl::createProduct (const HelixParser & data)
+{
+ return NULL;
+}
+
+//-----------------------------------------------------------------------------
+
+void
+HelixSourceImpl::parserCallback (const HelixParser & data)
+{
+ if (data.kind == ResTraits<Package>::kind) {
+ Package::Ptr p = createPackage (data);
+ _store.insert (p);
+ }
+}
+
//-----------------------------------------------------------------------------
void
HelixSourceImpl::load (const string & filename)
{
if (!filename.empty()) {
- Channel_Ptr channel = new Channel ("test", "test", "test", "test");
- channel->setType (CHANNEL_TYPE_HELIX);
+ solver::detail::Channel_Ptr channel = new solver::detail::Channel ("test", "test", "test", "test");
+ channel->setType (solver::detail::CHANNEL_TYPE_HELIX);
// channel->setSystem (true);
- extractHelixFile (filename, channel, add_resolvable_cb, &_store);
+ extractHelixFile (filename, channel, this);
}
}
-
-
-///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
#include "zypp/Selection.h"
#include "zypp/Pattern.h"
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
+namespace zypp {
///////////////////////////////////////////////////////////////////
//
/** Default ctor */
HelixSourceImpl(media::MediaAccess::Ptr & media_r, const Pathname & path_r = "/");
+ Package::Ptr createPackage (const HelixParser & data);
+ Message::Ptr createMessage (const HelixParser & data);
+ Script::Ptr createScript (const HelixParser & data);
+ Patch::Ptr createPatch (const HelixParser & data);
+ Pattern::Ptr createPattern (const HelixParser & data);
+ Product::Ptr createProduct (const HelixParser & data);
+
+
+ Dependencies createDependencies (const HelixParser & data);
+
+ void parserCallback (const HelixParser & data);
};
-///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
+
+
+} // namespace zypp
#endif // ZYPP_SOLVER_TEMPORARY_HELIXSOURCEIMPL_H
Buffer.cc \
HelixExtract.cc \
HelixParser.cc \
- HelixSourceImpl.cc
-
-# HelixPackageImpl.cc
+ HelixSourceImpl.cc \
+ HelixPackageImpl.cc
<channel><subchannel>
<package>
- <name>unfulfilled</name>
+ <name>Package1</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
</update>
</history>
<provides>
- <dep name="x" op="(any)" version="1.0"/>
+ <dep name="x"/>
</provides>
<requires>
<dep name="nothere"/>
</requires>
</package>
<package>
- <name>A</name>
+ <name>Package2</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
</update>
</history>
<requires>
- <dep name="b" op="(any)" version="1.0"/>
+ <dep name="b" op="=" version="1.0"/>
</requires>
<provides>
- <dep name="a" op="(any)" version="1.0"/>
+ <dep name="a" op="=" version="1.0"/>
</provides>
</package>
<package>
- <name>B</name>
+ <name>Package3</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
</update>
</history>
<requires>
- <dep name="c" op="(any)" version="1.0"/>
+ <dep name="c" op="<" version="1.0"/>
</requires>
<provides>
- <dep name="b" op="(any)" version="1.0"/>
+ <dep name="b" op=">=" version="1.0"/>
</provides>
<conflicts>
- <dep name="e" op="(any)" version="1.0"/>
+ <dep name="e" op="!=" version="1.0"/>
</conflicts>
</package>
<package>
- <name>C</name>
+ <name>Package4</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
</update>
</history>
<provides>
- <dep name="c" op="(any)" version="1.0"/>
+ <dep name="c" op="<=" version="1.0"/>
</provides>
</package>
<package>
- <name>D</name>
+ <name>Package5</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
</update>
</history>
<provides>
- <dep name="d" op="(any)" version="1.0"/>
- <dep name="c" op="(any)" version="1.0"/>
+ <dep name="d" op="==" version="1.0"/>
+ <dep name="c"/>
</provides>
</package>
<package>
- <name>E</name>
+ <name>Package6</name>
<summary>A fake package</summary>
<description>A fake package</description>
<section>misc</section>
<description>Yggdrasil Linux</description>
</update>
</history>
- <provides>
- <dep name="c" op="(any)" version="1.0"/>
- <dep name="e" op="(any)" version="1.0"/>
- <dep name="x" op="(any)" version="1.0"/>
- </provides>
</package>
</subchannel></channel>
Pathname p = argv[1];
media::MediaAccess::Ptr media = new media::MediaAccess();
- Source::Impl_Ptr impl = new solver::detail::HelixSourceImpl (media, p);
+ Source::Impl_Ptr impl = new HelixSourceImpl (media, p);
SourceFactory _f;
Source s = _f.createFrom( impl );
ResStore store = s.resolvables();