diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-01-10 16:53:29 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-01-10 16:53:30 +0900 |
commit | 0190e8092e25e3fc59b9551883baab3ef6d8ddbf (patch) | |
tree | 34368c19fb489313c3abfa60ce48451998c13153 | |
parent | da4119182e0212f7a0c2b997c109a7b452816c41 (diff) | |
download | libzypp-bindings-0190e8092e25e3fc59b9551883baab3ef6d8ddbf.tar.gz libzypp-bindings-0190e8092e25e3fc59b9551883baab3ef6d8ddbf.tar.bz2 libzypp-bindings-0190e8092e25e3fc59b9551883baab3ef6d8ddbf.zip |
Imported Upstream version 0.7.0
Change-Id: Ica24db86ba56b4f31a763b9e9bb19fedf1ca733b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | COPYING | 20 | ||||
-rw-r--r-- | VERSION.cmake | 4 | ||||
-rwxr-xr-x | examples/python/SimpleWalkthrough.py | 147 | ||||
-rw-r--r-- | libzypp-bindings.spec.cmake | 4 | ||||
-rw-r--r-- | package/libzypp-bindings.changes | 6 | ||||
-rw-r--r-- | swig/ResPool.i | 7 | ||||
-rw-r--r-- | swig/Resolver.i | 16 | ||||
-rw-r--r-- | swig/ZYppFactory.i | 14 | ||||
-rw-r--r-- | swig/zypp.i | 2 |
10 files changed, 209 insertions, 13 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) diff --git a/VERSION.cmake b/VERSION.cmake index 2c07442..fbe1f83 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 "4") +SET(VERSION_MINOR "7") +SET(VERSION_PATCH "0") diff --git a/examples/python/SimpleWalkthrough.py b/examples/python/SimpleWalkthrough.py new file mode 100755 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 aa6b73a..591100d 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.30.0 +BuildRequires: libzypp-devel >= 15.1.0 BuildRequires: python-devel < 3 BuildRequires: ruby-devel -BuildRequires: swig >= 1.3.40 +BuildRequires: swig >= 2 Source: %{name}-%{version}.tar.bz2 %description diff --git a/package/libzypp-bindings.changes b/package/libzypp-bindings.changes index e451a7f..bc9ca92 100644 --- a/package/libzypp-bindings.changes +++ b/package/libzypp-bindings.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon May 4 10:17:32 CEST 2015 - ma@suse.de + +- Adapt to libzypp-15.x +- 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. diff --git a/swig/ResPool.i b/swig/ResPool.i index 08154f8..8c1c45f 100644 --- a/swig/ResPool.i +++ b/swig/ResPool.i @@ -16,6 +16,13 @@ namespace zypp namespace zypp { +%extend ResPool { + pool::GetResolvablesToInsDel getTransaction() + { + return pool::GetResolvablesToInsDel( *self ); + } +} + #ifdef SWIGPERL5 diff --git a/swig/Resolver.i b/swig/Resolver.i index d4245c7..127d70f 100644 --- a/swig/Resolver.i +++ b/swig/Resolver.i @@ -7,8 +7,23 @@ %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 >; + + +typedef std::list< zypp::solver::detail::SolutionAction_constPtr > CSolutionActionList; +%template(CSolutionActionList) std::list< zypp::solver::detail::SolutionAction_constPtr >; + namespace zypp { + typedef ::zypp::intrusive_ptr< Resolver > Resolver_Ptr; %template(Resolver_Ptr) ::zypp::intrusive_ptr<Resolver>; @@ -25,3 +40,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/zypp.i b/swig/zypp.i index a7fb5e1..bd3df23 100644 --- a/swig/zypp.i +++ b/swig/zypp.i @@ -276,8 +276,6 @@ namespace zypp { %ignore zypp::ZYpp::setArchitecture; %ignore zypp::ZYpp::applyLocks; -%include <zypp/ZYpp.h> - %include "ZYppFactory.i" #endif |