(no commit message)
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 24 Apr 2007 12:26:33 +0000 (12:26 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 24 Apr 2007 12:26:33 +0000 (12:26 +0000)
devel/devel.dmacvicar/CMakeLists.txt
devel/devel.dmacvicar/RepositoryManager.cc [new file with mode: 0644]
devel/devel.dmacvicar/RepositoryManager.h [new file with mode: 0644]
devel/devel.dmacvicar/RepositoryManager_tp.cc [new file with mode: 0644]
devel/devel.dmacvicar/SourceManager.cc [deleted file]
devel/devel.dmacvicar/SourceManager.h [deleted file]
devel/devel.dmacvicar/SourceManager_tp.cc [deleted file]

index 248f53424216691a75638675cd62787187598a87..da858fb916317171b1d0004ff7b57869009a008d 100644 (file)
@@ -32,6 +32,10 @@ ADD_EXECUTABLE(cachedsource CachedSource_tp.cc)
 TARGET_LINK_LIBRARIES(cachedsource  zypp )
 TARGET_LINK_LIBRARIES(cachedsource  zypp2 )
 
+ADD_EXECUTABLE(repomanager RepositoryManager_tp.cc RepositoryManager.cc)
+TARGET_LINK_LIBRARIES(repomanager zypp )
+#TARGET_LINK_LIBRARIES(repomanager zypp2 )
+
 FIND_PACKAGE(Zsync)
 IF(ZSYNC_FOUND)
   ADD_EXECUTABLE(zsync zsync.cc)
diff --git a/devel/devel.dmacvicar/RepositoryManager.cc b/devel/devel.dmacvicar/RepositoryManager.cc
new file mode 100644 (file)
index 0000000..0ae6f69
--- /dev/null
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+#include <iostream>
+#include <list>
+#include <algorithm>
+#include "RepositoryManager.h"
+#include "zypp/base/Exception.h"
+#include "zypp/base/Logger.h"
+#include "zypp/PathInfo.h"
+#include "zypp/parser/inifile/iniparser.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::filesystem;
+using namespace zypp::source;
+
+namespace zypp {
+
+RepositoryManager::RepositoryManager()
+{
+
+}
+
+static std::list<source::SourceInfo> repositories_in_file( const Pathname &file )
+{
+  dictionary *d = iniparser_new(file.c_str());
+  
+  if ( d == NULL )
+    ZYPP_THROW(Exception("Failed creating dictionary"));
+  
+  int n = iniparser_getnsec(d);
+  MIL << n << endl;
+  
+  for ( int i = 0; i < n; i++ )
+  {
+    MIL << iniparser_getsecname(d, i) << endl;
+    
+  }
+  return std::list<source::SourceInfo>();
+}
+
+static std::list<source::SourceInfo> repositories_in_path( const Pathname &dir )
+{
+  std::list<source::SourceInfo> repos;
+  list<Pathname> entries;
+  if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
+    ZYPP_THROW(Exception("failed to read directory"));
+  
+  for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
+  {
+    Pathname file = *it;
+    std::list<source::SourceInfo> repos_here = repositories_in_file(file);
+    std::copy( repos_here.begin(), repos_here.end(), std::back_inserter(repos));
+  }
+  return repos;
+}
+
+std::list<source::SourceInfo> RepositoryManager::knownRepositories()
+{
+  
+
+  return std::list<source::SourceInfo>();
+}
+
+} // ns zypp
\ No newline at end of file
diff --git a/devel/devel.dmacvicar/RepositoryManager.h b/devel/devel.dmacvicar/RepositoryManager.h
new file mode 100644 (file)
index 0000000..0654362
--- /dev/null
@@ -0,0 +1,24 @@
+
+#ifndef ZYPP_NEW_REPOMANAGER_H
+#define ZYPP_NEW_REPOMANAGER_H
+
+#include <list>
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/source/SourceInfo.h"
+#include "zypp/Pathname.h"
+
+namespace zypp
+{
+  
+  class RepositoryManager : public base::ReferenceCounted, private base::NonCopyable
+  {
+    friend std::ostream & operator<<( std::ostream & str, const RepositoryManager & obj );
+  public:
+    RepositoryManager();
+    std::list<source::SourceInfo> knownRepositories();
+  };
+  
+  
+}
+#endif
\ No newline at end of file
diff --git a/devel/devel.dmacvicar/RepositoryManager_tp.cc b/devel/devel.dmacvicar/RepositoryManager_tp.cc
new file mode 100644 (file)
index 0000000..9b4d990
--- /dev/null
@@ -0,0 +1,44 @@
+
+#include <sys/time.h>
+
+#include <iostream>
+#include <fstream>
+
+#include <zypp/base/Logger.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
+
+#include "zypp/Product.h"
+#include "zypp/detail/PackageImplIf.h"
+#include "zypp/Package.h"
+#include "zypp/SourceFactory.h"
+
+#include "zypp2/source/cached/CachedSourceImpl.h"
+#include "zypp/data/ResolvableData.h"
+
+#include "RepositoryManager.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::source;
+
+
+int main(int argc, char **argv)
+{
+    try
+    {
+      ZYpp::Ptr z = getZYpp();
+    
+      Pathname dbpath = Pathname(getenv("PWD"));
+      
+      RepositoryManager manager;
+      list<SourceInfo> sources = manager.knownRepositories();
+    }
+    catch ( const Exception &e )
+    {
+      ZYPP_CAUGHT(e);
+      cout << e.msg() << endl;
+    }
+    
+    return 0;
+}
diff --git a/devel/devel.dmacvicar/SourceManager.cc b/devel/devel.dmacvicar/SourceManager.cc
deleted file mode 100644 (file)
index 0291ed7..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include "SourceManager.h"
-
diff --git a/devel/devel.dmacvicar/SourceManager.h b/devel/devel.dmacvicar/SourceManager.h
deleted file mode 100644 (file)
index c1f3518..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#ifndef ZYPP_NEW_SOURCEMANAGER_H
-#define ZYPP_NEW_SOURCEMANAGER_H
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/Pathname.h"
-
-namespace zypp2
-{
-  
-  class SourceManager : public base::ReferenceCounted, private base::NonCopyable
-  {
-    friend std::ostream & operator<<( std::ostream & str, const SourceManager & obj );
-  };
-  
-  
-}
-#endif
\ No newline at end of file
diff --git a/devel/devel.dmacvicar/SourceManager_tp.cc b/devel/devel.dmacvicar/SourceManager_tp.cc
deleted file mode 100644 (file)
index e69de29..0000000