added frist draft of YUMScriptImpl
authorJiri Srain <jsrain@suse.cz>
Wed, 16 Nov 2005 13:15:40 +0000 (13:15 +0000)
committerJiri Srain <jsrain@suse.cz>
Wed, 16 Nov 2005 13:15:40 +0000 (13:15 +0000)
fixed library linking

13 files changed:
configure.ac
test/Makefile.am
test/devel.jsrain/Makefile.am
test/devel.jsrain/PatchRead.cc
test/devel.ma/Makefile.am
zypp/Makefile.am
zypp/parser/Makefile.am
zypp/source/Makefile.am [new file with mode: 0644]
zypp/source/Source.cc [new file with mode: 0644]
zypp/source/Source.h [new file with mode: 0644]
zypp/source/yum/Makefile.am [new file with mode: 0644]
zypp/source/yum/YUMScriptImpl.cc [new file with mode: 0644]
zypp/source/yum/YUMScriptImpl.h [new file with mode: 0644]

index 4623858..7e3d9e0 100644 (file)
@@ -109,7 +109,9 @@ AC_OUTPUT(  \
        zypp/capability/Makefile        \
        zypp/parser/Makefile            \
        zypp/parser/yum/Makefile        \
-       zypp/parser/yum/schema/Makefile
+       zypp/parser/yum/schema/Makefile \
+       zypp/source/Makefile            \
+       zypp/source/yum/Makefile
 )
 dnl ==================================================
 
index add4e92..fba280c 100644 (file)
@@ -11,7 +11,7 @@ noinst_PROGRAMS = Example.createResolvable
 
 ## ##################################################
 
-LDADD =        $(top_srcdir)/zypp/lib@PACKAGE@.la /usr/lib/libxml2.a /usr/lib/libz.a
+LDADD =        $(top_srcdir)/zypp/lib@PACKAGE@.la
 
 ## ##################################################
 
index ffd3d7b..45f1784 100644 (file)
@@ -14,7 +14,7 @@ AM_LDFLAGS =
 
 AM_CXXFLAGS =  -pg
 
-LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la  /usr/lib/libxml2.a /usr/lib/libz.a
+LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la
 
 ## ##################################################
 
index 5fae299..633efb1 100644 (file)
 #include <zypp/Capability.h>
 #include <zypp/capability/CapabilityImpl.h>
 
+#include <zypp/parser/yum/YUMParser.h>
+#include <zypp/base/Logger.h>
+#include <zypp/source/yum/YUMScriptImpl.h>
+
 
 #include <map>
 #include <set>
 
 #include <zypp/CapFactory.h>
 
+using namespace zypp::detail;
+
 using namespace std;
 using namespace zypp;
+using namespace zypp::parser::YUM;
+using namespace zypp::source::YUM;
 
-class PACKAGE {
-  public:
-    string name;
-    string version;
-    string release;
-    string arch;
-    list<Capability> requires;
-};
-
-class MESSAGE {
-  public:
-    string name;
-    string type;
-    string text;
-};
-
-class SCRIPT {
-  public:
-    string name;
-    string do_script;
-    string undo_script;
-};
-
-class PATCH {
-  public:
-    string name;
-    list<PACKAGE> pack;
-    list<MESSAGE> msg;
-    list<SCRIPT> scr;
-};
 
 CapFactory _f;
 
@@ -72,21 +50,6 @@ class MyMessageImpl : public detail::MessageImpl
 };
 IMPL_PTR_TYPE(MyMessageImpl)
 
-DEFINE_PTR_TYPE(MyScriptImpl)
-class MyScriptImpl : public detail::ScriptImpl
-{
-  public:
-    MyScriptImpl (string name, std::string do_script, std::string undo_script = "") 
-    : ScriptImpl (name,
-                 Edition (),
-                 Arch ("noarch"))
-    {
-      _do_script = do_script;
-      _undo_script = undo_script;
-    }
-};
-IMPL_PTR_TYPE(MyScriptImpl)
-
 void AddDependency (detail::ResolvableImplPtr res, Capability& cap) {
   Dependencies deps = res->deps();
   CapSet req = deps.requires();
@@ -109,7 +72,7 @@ DEFINE_PTR_TYPE(MyPatchImpl)
 class MyPatchImpl : public detail::PatchImpl
 {
   public:
-    MyPatchImpl( PATCH & p )
+    MyPatchImpl( YUMPatchData & p )
     : PatchImpl (p.name,
                 Edition (),
                 Arch ("noarch"))
@@ -119,7 +82,23 @@ class MyPatchImpl : public detail::PatchImpl
 
       // Process atoms
       atom_list atoms;
-      for (list<PACKAGE>::iterator it = p.pack.begin();
+
+      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);
+       }
+      }
+
+/*      for (list<PACKAGE>::iterator it = p.pack.begin();
            it != p.pack.end();
            it++)
       {
@@ -148,21 +127,7 @@ class MyPatchImpl : public detail::PatchImpl
        DBG << p->deps() << endl;
        atoms.push_back( p );
       }
-      for (list<SCRIPT>::iterator it = p.scr.begin();
-           it != p.scr.end();
-           it++)
-      {
-       detail::ScriptImplPtr pi( new MyScriptImpl(
-         it->name,
-         it->do_script,
-         it->undo_script));
-       AddDependency( pi, cap );
-       ScriptPtr p( new Script( pi ));
-       DBG << *p << endl;
-       DBG << p->deps() << endl;
-       atoms.push_back( p );
-      }
-
+*/
       // FIXME mve this piece of code after solutions are selected
       // this orders the atoms of a patch
       ResolvablePtr previous;
@@ -205,7 +170,7 @@ int main( int argc, char * argv[] )
   INT << "===[START]==========================================" << endl;
 
 // filling structures
-
+/*
 PACKAGE foo;
 foo.name = "foo";
 foo.version = "3.0";
@@ -250,11 +215,21 @@ ptch.name = "patch";
 ptch.pack = pkgs;
 ptch.msg = msgs;
 ptch.scr = scrs;
+*/
+PatchPtr patch1;
+YUMPatchParser iter(cin,"");
+for (;
+     !iter.atEnd();
+     ++iter) {
+       MyPatchImplPtr q(new MyPatchImpl(**iter));
+       patch1 = new Patch (q);
+     }
+if (iter.errorStatus())
+  throw *iter.errorStatus();
 
-// process the patch
 
-MyPatchImplPtr q (new MyPatchImpl (ptch));
-PatchPtr patch1 (new Patch (q));
+
+// process the patch
 
 DBG << patch1 << endl;
 DBG << *patch1 << endl;
index dd8b7b4..bcfa335 100644 (file)
@@ -11,7 +11,7 @@ AM_LDFLAGS =
 
 AM_CXXFLAGS =  -pg
 
-LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la  /usr/lib/libxml2.a /usr/lib/libz.a
+LDADD =                $(top_srcdir)/zypp/lib@PACKAGE@.la
 
 ## ##################################################
 
index f478c5c..40247ff 100644 (file)
@@ -51,6 +51,6 @@ lib@PACKAGE@_la_LIBADD =        base/lib@PACKAGE@_base.la     \
                                detail/lib@PACKAGE@_detail.la   \
                                capability/lib@PACKAGE@_capability.la   \
                                parser/lib@PACKAGE@_parser.la   \
-                               parser/yum/lib@PACKAGE@_parser_yum.la
+                               source/lib@PACKAGE@_source.la
 
 ## ##################################################
index cf39769..4a29ecf 100644 (file)
@@ -20,4 +20,8 @@ lib@PACKAGE@_parser_la_SOURCES = \
        XMLNodeIterator.cc      \
        LibXMLHelper.cc
 
+lib@PACKAGE@_parser_la_LIBADD =        yum/lib@PACKAGE@_parser_yum.la  \
+                               -lxml2          \
+                               -lz
+
 ## ##################################################
diff --git a/zypp/source/Makefile.am b/zypp/source/Makefile.am
new file mode 100644 (file)
index 0000000..70f87fb
--- /dev/null
@@ -0,0 +1,21 @@
+## Process this file with automake to produce Makefile.in
+## ##################################################
+
+SUBDIRS = yum
+
+## ##################################################
+
+include_HEADERS =      \
+       Source.h
+
+
+noinst_LTLIBRARIES =   lib@PACKAGE@_source.la
+
+## ##################################################
+
+lib@PACKAGE@_source_la_SOURCES =       \
+       Source.cc
+
+lib@PACKAGE@_source_la_LIBADD =        yum/lib@PACKAGE@_source_yum.la
+
+## ##################################################
diff --git a/zypp/source/Source.cc b/zypp/source/Source.cc
new file mode 100644 (file)
index 0000000..99232ae
--- /dev/null
@@ -0,0 +1,31 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/ResolvableImpl.cc
+ *
+*/
+#include <iostream>
+
+#include "zypp/source/Source.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace source
+  { /////////////////////////////////////////////////////////////////
+    IMPL_PTR_TYPE(Source)
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace detail
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/source/Source.h b/zypp/source/Source.h
new file mode 100644 (file)
index 0000000..90b1237
--- /dev/null
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/Source.h
+ *
+*/
+#ifndef ZYPP_DETAIL_SOURCE_H
+#define ZYPP_DETAIL_SOURCE_H
+
+#include <string>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace source
+  { /////////////////////////////////////////////////////////////////
+    DEFINE_PTR_TYPE(Source)
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : Source
+    //
+    /**
+     * \todo Assert \c deps provide 'name=edition'.
+    */
+    class Source : public base::ReferenceCounted, private base::NonCopyable
+    {
+    public:
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace source
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_DETAIL_SOURCE_H
diff --git a/zypp/source/yum/Makefile.am b/zypp/source/yum/Makefile.am
new file mode 100644 (file)
index 0000000..39ac1ae
--- /dev/null
@@ -0,0 +1,19 @@
+## Process this file with automake to produce Makefile.in
+## ##################################################
+
+SUBDIRS =
+
+## ##################################################
+
+include_HEADERS =      \
+       YUMScriptImpl.h
+
+
+noinst_LTLIBRARIES =   lib@PACKAGE@_source_yum.la
+
+## ##################################################
+
+lib@PACKAGE@_source_yum_la_SOURCES =   \
+       YUMScriptImpl.cc
+
+## ##################################################
diff --git a/zypp/source/yum/YUMScriptImpl.cc b/zypp/source/yum/YUMScriptImpl.cc
new file mode 100644 (file)
index 0000000..1f4f8b9
--- /dev/null
@@ -0,0 +1,62 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/ScriptImpl.cc
+ *
+*/
+
+#include "zypp/source/yum/YUMScriptImpl.h"
+
+using namespace std;
+using namespace zypp::detail;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace source
+  { /////////////////////////////////////////////////////////////////
+    namespace YUM
+    {
+      IMPL_PTR_TYPE(YUMScriptImpl)
+  
+      ///////////////////////////////////////////////////////////////////
+      //
+      //        CLASS NAME : YUMScriptImpl
+      //
+      ///////////////////////////////////////////////////////////////////
+  
+      /** Default ctor */
+      YUMScriptImpl::YUMScriptImpl(
+       const zypp::parser::YUM::YUMPatchScript & parsed
+      )
+      : ScriptImpl(
+       parsed.name,
+       Edition(parsed.ver, parsed.rel, strtol(parsed.epoch.c_str(), NULL, 10)),
+       Arch("noarch")
+      )
+      {
+       _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 
+    /////////////////////////////////////////////////////////////////
+  } // namespace source
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
diff --git a/zypp/source/yum/YUMScriptImpl.h b/zypp/source/yum/YUMScriptImpl.h
new file mode 100644 (file)
index 0000000..d01eefa
--- /dev/null
@@ -0,0 +1,48 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/detail/ScriptImpl.h
+ *
+*/
+#ifndef ZYPP_SOURCE_YUM_YUMSCRIPTIMPL_H
+#define ZYPP_SOURCE_YUM_YUMSCRIPTIMPL_H
+
+#include "zypp/detail/ScriptImpl.h"
+#include "zypp/parser/yum/YUMParserData.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace source
+  { /////////////////////////////////////////////////////////////////
+    namespace YUM
+    { //////////////////////////////////////////////////////////////
+
+      DEFINE_PTR_TYPE(YUMScriptImpl)
+  
+      ///////////////////////////////////////////////////////////////////
+      //
+      //        CLASS NAME : YUMScriptImpl
+      //
+      /** Class representing an update script */
+      class YUMScriptImpl : public detail::ScriptImpl
+      {
+      public:
+        /** Default ctor */
+        YUMScriptImpl( const zypp::parser::YUM::YUMPatchScript & parsed );
+       };
+      ///////////////////////////////////////////////////////////////////
+    } // namespace YUM
+    /////////////////////////////////////////////////////////////////
+  } // namespace source
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_YUM_YUMSCRIPTIMPL_H