- Introduce examples/
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 11 Aug 2006 09:47:51 +0000 (09:47 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 11 Aug 2006 09:47:51 +0000 (09:47 +0000)
  much like devel.* programs with one difference:
  - must compile. They are documentation.
  - Included in compilation
  - they should show only useful tasks.
    like installing a package, but not
    how to use templates to draw the suse logo in ascii.
  - they must be zypp user examples, not zypp developer examples

- fix some svn ignores

Makefile.am
configure.ac
devel/devel.dmacvicar/testbed.cc
examples/Makefile.am [new file with mode: 0644]
examples/README [new file with mode: 0644]
examples/read_plaindir_source.cc [new file with mode: 0644]

index 12d907a..1918f8e 100644 (file)
@@ -4,7 +4,7 @@
 # Do NOT list 'devel' in subdirs. It's developers playgound
 # and must not prevent anything from building.
 
-SUBDIRS = zypp zypp2 testsuite po doc
+SUBDIRS = zypp zypp2 examples testsuite po doc
 
 ## ##################################################
 
index 98ca05d..3974143 100644 (file)
@@ -241,7 +241,8 @@ AC_OUTPUT(   po/Makefile.in\
        testsuite/target/tests/Makefile \
        testsuite/media/Makefile        \
        testsuite/media/tests/Makefile  \
-       zypp/Makefile                   \
+  examples/Makefile  \
+  zypp/Makefile                        \
        zypp/base/Makefile              \
        zypp/thread/Makefile            \
        zypp/detail/Makefile            \
index 9af1434..6ad0ced 100644 (file)
@@ -1,39 +1,11 @@
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
-#include "boost/filesystem/fstream.hpp"    // ditto
-
-#include <boost/iostreams/device/file_descriptor.hpp>
-
 #include <zypp/base/Logger.h>
-#include <zypp/Locale.h>
 #include <zypp/ZYpp.h>
 #include <zypp/ZYppFactory.h>
-#include <zypp/TranslatedText.h>
-///////////////////////////////////////////////////////////////////
-
-#include <zypp/base/Logger.h>
-
 
-#include <map>
-#include <set>
-
-#include "zypp/CapFactory.h"
-#include "zypp/KeyRing.h"
 #include "zypp/Product.h"
-#include "zypp/Selection.h"
 #include "zypp/Package.h"
-#include "zypp/PublicKey.h"
-
-#include "zypp/ZYppFactory.h"
 
-#include "zypp/MediaSetAccess.h"
 #include "zypp/SourceFactory.h"
-#include "zypp2/source/yum/YUMSourceCacher.h"
-
 #include "testsuite/src/utils/TestUtils.h"
 
 using namespace zypp::detail;
@@ -63,13 +35,7 @@ int main()
       zypp::Package::Ptr res = asKind<zypp::Package>( *it );
       MIL << res->name() << " " << res->edition() << " " << res->location() << std::endl;
     }
-    
-    /*for (ResStore::resfilter_const_iterator it = z->target()->byKindBegin(ResTraits<TestKind>::kind); it != z->target()->byKindEnd(ResTraits<TestKind>::kind); ++it)
-    {
-      zypp::TestKind::constPtr res = asKind<const zypp::TestKind>( *it );
-      MIL << res->name() << " " << res->edition() << std::endl;
-    }*/
-    
+        
   }
   catch ( const Exception &e )
   {
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644 (file)
index 0000000..59ecce9
--- /dev/null
@@ -0,0 +1,28 @@
+## Process this file with automake to produce Makefile.in
+## ##################################################
+
+noinst_PROGRAMS = read_plaindir_source
+
+## ##################################################
+
+INCLUDES = -I$(oldincludedir)/libxml2
+AM_LDFLAGS =
+
+AM_CXXFLAGS =
+# gperf:       -pg
+
+LDADD =                -L$(top_srcdir)/zypp/.libs -lzypp -lboost_regex -lxml2 -lz $(top_srcdir)/testsuite/src/utils/lib@PACKAGE@_testsuite_utils.la
+
+## ##################################################
+
+read_plaindir_source_SOURCES =         read_plaindir_source.cc
+read_plaindir_source_LDFLAGS = -static
+
+.PHONY:        always
+
+$(noinst_PROGRAMS):    $(top_srcdir)/zypp/lib@PACKAGE@.la
+
+$(top_srcdir)/zypp/lib@PACKAGE@.la:     always
+       $(MAKE) -C $(top_srcdir)/zypp
+
+## ##################################################
diff --git a/examples/README b/examples/README
new file mode 100644 (file)
index 0000000..62523d4
--- /dev/null
@@ -0,0 +1,8 @@
+
+ZyPP Examples
+=============
+
+* read_plaindir_source.cc
+  Read a sirectory with rpm files (no metadata) and loop over the resolvables.
+  
+  
\ No newline at end of file
diff --git a/examples/read_plaindir_source.cc b/examples/read_plaindir_source.cc
new file mode 100644 (file)
index 0000000..4842db7
--- /dev/null
@@ -0,0 +1,53 @@
+// ZyPP Example
+// Read a directory with rpms as a source
+// No need for metadata, it is read from the rpms
+
+#include <zypp/base/Logger.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
+
+#include "zypp/Product.h"
+#include "zypp/Package.h"
+
+#include "zypp/SourceFactory.h"
+#include "testsuite/src/utils/TestUtils.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::source;
+
+int
+main (int argc, char **argv)
+{
+  if (argc < 2) {
+    cerr << "1|usage: " << argv[0] << " <dir:/somepath>" << endl;
+    return 1;
+  }
+  
+  try
+  {
+    ZYpp::Ptr z = getZYpp();
+    
+    // plaindir sources are not signed so we don't need to initialize the
+    // target to import the system public keys.
+    //z->initializeTarget("/");
+   
+    Source_Ref source = SourceFactory().createFrom( Url(argv[1]), "/", "testsource", Pathname() );
+    ResStore store = source.resolvables();
+    //zypp::testsuite::utils::dump(store, true, true);
+    
+    for (ResStore::const_iterator it = store.begin(); it != store.end(); ++it)
+    {
+      zypp::Package::Ptr res = asKind<zypp::Package>( *it );
+      MIL << res->name() << " " << res->edition() << " " << res->location() << std::endl;
+    }
+        
+  }
+  catch ( const Exception &e )
+  {
+    MIL << "Exception ocurred, bye" << endl;
+  }
+}
+
+
+