diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | COPYING | 20 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | VERSION.cmake | 4 | ||||
-rw-r--r-- | examples/perl/list_target_resolvables.pl | 28 | ||||
-rw-r--r-- | examples/python/SimpleWalkthrough.py | 147 | ||||
-rw-r--r-- | libzypp-bindings.spec.cmake | 12 | ||||
-rw-r--r-- | package/libzypp-bindings.changes | 43 | ||||
-rw-r--r-- | packaging/libzypp-bindings.spec | 2 | ||||
-rw-r--r-- | swig/Arch.i | 16 | ||||
-rw-r--r-- | swig/CMakeLists.txt | 47 | ||||
-rw-r--r-- | swig/Capabilities.i | 18 | ||||
-rw-r--r-- | swig/PoolItem.i | 1 | ||||
-rw-r--r-- | swig/RepoInfo.i | 4 | ||||
-rw-r--r-- | swig/RepoManager.i | 3 | ||||
-rw-r--r-- | swig/ResPool.i | 37 | ||||
-rw-r--r-- | swig/ResTraits.i | 1 | ||||
-rw-r--r-- | swig/Resolvable.i | 2 | ||||
-rw-r--r-- | swig/Resolver.i | 18 | ||||
-rw-r--r-- | swig/ZYppFactory.i | 14 | ||||
-rw-r--r-- | swig/ruby/tests/arch.rb | 31 | ||||
-rw-r--r-- | swig/ruby/tests/bytecount.rb | 9 | ||||
-rw-r--r-- | swig/ruby/tests/target.rb | 15 | ||||
-rw-r--r-- | swig/zypp.i | 26 |
24 files changed, 408 insertions, 95 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e02ba6b..30b0841 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,7 +66,7 @@ FIND_PATH( BOOST_SMARTPTR_INCLUDE_DIR boost/smart_ptr/shared_ptr.hpp /usr/local/include ) IF( BOOST_SMARTPTR_INCLUDE_DIR ) - SET( SWIG_DEFINITIONS ${SWIG_DEFINITIONS} -DBOOST_SMARTPTR_INCLUDE_DIR ) + SET( SWIG_DEFINITIONS ${SWIG_DEFINITIONS} -I${BOOST_SMARTPTR_INCLUDE_DIR} -DBOOST_SMARTPTR_INCLUDE_DIR ) ENDIF( BOOST_SMARTPTR_INCLUDE_DIR ) # Now into SWIG @@ -0,0 +1,20 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +Copyright (C) 2007-2015 SUSE Linux Products GmbH + +ZYpp-bindings is licensed under the GNU General Public License version 2 +or later. The text of the GNU General Public License can be viewed at +http://www.gnu.org/licenses/gpl.html + +As a special exception, you have permission to link this program +with the following libraries and distribute executables, as long as you +follow the requirements of the GNU GPL in regard to all of the +software in the executable aside from the following libraries: +- OpenSSL (http://www.openssl.org) @@ -1,4 +1,7 @@ +The project is discontinued! + +-------------------------------------------------------------------------------- Attempt to create generated bindings for libzypp. Not restricted to one language. diff --git a/VERSION.cmake b/VERSION.cmake index b0f8cf7..0920943 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1,4 +1,4 @@ # on maintenance branch add a 2nd level to patch (p.1, p.2, ...) SET(VERSION_MAJOR "0") -SET(VERSION_MINOR "6") -SET(VERSION_PATCH "2") +SET(VERSION_MINOR "7") +SET(VERSION_PATCH "4") diff --git a/examples/perl/list_target_resolvables.pl b/examples/perl/list_target_resolvables.pl index 61cd765..522eaed 100644 --- a/examples/perl/list_target_resolvables.pl +++ b/examples/perl/list_target_resolvables.pl @@ -5,18 +5,32 @@ $zypp = $z->getZYpp; $t = $zypp->initializeTarget(zypp::Pathname->new("/")); -$repo = $zypp->target; -$store = $repo->resolvables; +my $repoManager = zypp::RepoManager::new(); +my $repos = zypp::RepoManager::knownRepositories($repoManager); + +foreach $repo ( @{$repos} ) { + if ( $repo->enabled() ) { + print("Caching repo: ".$repo->name."\n"); + if ( ! zypp::RepoManager::isCached($repoManager,$repo) ) { + print("Rebuilding cache for: ".$repo->name."\n"); + zypp::RepoManager::buildCache($repoManager,$repo); + } + zypp::RepoManager::loadFromCache($repoManager,$repo); + } +} + +$store = $zypp->pool; $it_b = $store->cBegin; +$it_e = $store->cEnd; -while ($store->iterator_equal($it_b, $store->cEnd) ne 1){ +while ($store->iterator_equal($it_b, $it_e) ne 1){ $pkg = $store->iterator_value($it_b); - print $pkg->kindToS, " ", $pkg->name, " ", $pkg->edition->asString; - print $pkg->arch->asString, "\n"; + print $pkg->kind->asString, " ", $pkg->name, " ", $pkg->edition->asString; + print $pkg->arch->string, "\n"; print " Summary: ", $pkg->summary, "\n"; - print " Size: ", $pkg->size, "\n"; - print " Vendor: ", $pkg->vendor, "\n"; + print " Size: ", $pkg->installSize->asString, "\n"; + print " Vendor: ", $pkg->vendor->asString, "\n"; print " BuildTime: ", $pkg->buildtime->asString, "\n"; $it_b = $store->iterator_incr($it_b); diff --git a/examples/python/SimpleWalkthrough.py b/examples/python/SimpleWalkthrough.py new file mode 100644 index 0000000..a1b6d94 --- /dev/null +++ b/examples/python/SimpleWalkthrough.py @@ -0,0 +1,147 @@ +#! /usr/bin/python +import zypp +# ======================================================================================== + +def poolInstall( Z, capstr ): + print "Request: install %s" % capstr + Z.resolver().addRequire( zypp.Capability( capstr ) ) + +def poolRemove( Z, capstr ): + print "Request: delete %s" % capstr + Z.resolver().addConflict( zypp.Capability( capstr ) ) + +def poolPrintTransaction( Z ): + todo = Z.pool().getTransaction() + for item in todo._toDelete: + print '-- %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() ) + for item in todo._toInstall: + print '++ %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() ) + +def poolResolve( Z ): + print "Resolve pool:" + while not Z.resolver().resolvePool(): + # Print _all_ problems and possible solutions: + problems = Z.resolver().problems() + pn = 0 + for problem in problems: + pn += 1 + print "Problem %d:" % pn + print "==============================" + print problem.description() + if problem.details(): + print problem.details() + print "------------------------------" + sn = 0 + for solution in problem.solutions(): + sn += 1 + print "Solution %d.%d:" % ( pn, sn ) + print solution.description() + if solution.details(): + print solution.details() + print "==============================" + print + + # Faked user interaction: stupidly pick all 1st solutions (don't do this in real life!) + # + # In real life you probably pick just a single solution + # and re-solve immedaitely, because one solution may solve + # multiple ploblems - or create new ones. + # + pickedSolutions = zypp.ProblemSolutionList() + pn = 0 + for problem in problems: + pn += 1 + sn = 0 + for solution in problem.solutions(): + sn += 1 + print "Stupidly pick solution %d.%d" % ( pn, sn ) + pickedSolutions.push_back( solution ) + break + # Apply picked solutions: + Z.resolver().applySolutions( pickedSolutions ) + + # + print "Example stops here instead of starting a new iteration..." + print + raise BaseException("Solver Error") + + poolPrintTransaction( Z ) + print "[done]" + +def poolUpdate( Z ): + # In contrary to + print "Update pool:" + Z.resolver().doUpdate() + poolPrintTransaction( Z ) + print "[done]" + +# ======================================================================================== +Z = zypp.ZYppFactory_instance().getZYpp() + +# Load system rooted at "/"... +# +Z.initializeTarget( zypp.Pathname("/") ) +Z.target().load(); + +# Load all enabled repositories... +# +repoManager = zypp.RepoManager() +for repo in repoManager.knownRepositories(): + if not repo.enabled(): + continue + if not repoManager.isCached( repo ): + repoManager.buildCache( repo ) + repoManager.loadFromCache( repo ); + +# Now all installed and available items are in the pool: +# +print "Known items: %d" % ( Z.pool().size() ) +if True: + # Iterate the pool to query items. PoolItems are not just packages + # but also patterns, patches, products, ... + # PoolItem provides the common attributes and status. For specific + # attibutes cast the item inot the specific kind. + print "Printing just the Products..." + for item in Z.pool(): + if not zypp.isKindProduct( item ): + continue + + if item.status().isInstalled(): + t = "i" + else: + t = "*" + print "%s %s:%s-%s.%s\t(%s)" % ( t, + item.kind(), + item.name(), + item.edition(), + item.arch(), + item.repoInfo().alias() ) + + # How to access e.g. product specific attributes: + if zypp.isKindProduct( item ): + prod = zypp.asKindProduct( item ) + print " %s (%s)" % ( prod.shortName(), prod.flavor() ) + print + +# Building and resolving a transaction: +# +doUpdate = False +if doUpdate: + # Simply try to update all installed packages: + poolUpdate( Z ) +else: + # Add jobs to the pools resolver + # and finally resolve the jobs. + poolInstall( Z, "libzypp = 13.9.0-13.1" ) + poolInstall( Z, "pattern:unknown" ) + poolRemove( Z, "xteddy < 1.0" ) + poolResolve( Z ) + +# finally install (here dryRun) +# +policy = zypp.ZYppCommitPolicy() +policy.syncPoolAfterCommit( False ) +policy.dryRun( True ) + +result = Z.commit( policy ) +print result diff --git a/libzypp-bindings.spec.cmake b/libzypp-bindings.spec.cmake index 668dc6e..8ece7ec 100644 --- a/libzypp-bindings.spec.cmake +++ b/libzypp-bindings.spec.cmake @@ -26,10 +26,10 @@ Group: Development/Sources BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: cmake BuildRequires: gcc-c++ >= 4.5 -BuildRequires: libzypp-devel >= 14.5.0 -BuildRequires: python-devel +BuildRequires: libzypp-devel >= 15.11.0 +BuildRequires: python-devel < 3 BuildRequires: ruby-devel -BuildRequires: swig >= 1.3.40 +BuildRequires: swig >= 2 Source: %{name}-%{version}.tar.bz2 %description @@ -69,7 +69,7 @@ Summary: Ruby bindings for libzypp Group: Development/Languages/Ruby %description -n ruby-zypp -- +Ruby bindings for libzypp. %files -n ruby-zypp %defattr(-,root,root,-) @@ -84,7 +84,7 @@ Group: Development/Languages/Ruby Summary: Python bindings for libzypp Group: Development/Languages/Python %description -n python-zypp -- +Python bindings for libzypp. %files -n python-zypp %defattr(-,root,root,-) @@ -97,7 +97,7 @@ Summary: Perl bindings for libzypp Group: Development/Languages/Perl %description -n perl-zypp -- +Perl bindings for libzypp. %files -n perl-zypp %defattr(-,root,root,-) diff --git a/package/libzypp-bindings.changes b/package/libzypp-bindings.changes index 7f19f52..f123b13 100644 --- a/package/libzypp-bindings.changes +++ b/package/libzypp-bindings.changes @@ -1,4 +1,47 @@ ------------------------------------------------------------------- +Thu Oct 12 12:40:09 CEST 2017 - ma@suse.com + +- by V. Zhestkov: Adapt bindings to work with boost-1.62, + Fix perl examples +- 0.7.4 + +------------------------------------------------------------------- +Mon Aug 10 17:07:09 CEST 2015 - ma@suse.com + +- Adapt to libzypp changes due to FATE#318778 +- 0.7.3 + +------------------------------------------------------------------- +Mon Jul 20 13:44:19 CEST 2015 - ma@suse.de + +- Don't expose resolver internals (due to FATE#318099) +- 0.7.2 + +------------------------------------------------------------------- +Thu May 21 13:09:43 CEST 2015 - ma@suse.de + +- Fix test to run with ruby-2.2 +- 0.7.1 + +------------------------------------------------------------------- +Mon May 4 10:17:32 CEST 2015 - ma@suse.de + +- Adapt to libzypp-15.x (bnc#899755) +- 0.7.0 + +------------------------------------------------------------------- +Thu Dec 18 11:28:55 CET 2014 - ma@suse.de + +- Enforce Python 2.7 libzypp-bindings is not yet ready for Python 3. +- 0.6.4 + +------------------------------------------------------------------- +Fri Oct 17 11:22:13 CEST 2014 - ma@suse.de + +- Adapt to libzypp changes. +- 0.6.3 + +------------------------------------------------------------------- Thu Aug 14 14:45:12 CEST 2014 - mls@suse.de - work around syntax errors because of __attribute__ diff --git a/packaging/libzypp-bindings.spec b/packaging/libzypp-bindings.spec index 305b869..8c1ca95 100644 --- a/packaging/libzypp-bindings.spec +++ b/packaging/libzypp-bindings.spec @@ -8,7 +8,7 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: libzypp-bindings -Version: 0.6.1 +Version: 0.7.4 Release: 0 License: GPL-2.0+ Summary: Bindings for libzypp diff --git a/swig/Arch.i b/swig/Arch.i index 1129197..09ada80 100644 --- a/swig/Arch.i +++ b/swig/Arch.i @@ -100,6 +100,22 @@ class Arch { * builtin: armv7hl */ static Arch armv7hl() { return zypp::Arch_armv7hl; } + /* + * builtin: armv7tnhl + */ + static Arch armv7tnhl() { return zypp::Arch_armv7tnhl; } + /* + * builtin: armv7thl + */ + static Arch armv7thl() { return zypp::Arch_armv7thl; } + /* + * builtin: armv7nhl + */ + static Arch armv7nhl() { return zypp::Arch_armv7nhl; } + /* + * builtin: armv7hl + */ + static Arch armv7hl() { return zypp::Arch_armv7hl; } /* * builtin: armv7l diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index ea807f6..acf23f6 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -8,22 +8,37 @@ ENABLE_TESTING() SET( SWIG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}/zypp.i" ) # +# Allow to build only a subset of language bindings via options +# + +OPTION(BUILD_RUBY_BINDINGS "Build Ruby bindings" ON) +OPTION(BUILD_PYTHON2_BINDINGS "Build Python 2 bindings" ON) +OPTION(BUILD_PERL5_BINDINGS "Build Perl 5 bindings" ON) + +# # Let's see which target languages are available # -FIND_PACKAGE(Ruby) -FIND_PACKAGE(PythonLibs) -FIND_PACKAGE(Perl) - - -IF (RUBY_LIBRARY AND RUBY_INCLUDE_PATH) - ADD_SUBDIRECTORY(ruby) -ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH) - -IF (PYTHON_LIBRARY) - ADD_SUBDIRECTORY(python) -ENDIF(PYTHON_LIBRARY) - -#IF (PERL_EXECUTABLE) -# ADD_SUBDIRECTORY(perl5) -#ENDIF (PERL_EXECUTABLE) +IF(BUILD_RUBY_BINDINGS) + FIND_PACKAGE(Ruby) + IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH) + ADD_SUBDIRECTORY(ruby) + ENDIF() +ENDIF() + +IF(BUILD_PYTHON2_BINDINGS) + # Enforce Python 2.7, libzypp-bindings does not yet work with Python3 + set(PythonLibs_FIND_VERSION 2.7) + set(PythonLibs_FIND_VERSION_MAJOR 2) + FIND_PACKAGE(PythonLibs) + IF(PYTHON_LIBRARY) + ADD_SUBDIRECTORY(python) + ENDIF() +ENDIF() + +#IF(BUILD_PERL5_BINDINGS) +# FIND_PACKAGE(Perl) +# IF(PERL_EXECUTABLE) +# ADD_SUBDIRECTORY(perl5) +# ENDIF() +#ENDIF() diff --git a/swig/Capabilities.i b/swig/Capabilities.i index 88e5c30..624b921 100644 --- a/swig/Capabilities.i +++ b/swig/Capabilities.i @@ -8,3 +8,21 @@ by_value_iterator(zypp::Capabilities); #ifdef SWIGPERL5 forwarditer(zypp::Capabilities, zypp::Capability); #endif + +#ifdef SWIGPYTHON +%include "std_vector.i" +%include "std_string.i" + +%template(StringVector) std::vector<std::string>; + +%extend zypp::Capabilities { + std::vector<std::string> CapNames() + { + std::vector<std::string> caps; + for (zypp::Capabilities::const_iterator it = self->begin(); it != self->end(); ++it) { + caps.push_back((*it).asString()); + } + return caps; + } +} +#endif diff --git a/swig/PoolItem.i b/swig/PoolItem.i index 34a2eeb..ca4147c 100644 --- a/swig/PoolItem.i +++ b/swig/PoolItem.i @@ -1,3 +1,4 @@ +%template(SolvableType_PoolItem) zypp::sat::SolvableType<zypp::PoolItem>; %include <zypp/PoolItem.h> #ifdef SWIGPERL5 diff --git a/swig/RepoInfo.i b/swig/RepoInfo.i index 4f6c06c..80b2dd6 100644 --- a/swig/RepoInfo.i +++ b/swig/RepoInfo.i @@ -1,6 +1,6 @@ #ifdef SWIGPERL5 #else -%template(UrlSet) std::set<zypp::Url>; +%template(UrlSet) std::list<zypp::Url>; #endif namespace zypp @@ -31,7 +31,7 @@ namespace zypp typedef std::list<zypp::RepoInfo> RepoInfoList; %template(RepoInfoList) std::list<zypp::RepoInfo>; -%extend zypp::RepoInfo +%extend zypp::RepoInfo { std::string dump(void) const { diff --git a/swig/RepoManager.i b/swig/RepoManager.i index a150d32..4101be3 100644 --- a/swig/RepoManager.i +++ b/swig/RepoManager.i @@ -1,10 +1,9 @@ %include <zypp/RepoManager.h> - #ifdef SWIGPYTHON %extend zypp::RepoManager{ std::string loadSolvFile(std::string _solv, std::string _alias) { - RepoInfo tmpRepo; + RepoInfo tmpRepo; tmpRepo.setAlias(_alias); try { sat::Pool::instance().addRepoSolv(_solv, tmpRepo); diff --git a/swig/ResPool.i b/swig/ResPool.i index b9f24e9..48634fa 100644 --- a/swig/ResPool.i +++ b/swig/ResPool.i @@ -3,11 +3,9 @@ %ignore zypp::ResPool::byKindEnd; %ignore zypp::ResPool::byNameBegin; %ignore zypp::ResPool::byNameEnd; -#if (BOOST_VERSION >= 106501) -%ignore zypp::ResPool::byStatus; -%ignore zypp::ResPool::byStatusBegin; -%ignore zypp::ResPool::byStatusEnd; -#endif +%ignore zypp::ResPool::byStatus; +%ignore zypp::ResPool::byStatusBegin; +%ignore zypp::ResPool::byStatusEnd; %apply unsigned { zypp::ResPool::size_type }; %include <zypp/ResPool.h> @@ -22,6 +20,35 @@ namespace zypp namespace zypp { +#ifdef SWIGPYTHON +namespace sat +{ +%extend Pool { + std::string loadSolvFile(std::string _solv, std::string _alias) + { + RepoInfo tmpRepo; + tmpRepo.setAlias(_alias); + + try { + addRepoSolv(_solv, tmpRepo); + } catch ( const Exception & e ) { + return e.msg(); + } + + return std::string(); + } +} +} +#endif + +%extend ResPool { + pool::GetResolvablesToInsDel getTransaction() + { + return pool::GetResolvablesToInsDel( *self ); + } +} + + #ifdef SWIGPERL5 iter2(ResPool, PoolItem); diff --git a/swig/ResTraits.i b/swig/ResTraits.i index 60613ec..cbcefad 100644 --- a/swig/ResTraits.i +++ b/swig/ResTraits.i @@ -90,3 +90,4 @@ namespace zypp %STUFF(SrcPackage) %STUFF(Pattern) %STUFF(Product) +%STUFF(Application) diff --git a/swig/Resolvable.i b/swig/Resolvable.i index 7055b9f..ea4e33a 100644 --- a/swig/Resolvable.i +++ b/swig/Resolvable.i @@ -1,4 +1,6 @@ %ignore zypp::make; %import <zypp/sat/Solvable.h> +%import <zypp/sat/SolvableType.h> +%template(SolvableType_Resolvable) zypp::sat::SolvableType<zypp::Resolvable>; %include <zypp/Resolvable.h> diff --git a/swig/Resolver.i b/swig/Resolver.i index d4245c7..d6842dd 100644 --- a/swig/Resolver.i +++ b/swig/Resolver.i @@ -2,13 +2,30 @@ %template(StringList) std::list<std::string>; #endif +/* don't wrap legacy ItemCapKind stuff */ +%ignore zypp::Resolver::isInstalledBy( const PoolItem & item ); +%ignore zypp::Resolver::installs( const PoolItem & item ); +%ignore zypp::Resolver::satifiedByInstalled (const PoolItem & item ); +%ignore zypp::Resolver::installedSatisfied( const PoolItem & item ); + %include <zypp/ProblemTypes.h> %include <zypp/ResolverProblem.h> %include <zypp/ProblemSolution.h> %include <zypp/Resolver.h> +/* ResPoool provides leagacy GetResolvablesToInsDel */ +%ignore zypp::Resolver::getTransaction(); + + +typedef std::list<zypp::ProblemSolution_Ptr> ProblemSolutionList; +%template(ProblemSolutionList) std::list<zypp::ProblemSolution_Ptr>; + +typedef boost::intrusive_ptr< zypp::ProblemSolution > ProblemSolution_Ptr; +%template(ProblemSolution_Ptr) boost::intrusive_ptr< zypp::ProblemSolution >; + namespace zypp { + typedef ::zypp::intrusive_ptr< Resolver > Resolver_Ptr; %template(Resolver_Ptr) ::zypp::intrusive_ptr<Resolver>; @@ -25,3 +42,4 @@ namespace zypp #endif } + diff --git a/swig/ZYppFactory.i b/swig/ZYppFactory.i index 3ac0b5a..5617f7e 100644 --- a/swig/ZYppFactory.i +++ b/swig/ZYppFactory.i @@ -1,9 +1,11 @@ - +%include <zypp/ZYpp.h> %include <zypp/ZYppFactory.h> -namespace zypp -{ -typedef ::zypp::intrusive_ptr<ZYpp> ZYpp_Ptr; -%template(ZYpp_Ptr) ::zypp::intrusive_ptr<ZYpp>; -} +typedef ::boost::detail::sp_member_access<::zypp::ZYpp> b_d_sp_member_access; +%template(b_d_sp_member_access) boost::detail::sp_member_access<::zypp::ZYpp>; + +typedef ::boost::detail::sp_dereference<::zypp::ZYpp> b_d_sp_dereference; +%template(b_d_sp_dereference) boost::detail::sp_dereference<::zypp::ZYpp>; +typedef ::boost::shared_ptr<::zypp::ZYpp> ZYpp_Ptr; +%template(ZYpp_Ptr) ::boost::shared_ptr<::zypp::ZYpp>; diff --git a/swig/ruby/tests/arch.rb b/swig/ruby/tests/arch.rb index 3e2f508..eafca1b 100644 --- a/swig/ruby/tests/arch.rb +++ b/swig/ruby/tests/arch.rb @@ -12,44 +12,43 @@ class Zypp::Arch end class ArchTest < Test::Unit::TestCase - include Zypp def test_arch # define i386, a builtin - a = Arch.new("i386") + a = Zypp::Arch.new("i386") assert a assert_equal "i386", a.to_s assert_equal true, a.is_builtin # i486 is 'bigger' than i386 - b = Arch.new("i486") + b = Zypp::Arch.new("i486") assert b assert_equal "i486", b.to_s assert b.is_builtin - if VERSION > 800 + if Zypp::VERSION > 800 assert_equal a, b.base_arch end assert a < b assert a.compatible_with?(b) # A new, adventurous architecture - z = Arch.new("xyzzy") + z = Zypp::Arch.new("xyzzy") assert z assert_equal "xyzzy", z.to_s assert_equal false, z.is_builtin # predefined archs - assert_equal Arch.new("noarch"), Arch.noarch - assert_equal a, Arch.i386 - assert_equal b, Arch.i486 - assert_equal Arch.new("i586"), Arch.i586 - assert_equal Arch.new("i686"), Arch.i686 - assert_equal Arch.new("x86_64"), Arch.x86_64 - assert_equal Arch.new("ia64"), Arch.ia64 - assert_equal Arch.new("ppc"), Arch.ppc - assert_equal Arch.new("ppc64"), Arch.ppc64 - assert_equal Arch.new("s390"), Arch.s390 - assert_equal Arch.new("s390x"), Arch.s390x + assert_equal Zypp::Arch.new("noarch"), Zypp::Arch.noarch + assert_equal a, Zypp::Arch.i386 + assert_equal b, Zypp::Arch.i486 + assert_equal Zypp::Arch.new("i586"), Zypp::Arch.i586 + assert_equal Zypp::Arch.new("i686"), Zypp::Arch.i686 + assert_equal Zypp::Arch.new("x86_64"), Zypp::Arch.x86_64 + assert_equal Zypp::Arch.new("ia64"), Zypp::Arch.ia64 + assert_equal Zypp::Arch.new("ppc"), Zypp::Arch.ppc + assert_equal Zypp::Arch.new("ppc64"), Zypp::Arch.ppc64 + assert_equal Zypp::Arch.new("s390"), Zypp::Arch.s390 + assert_equal Zypp::Arch.new("s390x"), Zypp::Arch.s390x end end diff --git a/swig/ruby/tests/bytecount.rb b/swig/ruby/tests/bytecount.rb index 5b46e14..bda6f0a 100644 --- a/swig/ruby/tests/bytecount.rb +++ b/swig/ruby/tests/bytecount.rb @@ -10,16 +10,15 @@ require 'test/unit' class LoadTest < Test::Unit::TestCase require 'zypp' - include Zypp def test_bytecount - g = ByteCount.new(ByteCount.G) + g = Zypp::ByteCount.new(Zypp::ByteCount.G) assert g - gb = ByteCount.new(ByteCount.GB) + gb = Zypp::ByteCount.new(Zypp::ByteCount.GB) assert gb - k = ByteCount.new(ByteCount.K) + k = Zypp::ByteCount.new(Zypp::ByteCount.K) assert k.to_i == 1024 - mb = ByteCount.new(ByteCount.MB) + mb = Zypp::ByteCount.new(Zypp::ByteCount.MB) assert mb.to_i == 1000*1000 end end diff --git a/swig/ruby/tests/target.rb b/swig/ruby/tests/target.rb index 7594c79..1b8e45b 100644 --- a/swig/ruby/tests/target.rb +++ b/swig/ruby/tests/target.rb @@ -7,12 +7,11 @@ $:.unshift "../../../build/swig/ruby" # test loading of extension require 'test/unit' +require 'zypp' class LoadTest < Test::Unit::TestCase - require 'zypp' - include Zypp def test_target - z = ZYppFactory::instance.getZYpp + z = Zypp::ZYppFactory::instance.getZYpp assert z.homePath assert z.tmpPath @@ -35,17 +34,17 @@ class LoadTest < Test::Unit::TestCase break if i > 10 # PoolItems have status and a resolvable r = pi.resolvable - assert pi.is_a? PoolItem + assert pi.is_a? Zypp::PoolItem end #try iterate with kind i = 0 - p.each_by_kind(ResKind.package) do |pi| + p.each_by_kind(Zypp::ResKind.package) do |pi| i = i + 1 break if i > 10 - assert pi.is_a? PoolItem + assert pi.is_a? Zypp::PoolItem r = pi.resolvable - assert isKindPackage(pi) + assert Zypp::isKindPackage(pi) end i = 0 @@ -53,7 +52,7 @@ class LoadTest < Test::Unit::TestCase p.each_by_name("libzypp") do |pi| i = i + 1 break if i > 10 - assert pi.is_a? PoolItem + assert pi.is_a? Zypp::PoolItem r = pi.resolvable # broken in current SWIG assert_equal "libzypp",r.name #try to download it diff --git a/swig/zypp.i b/swig/zypp.i index 1cf9a4d..cd9327e 100644 --- a/swig/zypp.i +++ b/swig/zypp.i @@ -17,20 +17,14 @@ // stuff swig seems to be unable to parse #define BOOST_NOEXCEPT -#define BOOST_SP_NOEXCEPT -#define BOOST_SP_NOEXCEPT_WITH_ASSERT +#define BOOST_SP_NOEXCEPT +#define BOOST_SP_NOEXCEPT_WITH_ASSERT #define BOOST_NO_CXX11_NOEXCEPT #define BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_NO_CXX11_SMART_PTR -#if (BOOST_VERSION >= 106501) -#define BOOST_CONSTEXPR_OR_CONST const #define constexpr #define BOOST_CONSTEXPR constexpr -#else -#define BOOST_CONSTEXPR -#define BOOST_CONSTEXPR_OR_CONST const -#define constexpr -#endif + %{ /* Includes the header in the wrapper code */ #ifdef SWIGRUBY @@ -216,10 +210,8 @@ namespace zypp { %include "std_string.i" %include "stl.i" -#if (BOOST_VERSION >= 106501) -%import <boost/config.hpp> -%import <boost/pointer_cast.hpp> -#endif +%import <boost/config.hpp> +%import <boost/pointer_cast.hpp> #ifdef BOOST_SMARTPTR_INCLUDE_DIR %import <boost/smart_ptr/scoped_ptr.hpp> @@ -250,11 +242,11 @@ namespace zypp { %include "Capabilities.i" %include "CapMatch.i" %include "OnMediaLocation.i" -%include "Resolvable.i" +%include "SolvAttr.i" %include "RepoType.i" -%include "TmpPath.i" %include "RepoInfo.i" %include "Repository.i" +%include "Resolvable.i" %include "ServiceInfo.i" %include "ResTraits.i" %include "ResStatus.i" @@ -276,10 +268,10 @@ namespace zypp { %include "ResPool.i" %include "ZYppCommitPolicy.i" %include "ZYppCommitResult.i" +%include "TmpPath.i" %include "Resolver.i" %include "ZConfig.i" %include "PoolQuery.i" -%include "SolvAttr.i" //just simple files, where we need default ctor %include <zypp/repo/RepoProvideFile.h> @@ -294,8 +286,6 @@ namespace zypp { %ignore zypp::ZYpp::setArchitecture; %ignore zypp::ZYpp::applyLocks; -%include <zypp/ZYpp.h> - %include "ZYppFactory.i" #endif |