--- /dev/null
+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)
//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";
--- /dev/null
+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})
+
INCPATH = -I/usr/include -I. -I. -I.
LINK = g++
LFLAGS = -lpdbtozypp
-LIBS = $(SUBLIBS) -L/usr/local/lib
+LIBS = $(SUBLIBS) -L/usr/lib
####### Output directory
#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 ) {
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;
}
+++ /dev/null
-# 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
-);
+++ /dev/null
-####### 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/
+++ /dev/null
-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`;