#include <zypp/Message.h>
#include <zypp/detail/MessageImpl.h>
#include <zypp/detail/PatchImpl.h>
+#include <zypp/Patch.h>
#include <zypp/Package.h>
#include <zypp/detail/PackageImpl.h>
#include <zypp/Script.h>
#include <zypp/source/yum/YUMScriptImpl.h>
#include <zypp/source/yum/YUMMessageImpl.h>
#include <zypp/source/yum/YUMPackageImpl.h>
-
+#include <zypp/source/yum/YUMSource.h>
#include <map>
#include <set>
using namespace std;
using namespace zypp;
-using namespace zypp::parser::YUM;
-using namespace zypp::source::YUM;
-
-
-CapFactory _f;
+using namespace zypp::parser::yum;
+using namespace zypp::source::yum;
-void AddDependency (detail::ResolvableImplPtr res, Capability& cap) {
- Dependencies deps = res->deps();
- CapSet req = deps.requires();
- req.insert( cap );
- deps.setRequires( req );
- res->setDeps( deps );
-}
-
-void AddAllRequires( detail::ResolvableImplPtr res, list<Capability> & caps) {
- for (list<Capability>::iterator it = caps.begin();
- it != caps.end();
- it++)
- {
- AddDependency( res, *it );
- }
-}
-DEFINE_PTR_TYPE(MyPatchImpl)
-
-class MyPatchImpl : public detail::PatchImpl
-{
- public:
- MyPatchImpl( YUMPatchData & p )
- : PatchImpl (p.name,
- Edition (),
- Arch ("noarch"))
- {
- // Create a requires capability to the patch itself
- Capability cap( _f.parse( p.name, ResKind( "patch" )));
-
- // Process atoms
- detail::PatchImpl::AtomList atoms;
-
- for (std::list<YUMPatchAtom>::iterator it = p.atoms.begin();
- it != p.atoms.end();
- it++)
- {
- if (it->type == "script")
- {
- ScriptImplPtr impl = new YUMScriptImpl( *it->script );
- AddDependency(impl, cap);
- ScriptPtr script = new Script(impl);
- cout << *script << endl;
- cout << script->deps() << endl;
- atoms.push_back(script);
- }
- else if (it->type == "message")
- {
- MessageImplPtr impl = new YUMMessageImpl( *it->message );
- AddDependency(impl, cap);
- MessagePtr message = new Message(impl);
- cout << *message << endl;
- cout << message->deps() << endl;
- atoms.push_back(message);
- }
- else if (it->type == "package")
- {
- PackageImplPtr impl = new YUMPackageImpl( *it->package );
- AddDependency(impl, cap);
- PackagePtr package = new Package(impl);
- cout << *package << endl;
- cout << package->deps() << endl;
- atoms.push_back(package);
- }
- }
-
- // FIXME mve this piece of code after solutions are selected
+ // FIXME me this piece of code after solutions are selected
// this orders the atoms of a patch
- ResolvablePtr previous;
+/*
+ Resolvable::Ptr previous;
bool first = true;
for (detail::PatchImpl::AtomList::iterator it = atoms.begin();
it != atoms.end();
first = false;
previous = *it;
}
-
- _reboot_needed = false; // FIXME
- _atoms = atoms;
- _category = "recommended"; // FIXME
- }
-};
-
-IMPL_PTR_TYPE(MyPatchImpl)
-
+*/
/******************************************************************
**
{
INT << "===[START]==========================================" << endl;
-PatchPtr patch1;
+YUMSource src;
+Patch::Ptr patch1;
YUMPatchParser iter(cin,"");
for (;
!iter.atEnd();
++iter) {
- MyPatchImplPtr q(new MyPatchImpl(**iter));
- patch1 = new Patch (q);
+ patch1 = src.createPatch(**iter);
}
if (iter.errorStatus())
throw *iter.errorStatus();
using namespace zypp;
using namespace zypp::parser;
-using namespace zypp::parser::YUM;
+using namespace zypp::parser::yum;
using namespace std;
namespace {
<< " affects package manager: " << data.packageManager << endl
<< " update script: " << data.updateScript << endl
<< " atoms:" << endl
-/* for (std::list<shared_ptr<YUMPatchAtom> >::const_iterator it = data.atoms.begin();
- it != data.atoms.end();
- it++)
- {
- out << *it;
- }*/
-// FIXME here
<< data.atoms;
return out;
}
std::ostream& operator<<(std::ostream& out, const shared_ptr<YUMPatchAtom> data)
{
out << "Atom data" << endl;
-// out << " atom type: " << data->atomType() << endl;
switch (data->atomType())
{
case YUMPatchAtom::Package:
## ##################################################
-include_HEADERS = \
- YUMScriptImpl.h \
+include_HEADERS = \
+ YUMSource.h \
+ YUMScriptImpl.h \
YUMMessageImpl.h \
- YUMPackageImpl.h
+ YUMPackageImpl.h \
+ YUMPatchImpl.h
noinst_LTLIBRARIES = lib@PACKAGE@_source_yum.la
## ##################################################
lib@PACKAGE@_source_yum_la_SOURCES = \
+ YUMSource.cc \
YUMScriptImpl.cc \
YUMMessageImpl.cc \
- YUMPackageImpl.cc
+ YUMPackageImpl.cc \
+ YUMPatchImpl.cc
## ##################################################
YUMMessageImpl::YUMMessageImpl(
const zypp::parser::yum::YUMPatchMessage & parsed
)
-#warning MA cannot be constructed that way
-#if 0
- : MessageImpl(
- parsed.name,
- Edition(parsed.ver, parsed.rel, strtol(parsed.epoch.c_str(), NULL, 10)),
- Arch("noarch")
- )
-#endif
{
_text = parsed.text;
-/*
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> freshen;
- std::list<YUMDependency> requires;
-*/
}
} // namespace yum
/////////////////////////////////////////////////////////////////
//
// CLASS NAME : YUMMessageImpl
//
- /** Class representing an update script
- * \todo Fix brief descriptions, or delete them. This is not an update
- * script, It's implementation of zypp::Message for YUM source.
+ /** Class representing a message
*/
class YUMMessageImpl : public detail::MessageImpl
{
public:
/** Default ctor */
YUMMessageImpl( const zypp::parser::yum::YUMPatchMessage & parsed );
- };
+ };
///////////////////////////////////////////////////////////////////
} // namespace yum
/////////////////////////////////////////////////////////////////
YUMPackageImpl::YUMPackageImpl(
const zypp::parser::yum::YUMPatchPackage & parsed
)
-#warning MA cannot be constructed that way
-#if 0
- : PackageImpl(
- parsed.name,
- Edition(parsed.ver, parsed.rel, strtol(parsed.epoch.c_str(), NULL, 10)),
- Arch(parsed.arch)
- )
-#endif
{
/*
std::string type;
std::string sourcerpm;
std::string headerStart;
std::string headerEnd;
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> requires;
std::list<FileData> files;
// SuSE specific data
std::list<std::string> authors;
std::list<std::string> keywords;
std::string media;
std::list<YUMDirSize> dirSizes;
- std::list<YUMDependency> freshen;
bool installOnly;
// Change Log
std::list<ChangelogEntry> changelog;
//
// CLASS NAME : YUMPackageImpl
//
- /** Class representing an update script
- *
- * \todo Fix brief descriptions, or delete them. This is not an update
- * script, It's implementation of zypp::Package for YUM source.
+ /** Class representing a package
*
* \todo Deriving from detail::PackageImpl is useless here. PackageImpl
* is dumb, i.e. it provides nothing, but the dtor needed to instanciate
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/yum/YUMPatchImpl.cc
+ *
+*/
+
+#include "zypp/source/yum/YUMPatchImpl.h"
+#include "zypp/source/yum/YUMSource.h"
+#include <zypp/CapFactory.h>
+#include "zypp/parser/yum/YUMParserData.h"
+#include <zypp/parser/yum/YUMParser.h>
+#include "zypp/Package.h"
+#include "zypp/Script.h"
+#include "zypp/Message.h"
+#include "zypp/base/Logger.h"
+
+
+using namespace std;
+using namespace zypp::detail;
+using namespace zypp::parser::yum;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace yum
+ {
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : YUMPatchImpl
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ /** Default ctor
+ * \bug CANT BE CONSTUCTED THAT WAY ANYMORE
+ */
+ YUMPatchImpl::YUMPatchImpl(
+ const zypp::parser::yum::YUMPatchData & parsed,
+ YUMSource * src
+ )
+ {
+ CapFactory _f;
+ Capability cap( _f.parse(
+ Resolvable::Kind("Patch"),
+ parsed.name,
+ Edition(),
+ Arch("noarch")));
+
+ for (std::list<shared_ptr<YUMPatchAtom> >::const_iterator it
+ = parsed.atoms.begin();
+ it != parsed.atoms.end();
+ it++)
+ {
+ switch ((*it)->atomType())
+ {
+ case YUMPatchAtom::Package: {
+ shared_ptr<YUMPatchPackage> package_data
+ = dynamic_pointer_cast<YUMPatchPackage>(*it);
+ Package::Ptr package = src->createPackage(*package_data);
+ _atoms.push_back(package);
+ break;
+ }
+ case YUMPatchAtom::Message: {
+ shared_ptr<YUMPatchMessage> message_data
+ = dynamic_pointer_cast<YUMPatchMessage>(*it);
+ Message::Ptr message = src->createMessage(*message_data);
+ _atoms.push_back(message);
+ break;
+ }
+ case YUMPatchAtom::Script: {
+ shared_ptr<YUMPatchScript> script_data
+ = dynamic_pointer_cast<YUMPatchScript>(*it);
+ Script::Ptr script = src->createScript(*script_data);
+ _atoms.push_back(script);
+ break;
+ }
+ default:
+ ERR << "Unknown type of atom" << endl;
+ }
+ for (AtomList::iterator it = _atoms.begin();
+ it != _atoms.end();
+ it++)
+ {
+ Dependencies _deps = (*it)->deps();
+ CapSet _req = _deps.requires();
+ _req.insert(cap);
+ _deps.setRequires(_req);
+ (*it)->setDeps(_deps);
+ }
+
+ }
+ }
+
+
+ } // namespace yum
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/yum/YUMPatchImpl.h
+ *
+*/
+#ifndef ZYPP_SOURCE_YUM_YUMPATCHIMPL_H
+#define ZYPP_SOURCE_YUM_YUMPATCHIMPL_H
+
+#include "zypp/detail/PatchImpl.h"
+#include "zypp/parser/yum/YUMParserData.h"
+#include "zypp/source/yum/YUMSource.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace yum
+ { //////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : YUMPatchImpl
+ //
+ /** Class representing a patch
+ */
+ class YUMPatchImpl : public detail::PatchImpl
+ {
+ public:
+ /** Default ctor */
+ YUMPatchImpl(
+ const zypp::parser::yum::YUMPatchData & parsed,
+ YUMSource * src
+ );
+ };
+ ///////////////////////////////////////////////////////////////////
+ } // namespace yum
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_YUM_YUMPATCHIMPL_H
*/
#include "zypp/source/yum/YUMScriptImpl.h"
+#include "zypp/Arch.h"
+#include "zypp/Edition.h"
+#include <zypp/detail/ResObjectFactory.h>
+
using namespace std;
using namespace zypp::detail;
YUMScriptImpl::YUMScriptImpl(
const zypp::parser::yum::YUMPatchScript & parsed
)
-#warning MA: CANT BE CONSTUCTED THAT WAY ANYMORE
-#if 0
- : ScriptImpl(
- parsed.name,
- Edition(parsed.ver, parsed.rel, strtol(parsed.epoch.c_str(), NULL, 10)),
- Arch("noarch")
-
- )
-#endif
{
_do_script = parsed.do_script;
_undo_script = parsed.undo_script;
-/*
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> freshen;
- std::list<YUMDependency> requires;
-
-
-*/
}
} // namespace yum
/////////////////////////////////////////////////////////////////
public:
/** Default ctor */
YUMScriptImpl( const zypp::parser::yum::YUMPatchScript & parsed );
- };
+ };
///////////////////////////////////////////////////////////////////
} // namespace yum
/////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/yum/YUMSource.cc
+ *
+*/
+
+#include "zypp/source/yum/YUMSource.h"
+#include "zypp/source/yum/YUMPackageImpl.h"
+#include "zypp/source/yum/YUMScriptImpl.h"
+#include "zypp/source/yum/YUMMessageImpl.h"
+#include "zypp/source/yum/YUMPatchImpl.h"
+
+#include <zypp/CapFactory.h>
+
+using namespace std;
+using namespace zypp::detail;
+using namespace zypp::parser::yum;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace yum
+ {
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : YUMSource
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ /** Default ctor
+ */
+ YUMSource::YUMSource()
+ {}
+
+
+ Package::Ptr YUMSource::createPackage(
+ const zypp::parser::yum::YUMPatchPackage & parsed
+ )
+ {
+ shared_ptr<YUMPackageImpl> impl(new YUMPackageImpl(parsed));
+ Dependencies _deps = createDependencies(parsed);
+ Package::Ptr package = detail::makeResolvableFromImpl(
+ parsed.name,
+ Edition( parsed.ver, parsed.rel ),
+ Arch( parsed.arch ),
+ impl
+ );
+ package->setDeps(_deps);
+ return package;
+ }
+ Message::Ptr YUMSource::createMessage(
+ const zypp::parser::yum::YUMPatchMessage & parsed
+ )
+ {
+ shared_ptr<YUMMessageImpl> impl(new YUMMessageImpl(parsed));
+ Dependencies _deps = createDependencies(parsed);
+ Message::Ptr message = detail::makeResolvableFromImpl(
+ parsed.name,
+ Edition( parsed.ver, parsed.rel ),
+ Arch( "noarch" ),
+ impl
+ );
+ message->setDeps(_deps);
+ return message;
+ }
+
+ Script::Ptr YUMSource::createScript(
+ const zypp::parser::yum::YUMPatchScript & parsed
+ )
+ {
+ shared_ptr<YUMScriptImpl> impl(new YUMScriptImpl(parsed));
+ Dependencies _deps = createDependencies(parsed);
+ Script::Ptr script = detail::makeResolvableFromImpl(
+ parsed.name,
+ Edition( parsed.ver, parsed.rel ),
+ Arch( "noarch" ),
+ impl
+ );
+ script->setDeps(_deps);
+ return script;
+ }
+
+ Patch::Ptr YUMSource::createPatch(
+ const zypp::parser::yum::YUMPatchData & parsed
+ )
+ {
+ shared_ptr<YUMPatchImpl> impl(new YUMPatchImpl(parsed, this));
+// Dependencies _deps = createDependencies(parsed);
+ Patch::Ptr patch = detail::makeResolvableFromImpl(
+ parsed.name,
+ Edition( parsed.ver, parsed.rel ),
+ Arch( "noarch" ),
+ impl
+ );
+// patch->setDeps(_deps);
+ return patch;
+ }
+
+ Dependencies YUMSource::createDependencies(
+ const zypp::parser::yum::YUMPatchAtom & parsed
+ )
+ {
+ CapFactory _f;
+ CapSet _provides;
+ CapSet _conflicts;
+ CapSet _obsoletes;
+ CapSet _freshens;
+ CapSet _requires;
+ CapSet _prerequires;
+ Dependencies _deps;
+ for (std::list<YUMDependency>::const_iterator it = parsed.provides.begin();
+ it != parsed.provides.end();
+ it++)
+ {
+ // FIXME do not create the string this way
+ // FIXME other types than only packages
+ // FIXME use also the flags
+ _provides.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ }
+
+ for (std::list<YUMDependency>::const_iterator it = parsed.conflicts.begin();
+ it != parsed.conflicts.end();
+ it++)
+ {
+ // FIXME do not create the string this way
+ // FIXME other types than only packages
+ // FIXME use also the flags
+ _conflicts.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ }
+
+ for (std::list<YUMDependency>::const_iterator it = parsed.obsoletes.begin();
+ it != parsed.obsoletes.end();
+ it++)
+ {
+ // FIXME do not create the string this way
+ // FIXME other types than only packages
+ // FIXME use also the flags
+ _obsoletes.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ }
+
+ for (std::list<YUMDependency>::const_iterator it = parsed.freshen.begin();
+ it != parsed.freshen.end();
+ it++)
+ {
+ // FIXME do not create the string this way
+ // FIXME other types than only packages
+ // FIXME use also the flags
+ _freshens.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ }
+
+ for (std::list<YUMDependency>::const_iterator it = parsed.requires.begin();
+ it != parsed.requires.end();
+ it++)
+ {
+ // FIXME do not create the string this way
+ // FIXME other types than only packages
+ // FIXME use also the flags
+ if (it->pre == "1")
+ _prerequires.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ else
+ _requires.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+ }
+
+ _deps.setProvides(_provides);
+ _deps.setConflicts(_conflicts);
+ _deps.setObsoletes(_obsoletes);
+ _deps.setFreshens(_freshens);
+ _deps.setRequires(_requires);
+ _deps.setPrerequires(_prerequires);
+ return _deps;
+ }
+
+
+
+
+ } // namespace yum
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/yum/YUMSource.h
+ *
+*/
+#ifndef ZYPP_SOURCE_YUM_YUMSOURCE_H
+#define ZYPP_SOURCE_YUM_YUMSOURCE_H
+
+#include "zypp/source/Source.h"
+#include "zypp/parser/yum/YUMParserData.h"
+#include "zypp/Package.h"
+#include "zypp/Message.h"
+#include "zypp/Script.h"
+#include "zypp/Patch.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+ namespace yum
+ { //////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : YUMSource
+ //
+ /** Class representing a YUM installation source
+ */
+ class YUMSource : public source::Source
+ {
+ public:
+ /** Default ctor */
+ YUMSource();
+
+ Package::Ptr createPackage(
+ const zypp::parser::yum::YUMPatchPackage & parsed
+ );
+ Message::Ptr createMessage(
+ const zypp::parser::yum::YUMPatchMessage & parsed
+ );
+ Script::Ptr createScript(
+ const zypp::parser::yum::YUMPatchScript & parsed
+ );
+ Patch::Ptr createPatch(
+ const zypp::parser::yum::YUMPatchData & parsed
+ );
+
+
+ Dependencies createDependencies(
+ const zypp::parser::yum::YUMPatchAtom & parsed
+ );
+
+
+
+ };
+ ///////////////////////////////////////////////////////////////////
+ } // namespace yum
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_YUM_YUMSOURCE_H