diff options
46 files changed, 2228 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..97ba8d9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ + +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) +SET(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules ${CMAKE_MODULE_PATH}) + +INCLUDE(${CMAKE_SOURCE_DIR}/VERSION.cmake) +SET ( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) + +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Language Bindings for libzypp") +SET(CPACK_PACKAGE_VENDOR "Novell Inc.") +#SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt") +#SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") +SET(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) + +SET( CPACK_GENERATOR "TBZ2") +SET( CPACK_SOURCE_GENERATOR "TBZ2") +SET( CPACK_SOURCE_PACKAGE_FILE_NAME "zypp-bindings-${VERSION}" ) + +# The following components are regex's to match anywhere (unless anchored) +# in absolute path + filename to find files or directories to be excluded +# from source tarball. +SET (CPACK_SOURCE_IGNORE_FILES +"/CVS/;/.svn/;/.libs/;/.deps/;.swp$;.#;/#;/build/" +"~$" +"\\\\.cvsignore$" +"/package" +"Makefile\\\\.in$" +) + +INCLUDE(CPack) + +#FIND_PACKAGE(SWIG REQUIRED) + +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 "SWIG not found." ) +ELSE ( NOT SWIG_EXECUTABLE ) + MESSAGE( STATUS "SWIG found at ${SWIG_EXECUTABLE}" ) +ENDIF ( NOT SWIG_EXECUTABLE ) + +FIND_PACKAGE(Zypp REQUIRED) +FIND_PACKAGE(Ruby REQUIRED) + +#RUBY_RUBY_LIB_PATH +MESSAGE( STATUS "Ruby arch dir: ${RUBY_ARCH_DIR}" ) + +ADD_SUBDIRECTORY(swig)
\ No newline at end of file @@ -0,0 +1,33 @@ + +attempt to create generated bindings for +libzypp. Not restricted to one language. + +author: dmacvicar@suse.de + +Notes: + +- Some classes are not wrapped but converted to + equivalents: + +Usage: + +Requires swig and ruby installed. + +make -f Makefile.swig +ruby extconf.rb +make +ruby test.rb + +Ruby Notes +========== + +* API tries to follow ruby standards: +* zypp::Pathname -> std Pathname in ruby +* zypp::Date -> std Time in ruby +* ResStore does not implement iterators but: + * each + * each_by_name + * etc +* lower case methods, ie: ZYppFactory::instance.get_zypp + instead of ZYppFactory::instance()->getZYpp() + z.initialize_target("/") for z.initializeTarget("/") diff --git a/VERSION.cmake b/VERSION.cmake new file mode 100644 index 0000000..672b177 --- /dev/null +++ b/VERSION.cmake @@ -0,0 +1,3 @@ +SET(VERSION_MAJOR "0") +SET(VERSION_MINOR "2") +SET(VERSION_PATCH "0")
\ No newline at end of file diff --git a/examples/ruby/list_target_resolvables.rb b/examples/ruby/list_target_resolvables.rb new file mode 100644 index 0000000..e66d8f0 --- /dev/null +++ b/examples/ruby/list_target_resolvables.rb @@ -0,0 +1,12 @@ + +require 'rzypp' +include Rzypp + +z = ZYppFactory::instance.get_zypp + +t = z.initialize_target("/") +r = z.target.resolvables +puts r.class +r.each do | p | + puts "#{p.name} #{p.edition}" +end diff --git a/examples/ruby/mediasetaccess_example.rb b/examples/ruby/mediasetaccess_example.rb new file mode 100644 index 0000000..424a387 --- /dev/null +++ b/examples/ruby/mediasetaccess_example.rb @@ -0,0 +1,13 @@ + +require 'rzypp' +include Rzypp + +a = MediaSetAccess.new("http://dist.suse.de/install/stable-x86", "/") +p = a.provide_file("/content", 1) +puts p.class +File.open(p, 'r') do | f | + f.each_line do |l| + puts l + end +end + diff --git a/examples/ruby/play_with_pool_and_target.rb b/examples/ruby/play_with_pool_and_target.rb new file mode 100644 index 0000000..945424d --- /dev/null +++ b/examples/ruby/play_with_pool_and_target.rb @@ -0,0 +1,21 @@ + +require 'rzypp' +include Rzypp + +z = ZYppFactory::instance.get_zypp + +t = z.initialize_target("/") +r = z.target.resolvables +puts r.class + +p = z.pool +puts p.class + +z.add_resolvables r +p.each do | pi | + puts "a poolitem: #{pi} status: #{pi.status} res: #{pi.resolvable}" + puts pi.methods + exit +end + + diff --git a/examples/ruby/test.rb b/examples/ruby/test.rb new file mode 100644 index 0000000..1ad8b56 --- /dev/null +++ b/examples/ruby/test.rb @@ -0,0 +1,24 @@ + +require 'rzypp' +include Rzypp + +a = Arch.new("i386") +puts a.inspect +#exit + +z = ZYppFactory::instance.get_zypp + +puts z.inspect +puts z.architecture.to_s + +puts z.home_path +puts z.home_path.class + +t = z.initialize_target("/") +r = z.target.resolvables +puts r.class +r.each do | p | + puts "#{p.name} #{p.edition}" +end + +#puts z.methods diff --git a/examples/ruby/test2.rb b/examples/ruby/test2.rb new file mode 100644 index 0000000..0056627 --- /dev/null +++ b/examples/ruby/test2.rb @@ -0,0 +1,19 @@ + +require 'rzypp' +require 'pathname' + +include Rzypp + +z = ZYppFactory::instance.get_zypp + +#puts z.homePath.class +#z.setHomePath("/home") + +z.initialize_target("/") +t = z.target +puts z.target.class +#r = z.target.resolvables +puts t.class +#puts t.methods + + diff --git a/swig/Arch.i b/swig/Arch.i new file mode 100644 index 0000000..3f314b1 --- /dev/null +++ b/swig/Arch.i @@ -0,0 +1,35 @@ + +typedef std::set<Arch,CompareByGT<Arch> > CompatSet; + +%ignore Arch::compare(const Arch &, const Arch &); + +class Arch +{ +public: + //Arch(); + Arch( const std::string & rhs ); + const std::string & asString() const; + bool empty() const; + bool compatibleWith( const Arch & targetArch_r ) const; + int compare( const Arch & rhs ) const; + static int compare( const Arch & lhs, const Arch & rhs ); + //static std::string asString( const CompatSet & cset ); + struct CompatEntry; +private: + Arch( const CompatEntry & ); + const CompatEntry * _entry; +}; + +extern const Arch Arch_noarch; +extern const Arch Arch_x86_64; +extern const Arch Arch_athlon; +extern const Arch Arch_i686; +extern const Arch Arch_i586; +extern const Arch Arch_i486; +extern const Arch Arch_i386; +extern const Arch Arch_s390x; +extern const Arch Arch_s390; +extern const Arch Arch_ppc64; +extern const Arch Arch_ppc; +extern const Arch Arch_ia64; + diff --git a/swig/ByteCount.i b/swig/ByteCount.i new file mode 100644 index 0000000..fb365b8 --- /dev/null +++ b/swig/ByteCount.i @@ -0,0 +1,10 @@ + +%typemap(in) ByteCount { + ByteCount::SizeType bytes = (Date::SizeType) NUM2LONG( rb_funcall( $input, rb_intern("to_i"), 0, 0) ); + $1 = ByteCount(bytes); +} + +%typemap(out) ByteCount { + VALUE rbbytenum = INT2NUM( (ByteCount::SizeType) $1 ); + return rbbytenum; +}
\ No newline at end of file diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt new file mode 100644 index 0000000..49d7310 --- /dev/null +++ b/swig/CMakeLists.txt @@ -0,0 +1,28 @@ + +SET( SWIG_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx" ) +SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/zypp.i" ) + +ADD_CUSTOM_COMMAND ( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx + COMMAND ${CMAKE_COMMAND} -E echo_append "Creating wrapper code..." +#COMMAND ${SWIG_EXECUTABLE} -c++ -ruby -autorename -xmlout parse.xml -I/usr/include swig/zypp.i + COMMAND ${SWIG_EXECUTABLE} -c++ -ruby -autorename -xmlout ${CMAKE_CURRENT_BINARY_DIR}/parse.xml -o ${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx -I${ZYPP_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/zypp.i + COMMAND ${CMAKE_COMMAND} -E echo "Done." + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/zypp.i +) + +ADD_CUSTOM_TARGET( glue + DEPENDS ${SWIG_OUTPUT} +) + +ADD_LIBRARY( rzypp SHARED "${CMAKE_CURRENT_BINARY_DIR}/zypp_wrap.cxx" ) +SET_TARGET_PROPERTIES( rzypp PROPERTIES PREFIX "" ) +ADD_DEPENDENCIES( rzypp glue ) + +INCLUDE_DIRECTORIES( ${RUBY_INCLUDE_PATH} ) +INCLUDE_DIRECTORIES( ${ZYPP_INCLUDE_DIR} ) +TARGET_LINK_LIBRARIES( rzypp ${ZYPP_LIBRARY} ) +TARGET_LINK_LIBRARIES( rzypp ${RUBY_LIBRARY} ) + +INSTALL(TARGETS rzypp LIBRARY DESTINATION ${RUBY_ARCH_DIR} )
\ No newline at end of file diff --git a/swig/CapFactory.i b/swig/CapFactory.i new file mode 100644 index 0000000..b71e72e --- /dev/null +++ b/swig/CapFactory.i @@ -0,0 +1,57 @@ + +class CapFactory + { + friend std::ostream & operator<<( std::ostream & str, const CapFactory & obj ); + + public: + /** Default ctor */ + CapFactory(); + + /** Dtor */ + ~CapFactory(); + + public: + /** Parse Capability from string providing Resolvable::Kind. + * \a strval_r is expected to define a valid Capability. + * \throw EXCEPTION on parse error. + */ + Capability parse( const Resolvable::Kind & refers_r, + const std::string & strval_r ) const; + + + /** Parse Capability providing Resolvable::Kind, name, Rel and Edition as strings. + * \throw EXCEPTION on parse error. + */ + Capability parse( const Resolvable::Kind & refers_r, + const std::string & name_r, + const std::string & op_r, + const std::string & edition_r ) const; + + /** Parse Capability providing Resolvable::Kind, name, Rel and Edition. + * \throw EXCEPTION on parse error. + */ + Capability parse( const Resolvable::Kind & refers_r, + const std::string & name_r, + Rel op_r, + const Edition & edition_r ) const; + + /** Special Capability, triggering evaluation of Hal + * capabilities when matched. + */ + Capability halEvalCap() const; + + /** Special Capability, triggering evaluation of modalias + * capabilities when matched. + */ + Capability modaliasEvalCap() const; + + public: + /** Provide a parsable string representation of \a cap_r. */ + std::string encode( const Capability & cap_r ) const; + + private: + /** Implementation */ + struct Impl; + /** Pointer to implementation */ + RW_pointer<Impl> _pimpl; + };
\ No newline at end of file diff --git a/swig/CapMatch.i b/swig/CapMatch.i new file mode 100644 index 0000000..068a4a8 --- /dev/null +++ b/swig/CapMatch.i @@ -0,0 +1,57 @@ + +class CapMatch + { + enum Result { NOMATCH, MATCH, IRRELEVANT }; + + public: + + CapMatch( bool val_r ) + : _result( val_r ? MATCH : NOMATCH ) + {} + + static const CapMatch yes; + static const CapMatch no; + static const CapMatch irrelevant; + + friend bool operator==( const CapMatch & lhs, const CapMatch & rhs ) + { return lhs._result == rhs._result; } + + friend bool operator!=( const CapMatch & lhs, const CapMatch & rhs ) + { return lhs._result != rhs._result; } + + friend CapMatch operator!( const CapMatch & lhs ) + { + if ( lhs._result == CapMatch::IRRELEVANT ) + return lhs; + return !(lhs._result == CapMatch::MATCH); + } + + friend CapMatch operator&&( const CapMatch & lhs, const CapMatch & rhs ) + { + if ( lhs._result == CapMatch::IRRELEVANT ) + return rhs; + if ( rhs._result == CapMatch::IRRELEVANT ) + return lhs; + return (lhs._result == CapMatch::MATCH) + && (rhs._result == CapMatch::MATCH); + } + + friend CapMatch operator||( const CapMatch & lhs, const CapMatch & rhs ) + { + if ( lhs._result == CapMatch::IRRELEVANT ) + return rhs; + if ( rhs._result == CapMatch::IRRELEVANT ) + return lhs; + return (lhs._result == CapMatch::MATCH) + || (rhs._result == CapMatch::MATCH); + } + + friend std::ostream & operator<<( std::ostream & str, const CapMatch & obj ); + + private: + CapMatch() + : _result( IRRELEVANT ) + {} + + Result _result; + };
\ No newline at end of file diff --git a/swig/Capability.i b/swig/Capability.i new file mode 100644 index 0000000..2c31daf --- /dev/null +++ b/swig/Capability.i @@ -0,0 +1,83 @@ + +class Capability + { + public: + /** */ + typedef capability::CapabilityTraits::KindType Kind; + + public: + /** DefaultCtor creating \ref noCap. */ + Capability(); + + /** Dtor */ + virtual ~Capability(); + + /** Constant representing no Capabiliy. + * It refers to no kind of Resolvable, and matches returns + * returns \c CapMatch::irrelevant. + */ + static const Capability noCap; + + public: + /** Kind of Capability. */ + const Kind & kind() const; + + /** Kind of Resolvable the Capability refers to. */ + const Resolvable::Kind & refers() const; + + /** Whether to consider this Capability. + * Evaluates the Capabilities pre-condition (if any), and + * returns whether the condition applies. If not, the Capability + * is to be ignored. + */ + bool relevant() const; + + /** Return whether the Capabilities match. + * If either Capability is not \ref relevant, CapMatch::irrelevant + * is returned. + */ + CapMatch matches( const Capability & rhs ) const; + + /** More or less human readable representation as string. */ + std::string asString() const; + + /** accessors needed by solver/zmd */ + /** Deprecated */ + std::string index() const; + /** Deprecated, defaults to Rel::NONE */ + Rel op() const; + /** Deprecated, defaults to Edition::noedition */ + Edition edition() const; + + private: + typedef capability::CapabilityImpl Impl; + typedef capability::CapabilityImpl_Ptr Impl_Ptr ; + typedef capability::CapabilityImpl_constPtr Impl_constPtr; + + /** Factory */ + friend class CapFactory; + + /** Factory ctor */ + explicit + Capability( Impl_Ptr impl_r ); + + private: + /** */ + friend class capability::CapabilityImpl; + /** Pointer to implementation */ + RW_pointer<Impl,rw_pointer::Intrusive<Impl> > _pimpl; + }; + /////////////////////////////////////////////////////////////////// + + template<class _Cap> + inline bool isKind( const Capability & cap ) + { return cap.kind() == capability::CapTraits<_Cap>::kind; } + + /////////////////////////////////////////////////////////////////// + + /** Ordering relation used by ::CapSet. */ + struct CapOrder : public std::binary_function<Capability, Capability, bool> + { + bool operator()( const Capability & lhs, const Capability & rhs ) const + { return lhs._pimpl.get() < rhs._pimpl.get(); } + };
\ No newline at end of file diff --git a/swig/CheckSum.i b/swig/CheckSum.i new file mode 100644 index 0000000..3c3e223 --- /dev/null +++ b/swig/CheckSum.i @@ -0,0 +1,45 @@ + +class CheckSum + { + public: + /** + * Creates a checksum for algorithm \param type + * \throws if the checksum is invalid and can't be constructed + */ + CheckSum( const std::string & type, const std::string & checksum); + CheckSum( const std::string & type, std::istream & input_r ); + CheckSum(); + + public: + static const std::string & md5Type(); + static const std::string & shaType(); + static const std::string & sha1Type(); + static const std::string & sha256Type(); + + static CheckSum md5( const std::string & checksum ) + { return CheckSum( md5Type(), checksum); } + static CheckSum sha( const std::string & checksum ) + { return CheckSum( shaType(), checksum); } + static CheckSum sha1( const std::string & checksum ) + { return CheckSum( sha1Type(), checksum); } + static CheckSum sha256( const std::string & checksum ) + { return CheckSum( sha256Type(), checksum); } + + static CheckSum md5( std::istream & input_r ) + { return CheckSum( md5Type(), input_r ); } + static CheckSum sha( std::istream & input_r ) + { return CheckSum( sha1Type(), input_r ); } + static CheckSum sha1( std::istream & input_r ) + { return CheckSum( sha1Type(), input_r ); } + static CheckSum sha256( std::istream & input_r ) + { return CheckSum( sha256Type(), input_r ); } + + public: + std::string type() const; + std::string checksum() const; + bool empty() const; + + private: + std::string _type; + std::string _checksum; + };
\ No newline at end of file diff --git a/swig/Date.i b/swig/Date.i new file mode 100644 index 0000000..0b4538e --- /dev/null +++ b/swig/Date.i @@ -0,0 +1,12 @@ + +%typemap(rubyin) Date { + Date::ValueType seconds = (Date::ValueType) NUM2INT( rb_funcall( $input, rb_intern("to_i"), 0, 0) ); + $1 = Date(seconds); +} + +%typemap(rubyout) Date { + // Time works without require + VALUE klass = rb_const_get( rb_cObject, rb_intern("Time")); + VALUE rbtimenum = INT2NUM( (Date::ValueType) $1 ); + $result = rb_funcall( klass, rb_intern("at"), 1, rbtimenum); +} diff --git a/swig/Dep.i b/swig/Dep.i new file mode 100644 index 0000000..97afdde --- /dev/null +++ b/swig/Dep.i @@ -0,0 +1,64 @@ + +struct Dep + { + /** \name Dependency types + * These are the \em real dependency type contants to + * use. Don't mind that it's not an enum. + * \see \ref zypp::Dep::inSwitch + */ + //@{ + static const Dep PROVIDES; + static const Dep PREREQUIRES; + static const Dep REQUIRES; + static const Dep CONFLICTS; + static const Dep OBSOLETES; + static const Dep RECOMMENDS; + static const Dep SUGGESTS; + static const Dep FRESHENS; + static const Dep ENHANCES; + static const Dep SUPPLEMENTS; + //@} + + /** Enumarators provided \b only for use \ref inSwitch statement. + * \see inSwitch + */ + enum for_use_in_switch { + PROVIDES_e, + PREREQUIRES_e, + REQUIRES_e, + CONFLICTS_e, + OBSOLETES_e, + RECOMMENDS_e, + SUGGESTS_e, + FRESHENS_e, + ENHANCES_e, + SUPPLEMENTS_e, + }; + + /** Ctor from string. + * Legal values for \a strval_r are the constants names + * (case insignificant). + * + * \throw PARSE if \a strval_r is not legal. + * \todo refine exceptions and check throw. + */ + explicit + Dep( const std::string & strval_r ); + + /** String representation of dependency type. + * \return The constants names lowercased. + */ + const std::string & asString() const; + + /** Enumarator provided for use in \c switch statement. */ + for_use_in_switch inSwitch() const + { return _type; } + + private: + /** Ctor to initialize the dependency type contants. */ + Dep( for_use_in_switch type_r ) + : _type( type_r ) + {} + /** The operator. */ + for_use_in_switch _type; + };
\ No newline at end of file diff --git a/swig/Dependencies.i b/swig/Dependencies.i new file mode 100644 index 0000000..d3aeec3 --- /dev/null +++ b/swig/Dependencies.i @@ -0,0 +1,14 @@ + +%ignore Dependencies::operator[]; + +struct Dependencies + { + CapSet & operator[]( Dep idx_r ) + { return _capsets[idx_r]; } + + const CapSet & operator[]( Dep idx_r ) const + { return const_cast<std::map<Dep,CapSet>&>(_capsets)[idx_r]; } + + private: + std::map<Dep,CapSet> _capsets; + };
\ No newline at end of file diff --git a/swig/Edition.i b/swig/Edition.i new file mode 100644 index 0000000..d7d88fa --- /dev/null +++ b/swig/Edition.i @@ -0,0 +1,32 @@ + +class Edition +{ + public: + typedef unsigned epoch_t; + static const epoch_t noepoch = 0; + static const Edition noedition; + public: + Edition(); + + Edition( const std::string & edition_r ); + Edition( const std::string & version_r, + const std::string & release_r, + epoch_t epoch_r = noepoch ); + Edition( const std::string & version_r, + const std::string & release_r, + const std::string & epoch_r ); + ~Edition(); + public: + epoch_t epoch() const; + const std::string & version() const; + const std::string & release() const; + std::string asString() const; + public: + static int compare( const Edition & lhs, const Edition & rhs ); + int compare( const Edition & rhs ) const; + typedef Compare<Edition> Compare; + typedef Range<Edition> CompareRange; + public: + static int match( const Edition & lhs, const Edition & rhs ); + int match( const Edition & rhs ) const; + };
\ No newline at end of file diff --git a/swig/KeyRing.i b/swig/KeyRing.i new file mode 100644 index 0000000..7ebb690 --- /dev/null +++ b/swig/KeyRing.i @@ -0,0 +1,20 @@ + + class KeyRing + { + public: + KeyRing(const Pathname &baseTmpDir); + void importKey( const PublicKey &key, bool trusted = false); + void dumpTrustedPublicKey( const std::string &id, std::ostream &stream ); + void dumpUntrustedPublicKey( const std::string &id, std::ostream &stream ); + void dumpPublicKey( const std::string &id, bool trusted, std::ostream &stream ); + std::string readSignatureKeyId( const Pathname &signature ); + bool isKeyTrusted( const std::string &id); + bool isKeyKnown( const std::string &id ); + void deleteKey( const std::string &id, bool trusted = false); + std::list<PublicKey> publicKeys(); + std::list<PublicKey> trustedPublicKeys(); + bool verifyFileSignatureWorkflow( const Pathname &file, const std::string filedesc, const Pathname &signature); + bool verifyFileSignature( const Pathname &file, const Pathname &signature); + bool verifyFileTrustedSignature( const Pathname &file, const Pathname &signature); + ~KeyRing(); + };
\ No newline at end of file diff --git a/swig/Kind.i b/swig/Kind.i new file mode 100644 index 0000000..3b11c1b --- /dev/null +++ b/swig/Kind.i @@ -0,0 +1,40 @@ + +%typemap(in) Resolvable::Kind { + + VALUE kindstring = rb_funcall( $input, rb_intern("to_s"), 0, 0); + kindstring = rb_funcall( kindstring, rb_intern("downcase"), 0, 0); + std::string s(RSTRING(pathstring)->ptr); + + // FIXME make the string lowercase first + + if ( s == "patch" ) + { + $1 == Patch::Kind; + } + if ( s == "package" ) + { + $1 == Package::Kind; + } + if ( s == "script" ) + { + $1 == Script::Kind; + } + if ( s == "message" ) + { + $1 == Message::Kind; + } + if ( s == "pattern" ) + { + $1 == Pattern::Kind; + } + if ( s == "Selection" ) + { + $1 == Selection::Kind; + } + +} + +%typemap(out) Kind { + const char *s = $1.asString().c_str(); + $result = ID2SYM(rb_intern(s)); +}
\ No newline at end of file diff --git a/swig/MediaSetAccess.i b/swig/MediaSetAccess.i new file mode 100644 index 0000000..fc0d1b1 --- /dev/null +++ b/swig/MediaSetAccess.i @@ -0,0 +1,19 @@ + +class MediaSetAccess +{ + friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj ); + + public: + /** + * creates a callback enabled media access for \param url and \param path. + * with only 1 media no verified + */ + MediaSetAccess( const Url &url, const Pathname &path ); + ~MediaSetAccess(); + + /** + * Sets a verifier for given media number + */ + void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier ); + Pathname provideFile(const Pathname & file, unsigned media_nr ); + };
\ No newline at end of file diff --git a/swig/NVR.i b/swig/NVR.i new file mode 100644 index 0000000..aa7bc36 --- /dev/null +++ b/swig/NVR.i @@ -0,0 +1,33 @@ + struct NVR + { + /** Default ctor */ + NVR() + {} + + /** Ctor */ + explicit + NVR( const std::string & name_r, + const Edition & edition_r = Edition() ) + : name( name_r ) + , edition( edition_r ) + {} + + /** Ctor from Resolvable::constPtr */ + explicit + NVR( ResTraits<Resolvable>::constPtrType res_r ); + + /** */ + std::string name; + /** */ + Edition edition; + + public: + /** Comparison mostly for std::container */ + static int compare( const NVR & lhs, const NVR & rhs ) + { + int res = lhs.name.compare( rhs.name ); + if ( res ) + return res; + return lhs.edition.compare( rhs.edition ); + } + };
\ No newline at end of file diff --git a/swig/NVRA.i b/swig/NVRA.i new file mode 100644 index 0000000..3678a88 --- /dev/null +++ b/swig/NVRA.i @@ -0,0 +1,40 @@ +struct NVRA : public NVR + { + /** Default ctor */ + NVRA() + {} + + /** Ctor */ + explicit + NVRA( const std::string & name_r, + const Edition & edition_r = Edition(), + const Arch & arch_r = Arch() ) + : NVR( name_r, edition_r ) + , arch( arch_r ) + {} + + /** Ctor */ + explicit + NVRA( const NVR & nvr_r, + const Arch & arch_r = Arch() ) + : NVR( nvr_r ) + , arch( arch_r ) + {} + + /** Ctor from Resolvable::constPtr */ + explicit + NVRA( ResTraits<Resolvable>::constPtrType res_r ); + + /** */ + Arch arch; + + public: + /** Comparison mostly for std::container */ + static int compare( const NVRA & lhs, const NVRA & rhs ) + { + int res = NVR::compare( lhs, rhs ); + if ( res ) + return res; + return lhs.arch.compare( rhs.arch ); + } + };
\ No newline at end of file diff --git a/swig/NVRAD.i b/swig/NVRAD.i new file mode 100644 index 0000000..8fa5660 --- /dev/null +++ b/swig/NVRAD.i @@ -0,0 +1,38 @@ + +struct NVRAD : public NVRA, public Dependencies + { + /** Default ctor */ + NVRAD() + {} + + /** Ctor */ + explicit + NVRAD( const std::string & name_r, + const Edition & edition_r = Edition(), + const Arch & arch_r = Arch(), + const Dependencies & deps_r = Dependencies() ) + : NVRA( name_r, edition_r, arch_r ) + , Dependencies( deps_r ) + {} + + /** Ctor */ + explicit + NVRAD( const NVRA & nvra_r, + const Dependencies & deps_r = Dependencies() ) + : NVRA( nvra_r ) + , Dependencies( deps_r ) + {} + + /** Ctor from Resolvable::constPtr */ + explicit + NVRAD( const NVR & nvr_r, + const Arch & arch_r = Arch(), + const Dependencies & deps_r = Dependencies() ) + : NVRA( nvr_r, arch_r ) + , Dependencies( deps_r ) + {} + + /** Ctor */ + explicit + NVRAD( Resolvable::constPtr res_r ); + };
\ No newline at end of file diff --git a/swig/OnMediaLocation.i b/swig/OnMediaLocation.i new file mode 100644 index 0000000..e55330d --- /dev/null +++ b/swig/OnMediaLocation.i @@ -0,0 +1,29 @@ + + class OnMediaLocation + { + friend std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj ); + + public: + /** Ctor */ + OnMediaLocation() + : _medianr( 1 ) + {} + + public: + unsigned medianr() const { return _medianr; } + const Pathname & filename() const { return _filename; } + const CheckSum & checksum() const { return _checksum; } + const ByteCount & downloadsize() const { return _downloadsize; } + + public: + OnMediaLocation & medianr( unsigned val_r ) { _medianr = val_r; return *this; } + OnMediaLocation & filename( const Pathname & val_r ) { _filename = val_r; return *this; } + OnMediaLocation & checksum( const CheckSum & val_r ) { _checksum = val_r; return *this; } + OnMediaLocation & downloadsize( const ByteCount & val_r ) { _downloadsize = val_r; return *this; } + + private: + unsigned _medianr; + Pathname _filename; + CheckSum _checksum; + ByteCount _downloadsize; + };
\ No newline at end of file diff --git a/swig/Package.i b/swig/Package.i new file mode 100644 index 0000000..8573772 --- /dev/null +++ b/swig/Package.i @@ -0,0 +1,59 @@ + + class Package : public ResObject + { + + public: + typedef detail::PackageImplIf Impl; + typedef Package Self; + typedef ResTraits<Self> TraitsType; + typedef TraitsType::PtrType Ptr; + typedef TraitsType::constPtrType constPtr; + + public: + /** + * Checksum the source says this package should have + */ + CheckSum checksum() const; + /** Get the package change log */ + Changelog changelog() const; + /** */ + std::string buildhost() const; + /** */ + std::string distribution() const; + /** */ + Label license() const; + /** */ + std::string packager() const; + /** */ + PackageGroup group() const; + /** Don't ship it as class Url, because it might be + * in fact anything but a legal Url. */ + std::string url() const; + /** */ + std::string os() const; + /** */ + Text prein() const; + /** */ + Text postin() const; + /** */ + Text preun() const; + /** */ + Text postun() const; + /** */ + ByteCount sourcesize() const; + /** */ + std::list<std::string> authors() const; + /** */ + std::list<std::string> filenames() const; + + /** Disk usage per directory */ + //DiskUsage diskusage() const; + + /** location in source */ + Pathname location() const; + + protected: + Package( const NVRAD & nvrad_r ); + /** Dtor */ + virtual ~Package(); + };
\ No newline at end of file diff --git a/swig/Pathname.i b/swig/Pathname.i new file mode 100644 index 0000000..66fa10e --- /dev/null +++ b/swig/Pathname.i @@ -0,0 +1,17 @@ + +%typemap(in) const Pathname & { + VALUE pathstring = rb_funcall( $input, rb_intern("to_s"), 0, 0); + Pathname *p = new Pathname( (RSTRING(pathstring)->ptr) ); + $1 = p; +} + +%typemap(freearg) const Pathname & { + delete $1; +} + +%typemap(out) Pathname { + rb_require("pathname"); + VALUE klass = rb_const_get( rb_cObject, rb_intern("Pathname")); + VALUE rbpathstr = rb_str_new2($1.asString().c_str()); + $result = rb_funcall( klass, rb_intern("new"), 1, rbpathstr); +}
\ No newline at end of file diff --git a/swig/PoolItem.i b/swig/PoolItem.i new file mode 100644 index 0000000..3f4880c --- /dev/null +++ b/swig/PoolItem.i @@ -0,0 +1,68 @@ + +class PoolItem_Ref + { + friend std::ostream & operator<<( std::ostream & str, const PoolItem_Ref & obj ); + + public: + /** Implementation */ + class Impl; + + public: + /** Default ctor for use in std::container. */ + PoolItem_Ref(); + + /** Ctor */ + explicit + PoolItem_Ref( ResObject::constPtr res_r ); + + /** Ctor */ + PoolItem_Ref( ResObject::constPtr res_r, const ResStatus & status_r ); + + /** Dtor */ + ~PoolItem_Ref(); + + public: + /** Returns the current status. */ + ResStatus & status() const; + + /** Reset status (applies autoprotection). */ + ResStatus & statusReset() const; + + /** Returns the ResObject::constPtr. + * \see \ref operator-> + */ + ResObject::constPtr resolvable() const; + + public: + /** Implicit conversion into ResObject::constPtr to + * support query filters operating on ResObject. + */ + operator ResObject::constPtr() const + { return resolvable(); } + + /** Forward \c -> access to ResObject. */ + ResObject::constPtr operator->() const + { return resolvable(); } + + /** Conversion to bool to allow pointer style tests + * for nonNULL \ref resolvable. */ + operator ResObject::constPtr::unspecified_bool_type() const + { return resolvable(); } + + private: + /** Pointer to implementation */ + RW_pointer<Impl> _pimpl; + + private: + /** \name tmp hack for save/restore state. */ + /** \todo get rid of it. */ + //@{ + friend class PoolItemSaver; + void saveState() const; + void restoreState() const; + bool sameState() const; + //@} + }; + /////////////////////////////////////////////////////////////////// + + typedef PoolItem_Ref PoolItem; diff --git a/swig/ResObject.i b/swig/ResObject.i new file mode 100644 index 0000000..793c866 --- /dev/null +++ b/swig/ResObject.i @@ -0,0 +1,32 @@ + +%template(ResObject_Ptr) intrusive_ptr<ResObject>; + +class ResObject : public Resolvable + { + public: + typedef detail::ResObjectImplIf Impl; + typedef ResObject Self; + typedef ResTraits<Self> TraitsType; + typedef intrusive_ptr<ResObject> Ptr; + typedef TraitsType::constPtrType constPtr; + + public: + Text summary() const; + Text description() const; + Text insnotify() const; + Text delnotify() const; + Text licenseToConfirm() const; + Vendor vendor() const; + ByteCount size() const; + ByteCount archivesize() const; + Source_Ref source() const; + unsigned sourceMediaNr() const; + bool installOnly() const; + Date buildtime() const; + Date installtime() const; + protected: + ResObject( const Kind & kind_r, + const NVRAD & nvrad_r ); + virtual ~ResObject(); + virtual std::ostream & dumpOn( std::ostream & str ) const; + }; diff --git a/swig/ResPool.i b/swig/ResPool.i new file mode 100644 index 0000000..5fc5589 --- /dev/null +++ b/swig/ResPool.i @@ -0,0 +1,151 @@ + +class ResPool + { + friend std::ostream & operator<<( std::ostream & str, const ResPool & obj ); + + public: + /** \ref zypp::pool::PoolItem */ + typedef pool::PoolTraits::Item Item; + typedef pool::PoolTraits::size_type size_type; + typedef pool::PoolTraits::const_iterator const_iterator; + typedef pool::PoolTraits::byName_iterator byName_iterator; + typedef pool::PoolTraits::byCapabilityIndex_iterator byCapabilityIndex_iterator; + typedef pool::PoolTraits::AdditionalCapSet AdditionalCapSet; + + public: + /** Default ctor: empty pool */ + ResPool(); + /** Dtor */ + ~ResPool(); + + public: + /** */ + bool empty() const; + /** */ + size_type size() const; + + public: + + /** \name Iterate through all ResObjects (all kinds). */ + //@{ + /** + const_iterator begin() const; + const_iterator end() const; + */ + //@} + + public: + /** \name Iterate through all ResObjects of a certain kind. */ + //@{ + typedef resfilter::ByKind ByKind; + typedef filter_iterator<ByKind,const_iterator> byKind_iterator; + + /* + byKind_iterator byKindBegin( const ResObject::Kind & kind_r ) const + { return make_filter_begin( ByKind(kind_r), *this ); } + + template<class _Res> + byKind_iterator byKindBegin() const + { return make_filter_begin( resfilter::byKind<_Res>(), *this ); } + + + byKind_iterator byKindEnd( const ResObject::Kind & kind_r ) const + { return make_filter_end( ByKind(kind_r), *this ); } + + template<class _Res> + byKind_iterator byKindEnd() const + { return make_filter_end( resfilter::byKind<_Res>(), *this ); } + //@} + */ + public: + /** \name Iterate through all ResObjects with a certain name (all kinds). */ + /* + //@{ + byName_iterator byNameBegin( const std::string & name_r ) const; + + byName_iterator byNameEnd( const std::string & name_r ) const; + //@} + */ + public: + /** \name Iterate through all ResObjects which have at least + * one Capability with index \a index_r in dependency \a depType_r. + */ + /* + //@{ + byCapabilityIndex_iterator byCapabilityIndexBegin( const std::string & index_r, Dep depType_r ) const; + + byCapabilityIndex_iterator byCapabilityIndexEnd( const std::string & index_r, Dep depType_r ) const; + //@} + */ + public: + /** \name Handling addition capabilities in the pool in order for solving it in + * a solver run. This is used for tasks like needing a package with the name "foo". + * The solver has to evaluate a proper package by his own. + * + * CAUTION: This has another semantic in the solver. The required resolvable has + * been set for installation (in the pool) only AFTER a solver run. + */ + + /** + * Handling additional requirement. E.G. need package "foo" and package + * "foo1" which has a greater version than 1.0: + * + * \code + * CapSet capset; + * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo")); + * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo1 > 1.0")); + * + * // The user is setting this capablility + * ResPool::AdditionalCapSet aCapSet; + * aCapSet[ResStatus::USER] = capset; + * + * setAdditionalRequire( aCapSet ); + * \endcode + */ + void setAdditionalRequire( const AdditionalCapSet & capset ) const; + AdditionalCapSet & additionalRequire() const; + + /** + * Handling additional conflicts. E.G. do not install anything which provides "foo": + * + * \code + * CapSet capset; + * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo")); + * + * // The user is setting this capablility + * ResPool::AdditionalCapSet aCapSet; + * aCapSet[ResStatus::USER] = capset; + * + * setAdditionalConflict( aCapSet ); + * \endcode + */ + void setAdditionalConflict( const AdditionalCapSet & capset ) const; + AdditionalCapSet & additionaConflict() const; + + /** + * Handling additional provides. This is used for ignoring a requirement. + * e.G. Do ignore the requirement "foo": + * + * \code + * CapSet capset; + * capset.insert (CapFactory().parse( ResTraits<Package>::kind, "foo")); + * + * // The user is setting this capablility + * ResPool::AdditionalCapSet aCapSet; + * aCapSet[ResStatus::USER] = capset; + * + * setAdditionalProvide( aCapSet ); + * \endcode + */ + void setAdditionalProvide( const AdditionalCapSet & capset ) const; + AdditionalCapSet & additionaProvide() const; + + private: + /** */ + friend class ResPoolManager; + /** Ctor */ + ResPool( pool::PoolTraits::Impl_constPtr impl_r ); + private: + /** Const access to implementation. */ + pool::PoolTraits::Impl_constPtr _pimpl; + };
\ No newline at end of file diff --git a/swig/ResStatus.i b/swig/ResStatus.i new file mode 100644 index 0000000..be0641d --- /dev/null +++ b/swig/ResStatus.i @@ -0,0 +1,373 @@ + +class ResStatus + { + friend std::ostream & operator<<( std::ostream & str, const ResStatus & obj ); + friend bool operator==( const ResStatus & lhs, const ResStatus & rhs ); + + public: + /** \name BitField range definitions. + * + * \note Enlarge FieldType if more bit's needed. It's not yet + * checked by the compiler. + */ + //@{ + typedef uint16_t FieldType; + typedef bit::BitField<FieldType> BitFieldType; + // Bit Ranges within FieldType defined by 1st bit and size: + typedef bit::Range<FieldType,0, 1> StateField; + typedef bit::Range<FieldType,StateField::end, 2> EstablishField; + typedef bit::Range<FieldType,EstablishField::end, 2> TransactField; + typedef bit::Range<FieldType,TransactField::end, 2> TransactByField; + typedef bit::Range<FieldType,TransactByField::end, 3> TransactDetailField; + typedef bit::Range<FieldType,TransactDetailField::end, 2> SolverStateField; + typedef bit::Range<FieldType,SolverStateField::end, 1> LicenceConfirmedField; + // enlarge FieldType if more bit's needed. It's not yet + // checked by the compiler. + //@} + public: + + /** \name Status values. + * + * Each enum corresponds to a BitField range. + * \note Take care that enumerator values actually fit into + * the corresponding field. It's not yet checked by the compiler. + */ + //@{ + enum StateValue + { + UNINSTALLED = bit::RangeValue<StateField,0>::value, + INSTALLED = bit::RangeValue<StateField,1>::value + }; + enum EstablishValue + { + UNDETERMINED = bit::RangeValue<EstablishField,0>::value, + UNNEEDED = bit::RangeValue<EstablishField,1>::value, // has freshens, none trigger + SATISFIED = bit::RangeValue<EstablishField,2>::value, // has none or triggered freshens, all requirements fulfilled + INCOMPLETE = bit::RangeValue<EstablishField,3>::value // installed: has none or triggered freshens, requirements unfulfilled + }; + enum TransactValue + { + KEEP_STATE = bit::RangeValue<TransactField,0>::value, + LOCKED = bit::RangeValue<TransactField,1>::value, // locked, must not transact + TRANSACT = bit::RangeValue<TransactField,2>::value // transact according to state + }; + enum TransactByValue + { + SOLVER = bit::RangeValue<TransactByField,0>::value, + APPL_LOW = bit::RangeValue<TransactByField,1>::value, + APPL_HIGH = bit::RangeValue<TransactByField,2>::value, + USER = bit::RangeValue<TransactByField,3>::value + }; + + enum DetailValue + { + /** Detail for no transact, i.e. reset any Install/RemoveDetailValue. */ + NO_DETAIL = bit::RangeValue<TransactDetailField,0>::value, + }; + + enum InstallDetailValue + { + EXPLICIT_INSTALL = bit::RangeValue<TransactDetailField,0>::value, + SOFT_INSTALL = bit::RangeValue<TransactDetailField,1>::value + }; + enum RemoveDetailValue + { + EXPLICIT_REMOVE = bit::RangeValue<TransactDetailField,0>::value, + SOFT_REMOVE = bit::RangeValue<TransactDetailField,1>::value, + DUE_TO_OBSOLETE = bit::RangeValue<TransactDetailField,2>::value, + DUE_TO_UNLINK = bit::RangeValue<TransactDetailField,3>::value, + DUE_TO_UPGRADE = bit::RangeValue<TransactDetailField,4>::value + }; + enum SolverStateValue + { + NORMAL = bit::RangeValue<SolverStateField,0>::value, // default, notthing special + SEEN = bit::RangeValue<SolverStateField,1>::value, // already seen during ResolverUpgrade + IMPOSSIBLE = bit::RangeValue<SolverStateField,2>::value // impossible to install + }; + + enum LicenceConfirmedValue + { + LICENCE_UNCONFIRMED = bit::RangeValue<LicenceConfirmedField,0>::value, + LICENCE_CONFIRMED = bit::RangeValue<LicenceConfirmedField,1>::value + }; + //@} + + public: + + /** Default ctor. */ + ResStatus(); + + /** Ctor setting the initial . */ + ResStatus( bool isInstalled_r ); + + /** Dtor. */ + ~ResStatus(); + + /** Debug helper returning the bitfield. + * It's save to expose the bitfield, as it can't be used to + * recreate a ResStatus. So it is not possible to bypass + * transition rules. + */ + BitFieldType bitfield() const + { return _bitfield; } + + public: + + bool isLicenceConfirmed() const + { return fieldValueIs<LicenceConfirmedField>( LICENCE_CONFIRMED ); } + + void setLicenceConfirmed( bool toVal_r = true ) + { fieldValueAssign<LicenceConfirmedField>( toVal_r ? LICENCE_CONFIRMED : LICENCE_UNCONFIRMED ); } + + public: + // These two are IMMUTABLE! + + bool isInstalled() const + { return fieldValueIs<StateField>( INSTALLED ); } + + bool isUninstalled() const + { return fieldValueIs<StateField>( UNINSTALLED ); } + + public: + + bool staysInstalled() const + { return isInstalled() && !transacts(); } + + bool wasInstalled() const { return staysInstalled(); } //for old status + + bool isToBeInstalled() const + { return isUninstalled() && transacts(); } + + bool staysUninstalled() const + { return isUninstalled() && !transacts(); } + + bool wasUninstalled() const { return staysUninstalled(); } // for old status + + bool isToBeUninstalled() const + { return isInstalled() && transacts(); } + + bool isUndetermined() const + { return fieldValueIs<EstablishField>( UNDETERMINED ); } + + bool isEstablishedUneeded() const + { return fieldValueIs<EstablishField>( UNNEEDED ); } + + bool isEstablishedSatisfied() const + { return fieldValueIs<EstablishField>( SATISFIED ); } + + bool isEstablishedIncomplete() const + { return fieldValueIs<EstablishField>( INCOMPLETE ); } + + bool isUnneeded() const + { return isUninstalled() && fieldValueIs<EstablishField>( UNNEEDED ); } + + bool isSatisfied() const + { return isUninstalled() && fieldValueIs<EstablishField>( SATISFIED ); } + + bool isComplete () const + { return isInstalled() && fieldValueIs<EstablishField>( SATISFIED ); } + + bool isIncomplete() const + { return isInstalled() && fieldValueIs<EstablishField>( INCOMPLETE ); } + + bool isNeeded() const + { return isUninstalled() && fieldValueIs<EstablishField>( INCOMPLETE ); } + + bool isLocked() const + { return fieldValueIs<TransactField>( LOCKED ); } + + bool isKept() const + { return fieldValueIs<TransactField>( KEEP_STATE ); } + + bool transacts() const + { return fieldValueIs<TransactField>( TRANSACT ); } + + TransactValue getTransactValue() const + { return (TransactValue)_bitfield.value<TransactField>(); } + + bool isBySolver() const + { return fieldValueIs<TransactByField>( SOLVER ); } + + bool isByApplLow() const + { return fieldValueIs<TransactByField>( APPL_LOW ); } + + bool isByApplHigh() const + { return fieldValueIs<TransactByField>( APPL_HIGH ); } + + bool isByUser() const + { return fieldValueIs<TransactByField>( USER ); } + + TransactByValue getTransactByValue() const + { return (TransactByValue)_bitfield.value<TransactByField>(); } + + bool isToBeUninstalledDueToObsolete () const + { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_OBSOLETE ); } + + bool isToBeUninstalledDueToUnlink() const + { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_UNLINK ); } + + bool isToBeUninstalledDueToUpgrade() const + { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( DUE_TO_UPGRADE ); } + + bool isToBeInstalledSoft () const + { return isToBeInstalled() && fieldValueIs<TransactDetailField>( SOFT_INSTALL ); } + + bool isToBeInstalledNotSoft () const + { return isToBeInstalled() && !fieldValueIs<TransactDetailField>( SOFT_INSTALL ); } + + + bool isToBeUninstalledSoft () const + { return isToBeUninstalled() && fieldValueIs<TransactDetailField>( SOFT_REMOVE ); } + + public: + + bool setTransactValue( TransactValue newVal_r, TransactByValue causer_r ); + bool setLock( bool toLock_r, TransactByValue causer_r ); + bool maySetLock( bool to_r, TransactByValue causer_r ); + bool setTransact( bool toTansact_r, TransactByValue causer_r ); + bool maySetTransact( bool val_r, TransactByValue causer ); + bool setSoftLock( TransactByValue causer_r ); + bool resetTransact( TransactByValue causer_r ); + bool setSoftTransact( bool toTansact_r, TransactByValue causer_r, + TransactByValue causerLimit_r ); + bool setSoftTransact( bool toTansact_r, TransactByValue causer_r ); + bool maySetSoftTransact( bool val_r, TransactByValue causer, + TransactByValue causerLimit_r ); + bool maySetSoftTransact( bool val_r, TransactByValue causer ); + bool setToBeInstalled (TransactByValue causer); + bool maySetToBeInstalled (TransactByValue causer); + bool setToBeUninstalled (TransactByValue causer); + bool maySetToBeUninstalled (TransactByValue causer); + bool setToBeUninstalledDueToUnlink ( ); + bool setToBeUninstalledDueToObsolete ( ); + bool setToBeUninstalledDueToUpgrade ( TransactByValue causer ); + bool setToBeInstalledSoft ( ); + bool setToBeUninstalledSoft ( ); + bool maySetToBeUninstalledSoft (); + bool isSoftInstall () { + return fieldValueIs<TransactDetailField> (SOFT_INSTALL); + } + + bool isSoftUninstall () { + return fieldValueIs<TransactDetailField> (SOFT_REMOVE); + } + + bool setSoftInstall (bool flag) { + fieldValueAssign<TransactDetailField>(flag?SOFT_INSTALL:0); + return true; + } + + bool setSoftUninstall (bool flag) { + fieldValueAssign<TransactDetailField>(flag?SOFT_REMOVE:0); + return true; + } + + bool setUndetermined () + { + fieldValueAssign<EstablishField>(UNDETERMINED); + return true; + } + + bool setUnneeded () + { + fieldValueAssign<EstablishField>(UNNEEDED); + return true; + } + + bool setSatisfied () + { + fieldValueAssign<EstablishField>(SATISFIED); + return true; + } + + bool setIncomplete () + { + fieldValueAssign<EstablishField>(INCOMPLETE); + return true; + } + + bool isSeen () const + { return fieldValueIs<SolverStateField>( SEEN ); } + + bool isImpossible () const + { return fieldValueIs<SolverStateField>( IMPOSSIBLE ); } + + bool setSeen (bool value) + { + fieldValueAssign<SolverStateField>( value ? SEEN : NORMAL ); + return true; + } + + bool setImpossible (bool value) + { + fieldValueAssign<SolverStateField>( value ? IMPOSSIBLE : NORMAL ); + return true; + } + + bool setStatus( ResStatus newStatus_r ) + { + // State field is immutable! + if ( _bitfield.value<StateField>() != newStatus_r._bitfield.value<StateField>() ) + return false; + // Transaction state change allowed? + if ( ! setTransactValue( newStatus_r.getTransactValue(), newStatus_r.getTransactByValue() ) ) + return false; + + // Ok, we take it all.. + _bitfield = newStatus_r._bitfield; + return true; + } + + /** \name Builtin ResStatus constants. */ + //@{ + static const ResStatus toBeInstalled; + static const ResStatus toBeInstalledSoft; + static const ResStatus toBeUninstalled; + static const ResStatus toBeUninstalledSoft; + static const ResStatus toBeUninstalledDueToUnlink; + static const ResStatus toBeUninstalledDueToObsolete; + static const ResStatus toBeUninstalledDueToUpgrade; + static const ResStatus installed; // installed, status after successful target 'install' commit + static const ResStatus uninstalled; // uninstalled, status after successful target 'uninstall' commit + static const ResStatus satisfied; // uninstalled, satisfied + static const ResStatus complete; // installed, satisfied + static const ResStatus unneeded; // uninstalled, unneeded + static const ResStatus needed; // uninstalled, incomplete + static const ResStatus incomplete; // installed, incomplete + static const ResStatus impossible; // uninstallable + //@} + + private: + /** Ctor for intialization of builtin constants. */ + ResStatus( StateValue s, + EstablishValue e = UNDETERMINED, + TransactValue t = KEEP_STATE, + InstallDetailValue i = EXPLICIT_INSTALL, + RemoveDetailValue r = EXPLICIT_REMOVE, + SolverStateValue ssv = NORMAL ); + + /** Return whether the corresponding Field has value \a val_r. + */ + template<class _Field> + bool fieldValueIs( FieldType val_r ) const + { return _bitfield.isEqual<_Field>( val_r ); } + + /** Set the corresponding Field to value \a val_r. + */ + template<class _Field> + void fieldValueAssign( FieldType val_r ) + { _bitfield.assign<_Field>( val_r ); } + + /** compare two values. + */ + template<class _Field> + bool isGreaterThan( FieldType val_r ) + { return _bitfield.value<_Field>() > val_r; } + + template<class _Field> + bool isLessThan( FieldType val_r ) + { return _bitfield.value<_Field>() < val_r; } + + private: + BitFieldType _bitfield; + };
\ No newline at end of file diff --git a/swig/ResStore.i b/swig/ResStore.i new file mode 100644 index 0000000..5abb934 --- /dev/null +++ b/swig/ResStore.i @@ -0,0 +1,21 @@ + +class ResStore +{ + typedef ResObject ResT; + typedef std::set<ResT::Ptr> StorageT; + typedef StorageT::size_type size_type; + + friend std::ostream & operator<<( std::ostream & str, const ResStore & obj ); + public: + ResStore(); + ~ResStore(); + bool empty() const; + size_type size() const; + //iterator insert( const ResT::Ptr & ptr_r ); + //size_type erase( const ResT::Ptr & ptr_r ); + //void erase( iterator pos_r ); + //void erase( iterator first_r, iterator last_r ) + //void erase( const Resolvable::Kind & kind_r ) + void clear(); +}; + diff --git a/swig/Resolvable.i b/swig/Resolvable.i new file mode 100644 index 0000000..892e782 --- /dev/null +++ b/swig/Resolvable.i @@ -0,0 +1,27 @@ + + class Resolvable + { + public: + typedef Resolvable Self; + typedef ResTraits<Self> TraitsType; + typedef TraitsType::KindType Kind; + typedef TraitsType::PtrType Ptr; + typedef TraitsType::constPtrType constPtr; + + const Kind & kind() const; + const std::string & name() const; + const Edition & edition() const; + const Arch & arch() const; + + //const CapSet & dep( Dep which_r ) const; + //const Dependencies & deps() const; + //void injectProvides( const Capability & cap_r ); + //void injectRequires( const Capability & cap_r ); + + protected: + Resolvable( const Kind & kind_r, + const NVRAD & nvrad_r ); + virtual ~Resolvable(); + virtual std::ostream & dumpOn( std::ostream & str ) const; + }; + diff --git a/swig/Source.i b/swig/Source.i new file mode 100644 index 0000000..2ccb547 --- /dev/null +++ b/swig/Source.i @@ -0,0 +1,72 @@ + +class Source_Ref +{ + friend std::ostream & operator<<( std::ostream & str, const Source_Ref & obj ); + friend bool operator==( const Source_Ref & lhs, const Source_Ref & rhs ); + friend bool operator<( const Source_Ref & lhs, const Source_Ref & rhs ); + + public: + typedef source::SourceImpl Impl; + typedef source::SourceImpl_Ptr Impl_Ptr; + + public: + Source_Ref(); + static const Source_Ref noSource; + + public: + typedef unsigned long NumericId; + NumericId numericId() const; + + public: + std::string checksum() const; + Date timestamp() const; + bool hasResolvablesOfKind( const zypp::Resolvable::Kind &kind ) const; + std::set<zypp::Resolvable::Kind> resolvableKinds() const; + bool resStoreInitialized() const; + const ResStore & resolvables() const; + const ResStore resolvables(zypp::Resolvable::Kind kind) const; + //const Pathname providePackage( Package::constPtr package ); + const Pathname provideFile(const Pathname & file_r, const unsigned media_nr = 1); + const Pathname provideDirTree(const Pathname & dir_r, const unsigned media_nr = 1); + const void releaseFile(const Pathname & file_r, const unsigned media_nr = 1); + const void releaseDir(const Pathname & dir_r, const unsigned media_nr = 1, bool recursive = false); + bool enabled() const; + void enable(); + void disable(); + bool autorefresh() const; + void setAutorefresh( bool enable_r ); + void refresh(); + void storeMetadata(const Pathname & cache_dir_r); + std::string alias (void) const; + void setAlias (const std::string & alias_r); + std::string type (void) const; + unsigned numberOfMedia(void) const; + std::string vendor (void) const; + std::string unique_id (void) const; + std::string id (void) const; + void setId (const std::string id_r); + unsigned priority (void) const; + void setPriority (unsigned p); + unsigned priorityUnsubscribed (void) const; + void setPriorityUnsubscribed (unsigned p); + bool subscribed (void) const; + void setSubscribed (bool s); + const Pathname & cacheDir (void) const; + const std::list<Pathname> publicKeys(); + Url url (void) const; + void setUrl( const Url & url ); + bool remote() const; + const Pathname & path (void) const; + bool baseSource() const; + public: + void changeMedia(const media::MediaId & media_r, const Pathname & path_r); + void redirect(unsigned media_nr, const Url & new_url); + void release(); + void reattach(const Pathname &attach_point); + media::MediaVerifierRef verifier(unsigned media_nr); + private: + friend class SourceFactory; + friend class source::SourceImpl; + explicit + Source_Ref( const Impl_Ptr & impl_r ); + };
\ No newline at end of file diff --git a/swig/SourceFactory.i b/swig/SourceFactory.i new file mode 100644 index 0000000..e876e24 --- /dev/null +++ b/swig/SourceFactory.i @@ -0,0 +1,64 @@ + +class SourceFactory + { + friend std::ostream & operator<<( std::ostream & str, const SourceFactory & obj ); + + public: + /** Default ctor */ + SourceFactory(); + /** Dtor */ + ~SourceFactory(); + + public: + /** Construct source. + * \throw EXCEPTION on fail + */ + Source_Ref createFrom( const source::SourceInfo & context ); + + /** Construct source from an implementation. + * Returns Source_Ref::noSource on NULL \a impl_r. + */ + //Source_Ref createFrom( const Source_Ref::Impl_Ptr & impl_r ); + + /** Construct source. + * \throw EXCEPTION on fail + */ + Source_Ref createFrom( const Url & url_r, const Pathname & path_r = "/", const std::string & alias_r = "", const Pathname & cache_dir_r = "", bool base_source = false ); + + /** Construct source of a given type. + * \throw EXCEPTION on fail + */ + Source_Ref createFrom( const std::string & type, const Url & url_r, const Pathname & path_r, const std::string & alias_r, const Pathname & cache_dir_r, bool base_source, tribool auto_refresh ); + + protected: + template<class _SourceImpl> + Source_Ref createSourceImplWorkflow( media::MediaId id, const source::SourceInfo &context ); + private: + /** Implementation */ + class Impl; + /** Pointer to implementation */ + RW_pointer<Impl> _pimpl; + + public: + struct ProductEntry { + Pathname _dir; + std::string _name; + ProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ){ + _dir = dir_r; + _name = name_r; + } + bool operator<( const ProductEntry & rhs ) const { + return( _dir.asString() < rhs._dir.asString() ); + } + }; + + typedef std::set<ProductEntry> ProductSet; + + /** Check which products are available on the media + * \throw Exception or MediaException on fail + */ + void listProducts( const Url & url_r, ProductSet & products_r ); + private: +// bool probeSource( const std::string name, boost::function<bool()> prober, callback::SendReport<CreateSourceReport> &report ); + void scanProductsFile( const Pathname & file_r, ProductSet & pset_r ) const; + };
\ No newline at end of file diff --git a/swig/Target.i b/swig/Target.i new file mode 100644 index 0000000..b831e51 --- /dev/null +++ b/swig/Target.i @@ -0,0 +1,69 @@ + +typedef intrusive_ptr<Target> Target_Ptr; + +class Target + { + public: + + typedef std::list<PoolItem_Ref> PoolItemList; + + public: + + /** All resolvables provided by the target. */ + const ResStore & resolvables(); + + /** + * reload the target in future calls if + * needed. + * note the loading can actually be delayed, but + * the next call to resolvables must reflect the + * status of the system. + */ + void reset(); + + /** + * load resolvables of certain kind in the internal store + * and return a iterator + * successive calls will be faster as resolvables are cached- + */ + ResStore::resfilter_const_iterator byKindBegin( const ResObject::Kind & kind_r ) const; + ResStore::resfilter_const_iterator byKindEnd( const ResObject::Kind & kind_r ) const; + + /** Null implementation */ + static Target_Ptr nullimpl(); + + /** Refference to the RPM database */ + //target::rpm::RpmDb & rpmDb(); + + /** If the package is installed and provides the file + Needed to evaluate split provides during Resolver::Upgrade() */ + bool providesFile (const std::string & name_str, const std::string & path_str) const; + + ResObject::constPtr whoOwnsFile (const std::string & path_str) const; + + /** JUST FOR TESTSUITE */ + /** Sort according to prereqs and media numbers + * \todo provide it as standalone algorithm + */ + void getResolvablesToInsDel ( const ResPool pool_r, + PoolItemList & dellist_r, + PoolItemList & instlist_r, + PoolItemList & srclist_r ) const; + +#ifndef STORAGE_DISABLED + /** enables the storage target */ + bool isStorageEnabled() const; + void enableStorage(const Pathname &root_r); +#endif + + /** Set the log file for target */ + bool setInstallationLogfile(const Pathname & path_r); + + /** Return the root set for this target */ + Pathname root() const; + + /** return the last modification date of the target */ + Date timestamp() const; + }; + +%template(Target_Ptr) intrusive_ptr<Target>;
\ No newline at end of file diff --git a/swig/TranslatedText.i b/swig/TranslatedText.i new file mode 100644 index 0000000..5f21754 --- /dev/null +++ b/swig/TranslatedText.i @@ -0,0 +1,44 @@ + class TranslatedText + { + friend std::ostream & operator<<( std::ostream & str, const TranslatedText & obj ); + + public: + /** Implementation */ + class Impl; + + public: + /** Default ctor */ + TranslatedText(); + /** Ctor */ + explicit + TranslatedText(const std::string &text, const Locale &lang = Locale()); + /** Ctor. */ + explicit + TranslatedText(const std::list<std::string> &text, const Locale &lang = Locale()); + /** Dtor */ + ~TranslatedText(); + + /** true if the text have no translations for any language */ + bool empty() const ; + + /** static default empty translated text */ + static const TranslatedText notext; + + public: + + /** Synonym for \ref text */ + std::string asString( const Locale &lang = Locale() ) const + { return text(lang); } + + std::string text( const Locale &lang = Locale() ) const; + std::set<Locale> locales() const; + + void setText( const std::string &text, const Locale &lang = Locale()); + void setText( const std::list<std::string> &text, const Locale &lang = Locale()); + + Locale detectLanguage() const; + + private: + /** Pointer to implementation */ + RWCOW_pointer<Impl> _pimpl; + };
\ No newline at end of file diff --git a/swig/Url.i b/swig/Url.i new file mode 100644 index 0000000..438afe3 --- /dev/null +++ b/swig/Url.i @@ -0,0 +1,12 @@ + +/* new(scheme, userinfo, host, port, registry, path, opaque, query, fragment, arg_check = false) */ + +%typemap(in) const Url & { + VALUE urlstring = rb_funcall( $input, rb_intern("to_s"), 0, 0); + Url *u = new Url( (RSTRING(urlstring)->ptr) ); + $1 = u; +} + +%typemap(freearg) const Url & { + delete $1; +} diff --git a/swig/ZYppCommitPolicy.i b/swig/ZYppCommitPolicy.i new file mode 100644 index 0000000..17a0199 --- /dev/null +++ b/swig/ZYppCommitPolicy.i @@ -0,0 +1,52 @@ +class ZYppCommitPolicy + { + public: + ZYppCommitPolicy() + : _restrictToMedia ( 0 ) + , _dryRun ( false ) + , _rpmNoSignature ( false ) + , _syncPoolAfterCommit( true ) + {} + + public: + unsigned restrictToMedia() const + { return _restrictToMedia; } + + bool dryRun() const + { return _dryRun; } + + bool rpmNoSignature() const + { return _rpmNoSignature; } + + bool syncPoolAfterCommit() const + { return _syncPoolAfterCommit; } + + public: + /** Restrict commit to a certain media number + * \deprecated + */ + ZYppCommitPolicy & restrictToMedia( unsigned mediaNr_r ) + { _restrictToMedia = mediaNr_r; return *this; } + + /** Process all media (default) */ + ZYppCommitPolicy & allMedia() + { return restrictToMedia( 0 ); } + + /** Set dry run (default: false) */ + ZYppCommitPolicy & dryRun( bool yesNo_r = true ) + { _dryRun = yesNo_r; return *this; } + + /** Use rpm option --nosignature (default: false) */ + ZYppCommitPolicy & rpmNoSignature( bool yesNo_r = true ) + { _rpmNoSignature = yesNo_r; return *this; } + + /** Kepp pool in sync with the Target databases after commit (default: true) */ + ZYppCommitPolicy & syncPoolAfterCommit( bool yesNo_r = true ) + { _syncPoolAfterCommit = yesNo_r; return *this; } + + private: + unsigned _restrictToMedia; + bool _dryRun; + bool _rpmNoSignature; + bool _syncPoolAfterCommit; + };
\ No newline at end of file diff --git a/swig/ZYppCommitResult.i b/swig/ZYppCommitResult.i new file mode 100644 index 0000000..18918f0 --- /dev/null +++ b/swig/ZYppCommitResult.i @@ -0,0 +1,26 @@ +struct ZYppCommitResult + { + ZYppCommitResult() + : _result(0) + {} + + typedef std::list<PoolItem_Ref> PoolItemList; + + /** + * number of committed resolvables + **/ + int _result; + + /** + * list of resolvables with error + **/ + PoolItemList _errors; + /** + * list of resolvables remaining (due to wrong media) + **/ + PoolItemList _remaining; + /** + * list of kind:source resolvables remaining (due to wrong media) + **/ + PoolItemList _srcremaining; + };
\ No newline at end of file diff --git a/swig/ZYppFactory.i b/swig/ZYppFactory.i new file mode 100644 index 0000000..46a8184 --- /dev/null +++ b/swig/ZYppFactory.i @@ -0,0 +1,12 @@ + +%template(ZYpp_Ptr) intrusive_ptr<ZYpp>; + +class ZYppFactory +{ +public: + static ZYppFactory instance(); + ~ZYppFactory(); + ZYpp::Ptr getZYpp() const; + private: + ZYppFactory(); +}; diff --git a/swig/python.i b/swig/python.i new file mode 100644 index 0000000..1c9ea7f --- /dev/null +++ b/swig/python.i @@ -0,0 +1,13 @@ + +%define iter( cl ) +%extend cl { + %pythoncode %{ + def __iter__(self): + r = self.range() + while not r.empty(): + yield r.head() + r.removeFirst() + %} +}; +%enddef + diff --git a/swig/ruby.i b/swig/ruby.i new file mode 100644 index 0000000..5ab280f --- /dev/null +++ b/swig/ruby.i @@ -0,0 +1,79 @@ + +%rename("asString") foo(to_s); + +#define iter( cl, storetype ) \ +%mixin cl "Enumerable"; \ +%extend cl { \ + void each() { \ + cl::iterator i = self->begin(); \ + while ( i != self->end() ) { \ + rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(storetype), 1)); \ + ++i; \ + } \ + } \ +} + +#define iter2( cl, storetype ) \ +%mixin cl "Enumerable"; \ +%extend cl { \ + void each() { \ + cl::iterator i = self->begin(); \ + while ( i != self->end() ) { \ + rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(storetype), 0)); \ + ++i; \ + } \ + } \ +} + +%extend Target { + void each_by_kind( const ResObject::Kind & kind_r ) + { + ResStore::resfilter_const_iterator i = self->byKindBegin( kind_r ); + while ( i != self->byKindEnd( kind_r ) ) { + rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(ResStore::Ptr), 0)); + ++i; + } + } +} + +%extend ResPool { + void each() + { + ResPool::const_iterator i = self->begin(); + while ( i != self->end() ) { + rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem_Ref, 0)); + ++i; + } + } +} + +%extend ResPool { + void each_by_kind( const ResObject::Kind & kind_r ) + { + ResPool::byKind_iterator i = self->byKindBegin( kind_r ); + while ( i != self->byKindEnd( kind_r ) ) { + rb_yield( SWIG_NewPointerObj( (void *) &*i, SWIGTYPE_p_PoolItem_Ref, 0)); + ++i; + } + } +} + +%extend ResPool { + void each_by_name( const std::string &name ) + { + ResPool::byName_iterator i = self->byNameBegin( name ); + while ( i != self->byNameEnd( name ) ) { + rb_yield( SWIG_NewPointerObj( (void *) &*i, $descriptor(PoolItem_Ref), 0)); + ++i; + } + } +} + + +%rename(asString) to_s; + +%rename("dryRun=") ZYppCommitPolicy::dryRun(bool); +%rename("rpmNoSignature=") ZYppCommitPolicy::rpmNoSignature(bool); +%rename("syncPoolAfterCommit=") ZYppCommitPolicy::syncPoolAfterCommit(bool); + + diff --git a/swig/zypp.i b/swig/zypp.i new file mode 100644 index 0000000..a987a35 --- /dev/null +++ b/swig/zypp.i @@ -0,0 +1,146 @@ +%module rzypp +%include std_string.i + %{ + /* Includes the header in the wrapper code */ + + #include "zypp/base/PtrTypes.h" + #include <zypp/Edition.h> + #include <zypp/ResTraits.h> + #include <zypp/ResPoolProxy.h> + #include <zypp/ResStore.h> + #include <zypp/ZYppFactory.h> + #include <zypp/ZYpp.h> + #include <zypp/Pathname.h> + #include "zypp/base/ReferenceCounted.h" + #include "zypp/SourceFactory.h" + #include "zypp/Source.h" + #include "zypp/ResObject.h" + #include "zypp/Target.h" + #include "zypp/target/TargetImpl.h" +#include "zypp/TranslatedText.h" + #include "zypp/CapFactory.h" + #include "zypp/Package.h" +#include "zypp/ResFilters.h" +#include "zypp/source/OnMediaLocation.h" +#include "zypp/MediaSetAccess.h" + + using namespace boost; + using namespace zypp; + using namespace zypp::resfilter; + + %} + +#ifdef SWIGRUBY +%include "ruby.i" +#endif + +%rename("+") "operator+"; +%rename("<<") "operator<<"; +%rename("!=") "operator!="; +%rename("!") "operator!"; +%rename("==") "operator=="; + +/* Parse the header file to generate wrappers */ +%ignore zypp::operator<<( std::ostream & str, const ZYppFactory & obj ); +%ignore zypp::base::operator<<( std::ostream & str, const ReferenceCounted & obj ); + +/* +//%include "zypp/base/Deprecated.h" +//%include "zypp/base/PtrTypes.h" +*/ + + +template < typename T > +class intrusive_ptr { + public: + T *operator->(); +}; + +%include "Pathname.i" +%include "Arch.i" +%include "ResStore.i" +%include "Edition.i" +%include "Kind.i" +%include "Date.i" +%include "Resolvable.i" +%include "ByteCount.i" +%include "Source.i" +%include "SourceFactory.i" +%include "ResObject.i" +%include "TranslatedText.i" +%include "CheckSum.i" +%include "Dependencies.i" +%include "Capability.i" +%include "CapMatch.i" +%include "CapFactory.i" +%include "NVR.i" +%include "NVRA.i" +%include "NVRAD.i" +%include "Package.i" +%include "KeyRing.i" +%include "Target.i" +%include "ResStatus.i" +%include "Dep.i" +%include "PoolItem.i" +%include "ResPool.i" +%include "ZYppCommitPolicy.i" +%include "ZYppCommitResult.i" +%include "Url.i" +%include "MediaSetAccess.i" + +/* define iterators using swig macros */ +iter2( ResStore, ResObject::Ptr ) + +class ZYpp +{ + public: + typedef intrusive_ptr<ZYpp> Ptr; + typedef intrusive_ptr<const ZYpp> constPtr; + public: + + ResPool pool() const; + ResPoolProxy poolProxy() const; + + /* + SourceFeed_Ref sourceFeed() const; + */ + void addResolvables (const ResStore& store, bool installed = false); + void removeResolvables (const ResStore& store); + /* + DiskUsageCounter::MountPointSet diskUsage(); + void setPartitions(const DiskUsageCounter::MountPointSet &mp); + */ + Target_Ptr target() const; + void initializeTarget(const Pathname & root); + void finishTarget(); + + typedef ZYppCommitResult CommitResult; + ZYppCommitResult commit( const ZYppCommitPolicy & policy_r ); + + Resolver_Ptr resolver() const; + KeyRing_Ptr keyRing() const; + + /* + void setTextLocale( const Locale & textLocale_r ); + Locale getTextLocale() const; + typedef std::set<Locale> LocaleSet; + void setRequestedLocales( const LocaleSet & locales_r ); + LocaleSet getRequestedLocales() const; + LocaleSet getAvailableLocales() const; + void availableLocale( const Locale & locale_r ); + */ + Pathname homePath() const; + Pathname tmpPath() const; + void setHomePath( const Pathname & path ); + + Arch architecture() const; + void setArchitecture( const Arch & arch ); + + protected: + virtual ~ZYpp(); + private: + friend class ZYppFactory; + explicit ZYpp( const Impl_Ptr & impl_r ); +}; + +%include "ZYppFactory.i"
\ No newline at end of file diff --git a/zypp-bindings.spec.cmake b/zypp-bindings.spec.cmake new file mode 100644 index 0000000..2e4b488 --- /dev/null +++ b/zypp-bindings.spec.cmake @@ -0,0 +1,57 @@ +# +# spec file for package ruby-zypp (Version 0.0_svn) +# +# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + +Name: zypp-bindngs +Version: 0.1 +Release: 1 +License: GPL +Group: Development/Languages/Ruby +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: gcc-c++, ruby-devel +BuildRequires: libzypp-devel >= 3.0.0 +Requires: libzypp >= 3.0.0 +Source: %{name}.tar.bz2 +Summary: Language Bindings for libzypp +%description +Language Bindings for libzypp + + Authors: +---------- + Duncan Mac-Vicar P. <dmacvicar@suse.de> + Klaus Kaempf <kkaempf@suse.de> + +%prep +%setup -n %{name} + +%build +pushd src + ruby extconf.rb + make +popd +#make -C tests check + +%install +%{__install} -D -m 0755 src/rzypp.so \ + %{buildroot}%{_libdir}/ruby/%{rb_ver}/%{rb_arch}/rzypp.so + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-,root,root,-) +%{_libdir}/ruby/%{rb_ver}/%{rb_arch}/rzypp.so +%doc MAINTAINER COPYING README +%doc tests/*.rb + +%changelog -n ruby-zypp +* Tue Mar 21 2006 - mrueckert@suse.de +- Initial package |