changed to cmake
authorStefan Haas <shaas@suse.de>
Fri, 7 Sep 2007 10:14:47 +0000 (10:14 +0000)
committerStefan Haas <shaas@suse.de>
Fri, 7 Sep 2007 10:14:47 +0000 (10:14 +0000)
14 files changed:
devel/devel.shaas/PdbToZypp/CMakeLists.txt [new file with mode: 0644]
devel/devel.shaas/PdbToZypp/db.cc [moved from devel/devel.shaas/src/db.cc with 100% similarity]
devel/devel.shaas/PdbToZypp/db.h [moved from devel/devel.shaas/src/db.h with 100% similarity]
devel/devel.shaas/PdbToZypp/pdbtozypp.cc [moved from devel/devel.shaas/src/pdbtozypp.cc with 98% similarity]
devel/devel.shaas/PdbToZypp/pdbtozypp.h [moved from devel/devel.shaas/src/pdbtozypp.h with 100% similarity]
devel/devel.shaas/PdbToZypp/resolvable.cc [moved from devel/devel.shaas/src/resolvable.cc with 100% similarity]
devel/devel.shaas/PdbToZypp/resolvable.h [moved from devel/devel.shaas/src/resolvable.h with 100% similarity]
devel/devel.shaas/PdbToZypp/swig/CMakeLists.txt [new file with mode: 0644]
devel/devel.shaas/PdbToZypp/swig/PdbToZypp.i [moved from devel/devel.shaas/src/PdbToZypp.i with 100% similarity]
devel/devel.shaas/old/Makefile
devel/devel.shaas/old/main.cc
devel/devel.shaas/src/Makefile.PL [deleted file]
devel/devel.shaas/src/Makefile.no [deleted file]
devel/devel.shaas/src/install.pl [deleted file]

diff --git a/devel/devel.shaas/PdbToZypp/CMakeLists.txt b/devel/devel.shaas/PdbToZypp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ab4a253
--- /dev/null
@@ -0,0 +1,45 @@
+PROJECT(pdbtozypp)
+
+SET( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" )
+
+SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -O2 -Wall -W -fpic -D_REENTRANT" )
+
+FIND_PROGRAM(SWIG_EXECUTABLE
+  NAMES swig-1.3 swig
+  PATHS ${SWIG_DIR} ${SWIG_DIR}/.. ${SWIG_DIR}/../../bin /usr/bin /usr/local/bin ${CMAKE_INSTALL_PREFIX}/bin
+)
+
+IF ( NOT SWIG_EXECUTABLE )
+   MESSAGE( FATAL_ERROR " swig not found" )
+ELSE ( NOT SWIG_EXECUTABLE )
+   MESSAGE( STATUS "SWIG found at ${SWIG_EXECUTABLE}" )
+ENDIF ( NOT SWIG_EXECUTABLE ) 
+
+FIND_PACKAGE(Zypp REQUIRED)
+IF ( NOT ZYPP_LIBRARY )
+   MESSAGE( FATAL_ERROR " zypp not found" )
+ELSE ( NOT ZYPP_LIBRARY )
+   MESSAGE( STATUS "zypp found" )
+ENDIF ( NOT ZYPP_LIBRARY ) 
+
+SET( pdbtozypp_SRCS
+      db.cc
+      pdbtozypp.cc
+      resolvable.cc
+   )
+
+SET( pdbtozypp_HEADERS
+      db.h
+      pdbtozypp.h
+      resolvable.h
+   )
+
+INSTALL( FILES ${pdbtozypp_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/pdbtozypp" )
+
+ADD_LIBRARY(pdbtozypp SHARED ${pdbtozypp_SRCS})
+TARGET_LINK_LIBRARIES(pdbtozypp ${ZYPP_LIBRARY} )
+TARGET_LINK_LIBRARIES(pdbtozypp -lmysqlclient )
+
+INSTALL(TARGETS pdbtozypp LIBRARY DESTINATION ${LIB_INSTALL_DIR} )
+
+ADD_SUBDIRECTORY(swig)
similarity index 98%
rename from devel/devel.shaas/src/pdbtozypp.cc
rename to devel/devel.shaas/PdbToZypp/pdbtozypp.cc
index 9e83f3c..aad72a7 100644 (file)
@@ -16,8 +16,8 @@ void PdbToZypp::readOut(){
 
    //store = new ResStore;
 
-       database *dbDeps = new database("lorien.suse.de", "rpmread", "rrrrrrr", "rpm");
-       database *dbPackages = new database("lorien.suse.de", "rpmread", "rrrrrrr", "package");
+       database *dbDeps = new database("lorien.suse.de", "rpmread", "Salahm1", "rpm");
+       database *dbPackages = new database("lorien.suse.de", "rpmread", "Salahm1", "package");
 
        if(dbPackages->connect() != 1){
                //std::cout << "NO DB CONNECTION!!!\n";
diff --git a/devel/devel.shaas/PdbToZypp/swig/CMakeLists.txt b/devel/devel.shaas/PdbToZypp/swig/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a8f61b7
--- /dev/null
@@ -0,0 +1,43 @@
+FIND_PACKAGE(Perl REQUIRED)
+
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{cppflags}" OUTPUT_VARIABLE PERL_CXX_FLAGS)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PERL_CXX_FLAGS}")
+
+EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} -e "use Config; print \$Config{archlibexp}" OUTPUT_VARIABLE PERL_LIB_PATH)
+SET( PERL_INS_PATH "${PERL_LIB_PATH}" )
+SET( PERL_LIB_PATH "${PERL_LIB_PATH}/CORE" )
+
+MESSAGE(STATUS "Perl executable: ${PERL_EXECUTABLE}")
+MESSAGE(STATUS "Perl cpp-flags: ${PERL_CXX_FLAGS}")
+MESSAGE(STATUS "Perl lib path: ${PERL_LIB_PATH}")
+
+SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/PdbToZypp_wrap.cxx" )
+SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/PdbToZypp.i" )
+
+ADD_CUSTOM_COMMAND (
+   OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/PdbToZypp_wrap.cxx
+   COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code for perl..."
+   COMMAND ${SWIG_EXECUTABLE} -c++ -perl5 -xmlout ${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o ${CMAKE_CURRENT_BINARY_DIR}/PdbToZypp_wrap.cxx -I${ZYPP_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/PdbToZypp.i
+   COMMAND ${CMAKE_COMMAND} -E echo "Done."
+   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.i ${CMAKE_CURRENT_SOURCE_DIR}/*.i
+)
+
+ADD_CUSTOM_TARGET( glue
+   DEPENDS ${SWIG_OUTPUT}
+)
+
+ADD_LIBRARY( rpdbtozypp SHARED "${CMAKE_CURRENT_BINARY_DIR}/PdbToZypp_wrap.cxx" )
+SET_TARGET_PROPERTIES( rpdbtozypp PROPERTIES PREFIX "" )
+ADD_DEPENDENCIES( rpdbtozypp glue )
+
+INCLUDE_DIRECTORIES( ${PERL_LIB_PATH} )
+INCLUDE_DIRECTORIES( ${ZYPP_INCLUDE_DIR} )
+INCLUDE_DIRECTORIES( /usr/include/pdbtozypp )
+TARGET_LINK_LIBRARIES( rpdbtozypp ${ZYPP_LIBRARY} )
+TARGET_LINK_LIBRARIES( rpdbtozypp -lpdbtozypp )
+
+INSTALL(TARGETS rpdbtozypp LIBRARY DESTINATION ${PERL_INS_PATH})
+INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/rpdbtozypp.pm DESTINATION ${PERL_INS_PATH})
+
index 5dc8fe5..2a8607c 100644 (file)
@@ -8,7 +8,7 @@ CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT  $(DEFINES)
 INCPATH       = -I/usr/include -I. -I. -I.
 LINK          = g++
 LFLAGS        = -lpdbtozypp
-LIBS          = $(SUBLIBS)  -L/usr/local/lib
+LIBS          = $(SUBLIBS)  -L/usr/lib
 
 ####### Output directory
 
index a971998..c0aea1a 100644 (file)
@@ -1,13 +1,45 @@
 #include <pdbtozypp/pdbtozypp.h>
+#include <zypp/ResPool.h>
+#include <zypp/RepoManager.h>
+#include <zypp/TmpPath.h>
+#include <zypp/base/Iterator.h>
 
 using namespace zypp;
 using namespace std;
 int main(){
        
        static ZYpp::Ptr God;
-       ResStore store = pdbToZypp();
 
-       try {
+       PdbToZypp pdb;
+   pdb.readOut();
+
+   ResStore store = pdb.getStore();
+
+   /*RepoInfo repo_info;
+   repo_info.setAlias("test");
+   repo_info.setName("Test Repo");
+   repo_info.setEnabled(true);
+   repo_info.setAutorefresh(false);
+   repo_info.addBaseUrl(Url("ftp://dist.suse.de/install/stable-x86/"));
+       
+   RepoManagerOptions opts;
+   filesystem::TmpDir cachePath;
+   filesystem::TmpDir rawPath;
+   filesystem::TmpDir reposPath;
+
+   opts.repoCachePath = cachePath.path();
+   opts.repoRawCachePath = rawPath.path();
+   opts.knownReposPath = reposPath.path();
+
+   RepoManager repo_man(opts);
+
+   repo_man.addRepository(repo_info);
+   repo_man.refreshMetadata(repo_info);
+   repo_man.buildCache(repo_info);
+   Repository repo = repo_man.createFromCache(repo_info);
+   ResStore store = repo.resolvables();*/
+
+   try {
                God = zypp::getZYpp();
        }
        catch (const Exception & excpt_r ) {
@@ -18,5 +50,30 @@ int main(){
 
        God->addResolvables(store);
        cout << "Elements in pool: " << God->pool().size() << endl;
+
+   for(pool::PoolTraits::const_iterator iter = God->pool().begin(); iter != God->pool().end(); iter++){
+
+      ResObject::constPtr r = iter->resolvable();
+      if(r->name() == "glibc"){
+         cout << "Package found!" << endl;
+         iter->status().setToBeInstalled(ResStatus::USER);
+      }
+   
+   }
+
+   Resolver res(God->pool());
+
+   if(res.resolvePool() == false){
+      cout << "It was not possible to solve the pool" << endl;
+      list<string> problems = res.problemDescription();
+
+      for(list<string>::iterator iter = problems.begin(); iter != problems.end(); iter++){
+         cout << *iter << endl;
+      }
+
+   }else{
+      cout << "The pool was solved corectly" << endl;
+   }
+
        return 0;
 }
diff --git a/devel/devel.shaas/src/Makefile.PL b/devel/devel.shaas/src/Makefile.PL
deleted file mode 100644 (file)
index 6e7a7a2..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-# File : Makefile.PL
-use ExtUtils::MakeMaker;
-WriteMakefile(
-   'NAME'    => 'rpdbtozypp',                # Name of package
-   'LIBS'    => '-lm -lzypp -lpdbtozypp',                    # Name of custom libraries
-   'OBJECT'  => 'PdbToZypp_wrap.o /usr/lib/perl5/5.8.8/i586-linux-thread-multi/zypp.so'  # Object files
-);
diff --git a/devel/devel.shaas/src/Makefile.no b/devel/devel.shaas/src/Makefile.no
deleted file mode 100644 (file)
index 7d9ac3c..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-####### Compiler, tools and options
-
-CC            = gcc
-CXX           = g++
-DEFINES       =  
-CFLAGS        = -pipe -O2 -Wall -W -fpic -D_REENTRANT  $(DEFINES)
-CXXFLAGS      = -pipe -O2 -Wall -W -fpic -D_REENTRANT  $(DEFINES)
-INCPATH       = -I/usr/include -I. -I. -I.
-LINK          = g++
-LFLAGS        = -shared -lmysqlclient
-LIBS          = $(SUBLIBS)  -L/usr/lib
-
-####### Output directory
-
-OBJECTS_DIR   = ./
-
-####### Files
-
-SOURCES       = db.cc resolvable.h pdbtozypp.cc 
-OBJECTS       = db.o pdbtozypp.o
-OBJCOMP                  = /usr/lib/libzypp.so 
-DESTDIR       = 
-TARGET        = libpdbtozypp.so
-
-first: all
-####### Implicit rules
-
-.SUFFIXES: .o .c .cpp .cc .cxx .C
-
-.cpp.o:
-       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cc.o:
-       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cxx.o:
-       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.C.o:
-       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.c.o:
-       $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
-
-####### Build rules
-
-all: Makefile.no $(TARGET)
-
-$(TARGET):  $(OBJECTS)  
-       $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
-
-swig:
-       swig -c++ -perl5 PdbToZypp.i
-
-install: 
-       install --mode=644 db.h /usr/include/pdbtozypp/
-       install --mode=644 resolvable.h /usr/include/pdbtozypp/
-       install --mode=644 pdbtozypp.h /usr/include/pdbtozypp/
-       install --mode=555 libpdbtozypp.so /usr/lib/
diff --git a/devel/devel.shaas/src/install.pl b/devel/devel.shaas/src/install.pl
deleted file mode 100644 (file)
index 4d454ad..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-print "Build libpdbtozypp.so\n";
-`make -f Makefile.no`;
-print "Install libpdbtozypp.so\n";
-`make -f Makefile.no install`;
-print "Build swig-binding\n";
-`make -f Makefile.no swig`;
-print "Build Makefile for perl-module with MakeMaker\n";
-`perl Makefile.PL`;
-print "Build perl-module\n";
-`make`;
-print "Install perl-module\n";
-`make install`;