Imported Upstream version 0.7.0 01/109501/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 10 Jan 2017 07:53:29 +0000 (16:53 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 10 Jan 2017 07:53:30 +0000 (16:53 +0900)
Change-Id: Ica24db86ba56b4f31a763b9e9bb19fedf1ca733b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
CMakeLists.txt
COPYING [new file with mode: 0644]
VERSION.cmake
examples/python/SimpleWalkthrough.py [new file with mode: 0755]
libzypp-bindings.spec.cmake
package/libzypp-bindings.changes
swig/ResPool.i
swig/Resolver.i
swig/ZYppFactory.i
swig/zypp.i

index e02ba6b..30b0841 100644 (file)
@@ -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
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d1d10bc
--- /dev/null
+++ b/COPYING
@@ -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)
index 2c07442..fbe1f83 100644 (file)
@@ -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 (executable)
index 0000000..a1b6d94
--- /dev/null
@@ -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
index aa6b73a..591100d 100644 (file)
@@ -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
index e451a7f..bc9ca92 100644 (file)
@@ -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. 
index 08154f8..8c1c45f 100644 (file)
@@ -16,6 +16,13 @@ namespace zypp
 
 namespace zypp
 {
+%extend ResPool {
+  pool::GetResolvablesToInsDel getTransaction()
+  {
+    return pool::GetResolvablesToInsDel( *self );
+  }
+}
+
 
 #ifdef SWIGPERL5
 
index d4245c7..127d70f 100644 (file)
@@ -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
 }
 
+
index 3ac0b5a..5617f7e 100644 (file)
@@ -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>;
index a7fb5e1..bd3df23 100644 (file)
@@ -276,8 +276,6 @@ namespace zypp {
 %ignore zypp::ZYpp::setArchitecture;
 %ignore zypp::ZYpp::applyLocks;
 
-%include <zypp/ZYpp.h>
-
 %include "ZYppFactory.i"
 #endif