Hello community, here is the log from the commit of package libzypp-bindings for openSUSE:Factory checked in at Sun Oct 16 12:54:07 CEST 2011.
-------- --- openSUSE:Factory/libzypp-bindings/libzypp-bindings.changes 2011-09-23 02:11:19.000000000 +0200 +++ /mounts/work_src_done/STABLE/libzypp-bindings/libzypp-bindings.changes 2011-10-11 15:11:19.000000000 +0200 @@ -1,0 +2,5 @@ +Tue Oct 11 13:46:06 CEST 2011 - m...@suse.de + +- Use gcc-c++ >= 4.5 + +------------------------------------------------------------------- calling whatdependson for head-i586 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzypp-bindings.spec ++++++ --- /var/tmp/diff_new_pack.u0Gbi6/_old 2011-10-16 12:54:04.000000000 +0200 +++ /var/tmp/diff_new_pack.u0Gbi6/_new 2011-10-16 12:54:04.000000000 +0200 @@ -2,7 +2,7 @@ # spec file for package libzypp-bindings # # Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. -# + # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the @@ -17,15 +17,15 @@ # nodebuginfo - Name: libzypp-bindings Version: 0.5.9 -Release: 6 +Release: 0 License: GPLv2+ Summary: Bindings for libzypp Group: Development/Sources BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: cmake gcc-c++ python-devel ruby-devel +BuildRequires: cmake python-devel ruby-devel +BuildRequires: gcc-c++ >= 4.5 BuildRequires: swig >= 1.3.40 BuildRequires: libzypp-devel >= 5.8.0 Source: %{name}-%{version}.tar.bz2 @@ -48,7 +48,7 @@ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_SKIP_RPATH=1 \ .. -# the swig compile jobs take a lot of memory, so don't use %jobs here +# the swig compile jobs take a lot of memory, so don't use jobs here make -j1 %check @@ -83,7 +83,6 @@ License: GPLv2+ Summary: Python bindings for libzypp Group: Development/Languages/Python - %description -n python-zypp - ++++++ libzypp-bindings-0.5.9.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/CMakeLists.txt new/libzypp-bindings-0.5.9/CMakeLists.txt --- old/libzypp-bindings-0.5.9/CMakeLists.txt 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/CMakeLists.txt 2011-10-14 11:21:33.000000000 +0200 @@ -3,11 +3,11 @@ # # -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) ENABLE_TESTING() -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -fno-strict-aliasing") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -fno-strict-aliasing") # # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked @@ -48,12 +48,12 @@ # determine zypp version FIND_PROGRAM(READ_LINK readlink) -EXECUTE_PROCESS(COMMAND "${READ_LINK}" ${ZYPP_LIBRARY} OUTPUT_VARIABLE ZYPP_SOFILE) +EXECUTE_PROCESS(COMMAND "${READ_LINK}" "-f" ${ZYPP_LIBRARY} OUTPUT_VARIABLE ZYPP_SOFILE) # match number at end, strip trailing \n by using a sub-match -STRING(REGEX MATCH "([0-9]+)\n$" ZYPP_VERSION "${ZYPP_SOFILE}") +STRING(REGEX MATCH "([0-9]+)\\.[0-9]+\\.[0-9]+\n$" ZYPP_VERSION "${ZYPP_SOFILE}") SET( ZYPP_VERSION "${CMAKE_MATCH_1}" ) -MESSAGE(STATUS "Zypp so library: ${ZYPP_SOFILE}, version ${ZYPP_VERSION}") +MESSAGE(STATUS "Zypp so library version ${ZYPP_VERSION}") SET( SWIG_DEFINITIONS -DZYPP_DEPRECATED -DZYPP_VERSION=${ZYPP_VERSION} ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/README new/libzypp-bindings-0.5.9/README --- old/libzypp-bindings-0.5.9/README 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/README 2011-10-14 11:21:33.000000000 +0200 @@ -2,7 +2,8 @@ Attempt to create generated bindings for libzypp. Not restricted to one language. -Authors: dmacvi...@suse.de +Authors: kkae...@suse.de + dmacvi...@suse.de aschn...@suse.de Ruby Notes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/libzypp-bindings.spec.cmake new/libzypp-bindings-0.5.9/libzypp-bindings.spec.cmake --- old/libzypp-bindings-0.5.9/libzypp-bindings.spec.cmake 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/libzypp-bindings.spec.cmake 2011-10-14 11:21:33.000000000 +0200 @@ -1,10 +1,17 @@ # # spec file for package libzypp-bindings # -# Copyright (c) 2007 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. -# +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. + # +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + # Please submit bugfixes or comments via http://bugs.opensuse.org/ # @@ -13,11 +20,12 @@ Name: @PACKAGE@ Version: @VERSION@ Release: 0 -License: GPL v2 or later +License: GPLv2+ Summary: Bindings for libzypp Group: Development/Sources BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: cmake gcc-c++ python-devel ruby-devel +BuildRequires: cmake python-devel ruby-devel +BuildRequires: gcc-c++ >= 4.5 BuildRequires: swig >= 1.3.40 BuildRequires: libzypp-devel >= 5.8.0 Source: %{name}-%{version}.tar.bz2 @@ -40,7 +48,7 @@ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_SKIP_RPATH=1 \ .. -# the swig compile jobs take a lot of memory, so don't use %jobs here +# the swig compile jobs take a lot of memory, so don't use jobs here make -j1 %check @@ -55,6 +63,7 @@ %{__rm} -rf %{buildroot} %package -n ruby-zypp +License: GPLv2+ Summary: Ruby bindings for libzypp Group: Development/Languages/Ruby @@ -71,6 +80,7 @@ %endif %package -n python-zypp +License: GPLv2+ Summary: Python bindings for libzypp Group: Development/Languages/Python %description -n python-zypp @@ -82,6 +92,7 @@ %{py_sitedir}/zypp.py %package -n perl-zypp +License: GPLv2+ Requires: perl = %{perl_version} Summary: Perl bindings for libzypp Group: Development/Languages/Perl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/package/libzypp-bindings.changes new/libzypp-bindings-0.5.9/package/libzypp-bindings.changes --- old/libzypp-bindings-0.5.9/package/libzypp-bindings.changes 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/package/libzypp-bindings.changes 2011-10-14 11:21:33.000000000 +0200 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Tue Oct 11 13:46:06 CEST 2011 - m...@suse.de + +- Use gcc-c++ >= 4.5 + +------------------------------------------------------------------- Wed Feb 23 10:59:25 UTC 2011 - co...@novell.com - disable use of %jobs to avoid swapping during compilation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/swig/Callbacks.i new/libzypp-bindings-0.5.9/swig/Callbacks.i --- old/libzypp-bindings-0.5.9/swig/Callbacks.i 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/swig/Callbacks.i 2011-10-14 11:21:33.000000000 +0200 @@ -15,45 +15,301 @@ %{ #include <cstdarg> +#include <zypp/ZYppCallbacks.h> +/* + * Helpers + * + */ + +/* + * Action + * Symbol representation of :abort, :retry, and :ignore + * + */ + +static Target_Type action_abort() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("abort")); + return value; +#endif + return 0; // fallback + } + +static Target_Type action_retry() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("retry")); + return value; +#endif + return 0; // fallback + } + +static Target_Type action_ignore() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("ignore")); + return value; +#endif + return 0; // fallback + } + +/* + * Error + * Symbol representation of :no_error, :not_found, :io, :invalid + * + */ + +static Target_Type error_no_error() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("no_error")); + return value; +#endif +#if defined(SWIGPYTHON) + return Target_String("no_error"); +#endif + return 0; // fallback + } + +static Target_Type error_not_found() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("not_found")); + return value; +#endif +#if defined(SWIGPYTHON) + return Target_String("not_found"); +#endif + return 0; // fallback + } + +static Target_Type error_io() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("io")); + return value; +#endif +#if defined(SWIGPYTHON) + return Target_String("io"); +#endif + return 0; // fallback + } + +static Target_Type error_invalid() + { +#if defined(SWIGRUBY) + static VALUE value = Qnil; + if (value == Qnil) + value = ID2SYM(rb_intern("invalid")); + return value; +#endif +#if defined(SWIGPYTHON) + return Target_String("invalid"); +#endif + return 0; // fallback + } + +/* + * This is what makes people hate the ZYPP API. Why can't there + * be _one_ Error type ?! + */ +static Target_Type +remove_error2target(target::rpm::RemoveResolvableReport::Error error) +{ + Target_Type e; + switch(error) { + case target::rpm::RemoveResolvableReport::NO_ERROR: e = error_no_error(); break; + case target::rpm::RemoveResolvableReport::NOT_FOUND: e = error_not_found(); break; + case target::rpm::RemoveResolvableReport::IO: e = error_io(); break; + case target::rpm::RemoveResolvableReport::INVALID: e = error_invalid(); break; + } + return e; +} + + +/* + * This is what makes people hate the ZYPP API. Why can't there + * be _one_ Error type ?! + */ +static Target_Type +install_error2target(target::rpm::InstallResolvableReport::Error error) +{ + Target_Type e; + switch(error) { + case target::rpm::InstallResolvableReport::NO_ERROR: e = error_no_error(); break; + case target::rpm::InstallResolvableReport::NOT_FOUND: e = error_not_found(); break; + case target::rpm::InstallResolvableReport::IO: e = error_io(); break; + case target::rpm::InstallResolvableReport::INVALID: e = error_invalid(); break; + } + return e; +} + + +/* + * This is what makes people hate the ZYPP API. Why can't there + * be _one_ Action type ?! + */ +static target::PatchScriptReport::Action +target2patch_script_action(Target_Type a) +{ +#if defined(SWIGPYTHON) + const char *s; + if (!PyString_Check(a)) { + SWIG_exception_fail(SWIG_TypeError, "Expected string type"); + } + s = PyString_AsString(a); + if (!strcmp(s, "abort")) + return zypp::target::PatchScriptReport::ABORT; + else if (!strcmp(s, "retry")) + return zypp::target::PatchScriptReport::RETRY; + else if (!strcmp(s, "ignore")) + return zypp::target::PatchScriptReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected \"abort\", \"retry\" or \"ignore\""); +#endif +#if defined(SWIGRUBY) + if (a == action_abort()) + return zypp::target::PatchScriptReport::ABORT; + else if (a == action_retry()) + return zypp::target::PatchScriptReport::RETRY; + else if (a == action_ignore()) + return zypp::target::PatchScriptReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected :abort, :retry or :ignore"); +#endif +fail: + return zypp::target::PatchScriptReport::ABORT; +} + + +static target::rpm::RemoveResolvableReport::Action +target2removal_action(Target_Type a) +{ +#if defined(SWIGPYTHON) + const char *s; + if (!PyString_Check(a)) { + SWIG_exception_fail(SWIG_TypeError, "Expected string type"); + } + s = PyString_AsString(a); + if (!strcmp(s, "abort")) + return zypp::target::rpm::RemoveResolvableReport::ABORT; + else if (!strcmp(s, "retry")) + return zypp::target::rpm::RemoveResolvableReport::RETRY; + else if (!strcmp(s, "ignore")) + return zypp::target::rpm::RemoveResolvableReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected \"abort\", \"retry\" or \"ignore\""); +#endif +#if defined(SWIGRUBY) + if (a == action_abort()) + return zypp::target::rpm::RemoveResolvableReport::ABORT; + else if (a == action_retry()) + return zypp::target::rpm::RemoveResolvableReport::RETRY; + else if (a == action_ignore()) + return zypp::target::rpm::RemoveResolvableReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected :abort, :retry or :ignore"); +#endif +fail: + return zypp::target::rpm::RemoveResolvableReport::ABORT; +} + +static target::rpm::InstallResolvableReport::Action +target2install_action(Target_Type a) +{ +#if defined(SWIGPYTHON) + const char *s; + if (!PyString_Check(a)) { + SWIG_exception_fail(SWIG_TypeError, "Expected string type"); + } + s = PyString_AsString(a); + if (!strcmp(s, "abort")) + return zypp::target::rpm::InstallResolvableReport::ABORT; + else if (!strcmp(s, "retry")) + return zypp::target::rpm::InstallResolvableReport::RETRY; + else if (!strcmp(s, "ignore")) + return zypp::target::rpm::InstallResolvableReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected \"abort\", \"retry\" or \"ignore\""); +#endif +#if defined(SWIGRUBY) + if (a == action_abort()) + return zypp::target::rpm::InstallResolvableReport::ABORT; + else if (a == action_retry()) + return zypp::target::rpm::InstallResolvableReport::RETRY; + else if (a == action_ignore()) + return zypp::target::rpm::InstallResolvableReport::IGNORE; + SWIG_exception_fail(SWIG_ArgError(SWIG_ValueError), "Expected :abort, :retry or :ignore"); +#endif +fail: + return zypp::target::rpm::InstallResolvableReport::ABORT; +} + + +/* + * target_call + * + * Generic helper to call a function of the target language + * + */ static Target_Type target_call(Target_Type instance, const char *name, int argc, ... ) { va_list ap; va_start(ap, argc); - printf("Calling %p->%s with %d args\n", (void *)instance, name, argc); #if defined(SWIGPYTHON) /* * Python call with multiple args is like Array */ - Target_Type argv = Target_SizedArray(argc); - while(argc-- > 0) { - Target_Append(argv, va_arg(ap, Target_Type)); + Target_Type argv = PyTuple_New(argc); + int i; + for (i = 0; i < argc; ++i) + { + PyObject* arg = va_arg(ap, PyObject*); + if (arg == NULL) + { + arg = Py_None; + Py_IncRef(arg); + } + PyTuple_SET_ITEM(argv, i, arg); } - PyObject *pyfunc = PyObject_GetAttrString(instance, name); + PyObject *pyfunc = PyObject_GetAttrString(instance, name); PyObject *result = NULL; if (pyfunc == NULL) { - PyErr_Print(); - PyErr_Clear(); + PyErr_Print(); + PyErr_Clear(); goto cleanup; } - if (! PyCallable_Check(pyfunc)) + if (! PyCallable_Check(pyfunc)) { - goto cleanup; + fprintf(stderr,"%s not callable\n", name); + goto cleanup; } - + result = PyObject_CallObject(pyfunc, argv); if (PyErr_Occurred()) { - PyErr_Clear(); - goto cleanup; + fprintf(stderr,"%s returned error\n", name); + PyErr_Print(); + PyErr_Clear(); + goto cleanup; } cleanup: if (pyfunc) Py_DecRef(pyfunc); + if (argv) Py_DecRef(argv); #endif #if defined(SWIGRUBY) /* @@ -74,9 +330,11 @@ return result; } + /* * Patch message * + * calls 'show_message(zypp::Patch)' */ struct PatchMessageReportReceiver : public zypp::callback::ReceiveReport<zypp::target::PatchMessageReport> @@ -89,7 +347,17 @@ */ virtual bool show( zypp::Patch::constPtr & patch ) { - return true; + int result; + Target_Type r = SWIG_NewPointerObj((void *)&patch, SWIGTYPE_p_zypp__Patch, 0); + Target_Type res = target_call(instance, "patch_message", 1, r ); +#if defined(SWIGPYTHON) + result = PyObject_IsTrue(res) ? true : false; + if (res) Py_DecRef(res); +#endif +#if defined(SWIGRUBY) + result = RTEST(res) ? true : false; +#endif + return result; } }; @@ -107,27 +375,81 @@ virtual void start( const zypp::Package::constPtr & package, const zypp::Pathname & path_r ) // script path { + Target_Type pac = SWIG_NewPointerObj((void *)&(*package), SWIGTYPE_p_zypp__Package, 0); + Target_Type path = SWIG_NewPointerObj((void *)&path_r, SWIGTYPE_p_zypp__filesystem__Pathname, 0); + Target_Type result = target_call(instance, "patch_script_start", 2, pac, path ); +#if defined(SWIGPYTHON) + if (result) Py_DecRef(result); + Py_DecRef(path); + Py_DecRef(pac); +#endif + return; } /** - * Progress provides the script output. If the script is quiet, + * Progress provides the script output (Notify=OUTPUT). If the script is quiet, * from time to time still-alive pings are sent to the ui. (Notify=PING) * Returning \c FALSE aborts script execution. */ virtual bool progress( Notify kind, const std::string &output ) { - return true; + int result; + Target_Type str = Target_String(output.c_str()); + Target_Type k; + switch(kind) { + case OUTPUT: +#if defined(SWIGPYTHON) + k = Target_String("OUTPUT"); +#endif +#if defined(SWIGRUBY) + k = ID2SYM(rb_intern("OUTPUT")); +#endif + break; + case PING: +#if defined(SWIGPYTHON) + k = Target_String("PING"); +#endif +#if defined(SWIGRUBY) + k = ID2SYM(rb_intern("PING")); +#endif + break; + } + Target_Type res = target_call(instance, "patch_script_progress", 2, k, str ); +#if defined(SWIGPYTHON) + result = PyObject_IsTrue(res) ? true : false; + if (res) Py_DecRef(res); + Py_DecRef(k); + Py_DecRef(str); +#endif +#if defined(SWIGRUBY) + result = RTEST(res) ? true : false; +#endif + return result; } - /** Report error. */ + /** Report patch script error. + */ virtual Action problem( const std::string & description ) { - return zypp::target::PatchScriptReport::ABORT; + Action result; + Target_Type str = Target_String(description.c_str()); + Target_Type res = target_call(instance, "patch_script_problem", 1, str ); + result = target2patch_script_action(res); +#if defined(SWIGPYTHON) + Py_DecRef(str); + if (res) Py_DecRef(res); +#endif + return result; } - /** Report success. */ + /** Patch script finish. */ virtual void finish() { + Target_Type res = target_call(instance, "patch_script_finish", 0 ); +#if defined(SWIGPYTHON) + if (res) Py_DecRef(res); +#endif + return; } }; @@ -142,28 +464,68 @@ Target_Type instance; - virtual void start( const zypp::Resolvable *resolvable ) + virtual void start( Resolvable::constPtr resolvable ) { Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); Target_Type result = target_call(instance, "removal_start", 1, r ); #if defined(SWIGPYTHON) + Py_DecRef(r); if (result) Py_DecRef(result); #endif return; } + /** + * Return \c true to continue, \c false to abort commit. + */ virtual bool progress(int value, zypp::Resolvable::constPtr resolvable) { - return true; + bool result; + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type v = Target_Int(value); + Target_Type res = target_call(instance, "removal_progress", 2, r, v ); +#if defined(SWIGPYTHON) + result = PyObject_IsTrue(res) ? true : false; + Py_DecRef(v); + Py_DecRef(r); + if (res) Py_DecRef(res); +#endif +#if defined(SWIGRUBY) + result = RTEST(res) ? true : false; +#endif + return result; } - virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, const std::string & description ) + virtual Action problem( zypp::Resolvable::constPtr resolvable, target::rpm::RemoveResolvableReport::Error error, const std::string & description ) { - return RemoveResolvableReportReceiver::ABORT; + Action result; + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type e = remove_error2target(error); + Target_Type d = Target_String(description.c_str()); + Target_Type res = target_call(instance, "removal_problem", 3, r, e, d ); + result = target2removal_action(res); +#if defined(SWIGPYTHON) + if (res) Py_DecRef(res); + Py_DecRef(d); + Py_DecRef(e); + Py_DecRef(r); +#endif + return result; } virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, const std::string & reason ) { + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type e = remove_error2target(error); + Target_Type d = Target_String(reason.c_str()); + Target_Type res = target_call(instance, "removal_finish", 3, r, e, d ); +#if defined(SWIGPYTHON) + if (res) Py_DecRef(res); + Py_DecRef(d); + Py_DecRef(e); + Py_DecRef(r); +#endif + return; } }; @@ -178,26 +540,68 @@ Target_Type instance; - void display_step( zypp::Resolvable::constPtr resolvable, int value ) - { - } - virtual void start( zypp::Resolvable::constPtr resolvable ) { + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type result = target_call(instance, "install_start", 1, r ); +#if defined(SWIGPYTHON) + Py_DecRef(r); + if (result) Py_DecRef(result); +#endif + return; } + /** + * Return \c true to continue, \c false to abort commit. + */ virtual bool progress(int value, zypp::Resolvable::constPtr resolvable) { - return true; + bool result; + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type v = Target_Int(value); + Target_Type res = target_call(instance, "install_progress", 2, r, v ); +#if defined(SWIGPYTHON) + result = PyObject_IsTrue(res) ? true : false; + Py_DecRef(v); + Py_DecRef(r); + if (res) Py_DecRef(res); +#endif +#if defined(SWIGRUBY) + result = RTEST(res) ? true : false; +#endif + return result; } virtual Action problem( zypp::Resolvable::constPtr resolvable, Error error, const std::string & description, RpmLevel level ) { - return ABORT; + Action result; + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type e = install_error2target(error); + Target_Type d = Target_String(description.c_str()); + Target_Type res = target_call(instance, "install_problem", 3, r, e, d ); + result = target2install_action(res); +#if defined(SWIGPYTHON) + if (res) Py_DecRef(res); + Py_DecRef(d); + Py_DecRef(e); + Py_DecRef(r); +#endif + return result; } virtual void finish( zypp::Resolvable::constPtr resolvable, Error error, const std::string & reason, RpmLevel level ) { + Target_Type r = SWIG_NewPointerObj((void *)&(*resolvable), SWIGTYPE_p_zypp__Resolvable, 0); + Target_Type e = install_error2target(error); + Target_Type d = Target_String(reason.c_str()); + Target_Type res = target_call(instance, "install_finish", 3, r, e, d ); +#if defined(SWIGPYTHON) + if (res) Py_DecRef(res); + Py_DecRef(d); + Py_DecRef(e); + Py_DecRef(r); +#endif + return; } }; @@ -206,3 +610,4 @@ %} %include "CommitCallbacks.h" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/swig/CommitCallbacks.h new/libzypp-bindings-0.5.9/swig/CommitCallbacks.h --- old/libzypp-bindings-0.5.9/swig/CommitCallbacks.h 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/swig/CommitCallbacks.h 2011-10-14 11:21:33.000000000 +0200 @@ -165,11 +165,11 @@ _patch_script->start(package, path_r); } - /** - * * Progress provides the script output. If the script is quiet, - * * from time to time still-alive pings are sent to the ui. (Notify=PING) - * * Returning \c FALSE aborts script execution. - * */ + /** + * Progress provides the script output. If the script is quiet, + * from time to time still-alive pings are sent to the ui. (Notify=PING) + * Returning \c FALSE aborts script execution. + */ bool script_progress( target::PatchScriptReport::Notify kind, const std::string &output ) { return _patch_script->progress(kind, output); @@ -188,3 +188,6 @@ } }; + +#define REMOVE_NO_ERROR target::rpm::RemoveResolvableReport::NO_ERROR +#define INSTALL_NO_ERROR target::rpm::InstallResolvableReport::NO_ERROR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/swig/python/tests/commit_callbacks.py new/libzypp-bindings-0.5.9/swig/python/tests/commit_callbacks.py --- old/libzypp-bindings-0.5.9/swig/python/tests/commit_callbacks.py 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/swig/python/tests/commit_callbacks.py 2011-10-14 11:21:33.000000000 +0200 @@ -1,7 +1,22 @@ # # Test commit callbacks # - +# +# Callbacks are implemented by calling a specific object function +# +# You need +# - define a (receiver) class which include the function(s) you're interested in. +# - create an object instance of this class +# - tell Zypp where to send the callbacks +# +# There can only be one receiver instance be active at any time. +# So if you want to receive different callbacks, define the appropriate +# functions in the one receiver class +# +# +# See below for sample code +# +# import unittest import os @@ -12,37 +27,247 @@ import zypp +# +# This is counting the number of times our callback was called +# (its just for testing purposes to assert() that the callback was +# actually run) +# +removals = 0 +installs = 0 + + +# +# This is the receiver class. +# The _class name_ does not matter, but the _function name_ does +# +# TODO: provide a complete list of function names and parameters +# +# I. Patch message +# patch_message(zypp::Patch) - show patch message +# +# II. Patch script +# patch_script_start(zypp::Package, String) +# patch_script_progress(zypp::Notify, String) +# patch_script_problem(String) +# patch_script_finish() +# +# III. Removal +# removal_start(zypp::Resolvable) - start of resolvable uninstall +# removal_progress(zypp::Resolvable, Integer) - progress in percent +# removal_problem(zypp::Resolvable, zypp::Error, String) - problem report +# removal_finish(zypp::Resolvable, zypp::Error, String) - uninstall finish +# +# IV. Install +# install_start(zypp::Resolvable) - start of resolvable uninstall +# install_progress(zypp::Resolvable, Integer) - progress in percent +# install_problem(zypp::Resolvable, zypp::Error, String) - problem report +# install_finish(zypp::Resolvable, zypp::Error, String) - uninstall finish +# + class CommitReceiver: + + ################################ + # removal callbacks + + # + # removal_start() will be called at the beginning of a resolvable (typically package) uninstall + # and be passed the resolvable to-be-removed + # def removal_start(self, resolvable): + # testing: increment the number of removals and print the resolvable + global removals + removals += 1 print "Starting to remove ", resolvable + # + # removal_progress() is called during a resolvable (typically package) uninstall + # and be passed the resolvable to-be-removed and a percentage value + # Must return True (continue) or False (abort removal) + # + def removal_progress(self, resolvable, percentage): + assert percentage == 42 + print "Remove of ", resolvable, " at ", percentage, "%" + return True + + # + # removal_finish() is called after a resolvable (typically package) was uninstalled + # and be passed the resolvable just removed and a status (string) with detail (string) + # status is either + # - "no_error": typical 'good' status + # - "not_found": resolvable not found (i.e. not installed) + # - "io": (disk) I/O error + # - "invalid": any other error + # + def removal_finish(self, resolvable, status, detail): + print "Remove of ", resolvable.name(), " finished with problem ", status, ": ", detail + + # + # report a problem during resolvable removal + # error is the same as 'status' of removal_finish() + # + # Must return "abort", "retry" or "ignore" + # + def removal_problem(self, resolvable, error, description): + print "Remove of ", resolvable.name(), " has problem ", error, ": ", description + return "ignore" + + ################################ + # install callbacks + + # + # install_start() will be called at the beginning of a resolvable (typically package) install + # and be passed the resolvable to-be-installed + # + def install_start(self, resolvable): + # testing: increment the number of removals and print the resolvable + global installs + installs += 1 + print "Starting to install ", resolvable + + # + # install_progress() is called during a resolvable (typically package) install + # and be passed the resolvable to-be-removed and a percentage value + # Must return True (continue) or False (abort install) + # + def install_progress(self, resolvable, percentage): + assert percentage == 42 + print "Install of ", resolvable, " at ", percentage, "%" + return True + + # + # install_finish() is called after a resolvable (typically package) was installed + # and be passed the resolvable just installed and a status (string) with detail (string) + # status is either + # - "no_error": typical 'good' status + # - "not_found": resolvable not found + # - "io": (disk) I/O error + # - "invalid": any other error + # + def install_finish(self, resolvable, status, detail): + print "Install of ", resolvable.name(), " finished with problem ", status, ": ", detail + + # + # report a problem during resolvable install + # error is the same as 'status' of install_finish() + # + # Must return "abort", "retry" or "ignore" + # + def install_problem(self, resolvable, error, description): + print "Install of ", resolvable.name(), " has problem ", error, ": ", description + return "ignore" + +# +# Testcase for Callbacks +# + class CommitCallbacksTestCase(unittest.TestCase): + def setUp(self): + # + # Normal zypp startup + # + self.Z = zypp.ZYppFactory_instance().getZYpp() + self.Z.initializeTarget( zypp.Pathname("/") ) + self.Z.target().load() + + # The 'zypp.CommitCallbacksEmitter()' is a test/debug class + # which can be used to trigger various callbacks + # (This is callback test code - we cannot do an actual package uninstall here!) + self.commit_callbacks_emitter = zypp.CommitCallbacksEmitter() + + # + # create an instance of our CommitReceiver class defined above + # + self.commit_receiver = CommitReceiver() + + # zypp.CommitCallbacks is the callback 'handler' which must be informed + # about the receiver + self.commit_callbacks = zypp.CommitCallbacks() + + # + # Ensure that no other receiver is registered + # + assert None == self.commit_callbacks.receiver() + + # + # Connect the receiver instance with the callback handler + # + self.commit_callbacks.connect(self.commit_receiver) + + # + # Ensure that its set correctly + # + assert self.commit_receiver == self.commit_callbacks.receiver() + + def tearDown(self): + # + # Disconnect the receiver from the callback handler + # + self.commit_callbacks.disconnect() + + # + # Ensure that the disconnect was successful + # + assert None == self.commit_callbacks.receiver() + + # test patch message + def testPatchMessageCallback(self): + # + # Ugh, this would need a patch with a message :-/ + # + # FIXME + assert True + + # test patch script + def testPatchScriptCallback(self): + # + # Ugh, this would need a patch with a script :-/ + # + # FIXME + assert True + + # this will test the remove callback def testRemoveCallback(self): - Z = zypp.ZYppFactory_instance().getZYpp() - Z.initializeTarget( zypp.Pathname("/") ) - Z.target().load(); - - commit_callbacks_emitter = zypp.CommitCallbacksEmitter() - commit_callbacks = zypp.CommitCallbacks() -# print "commit_callbacks " , commit_callbacks - assert None == commit_callbacks.receiver() -# print "callbacks receiver is NULL - good" - commit_receiver = CommitReceiver() -# print "receiver is ", commit_receiver - commit_callbacks.connect(commit_receiver) -# print "connected to ", commit_receiver - assert commit_receiver == commit_callbacks.receiver() -# print "callbacks receiver is set - good" - for item in Z.pool(): + # + # Loop over pool - just to get real instances of Resolvable + # + for item in self.Z.pool(): print "Emitting removal of ", item.resolvable() - commit_callbacks_emitter.remove_start(item.resolvable()) - break + # + # Use the zypp.CommitCallbacksEmitter to fake an actual package removal + # + resolvable = item.resolvable() + self.commit_callbacks_emitter.remove_start(resolvable) + self.commit_callbacks_emitter.remove_progress(resolvable, 42) +# self.commit_callbacks_emitter.remove_problem(resolvable, zypp.REMOVE_NO_ERROR, "All fine") +# self.commit_callbacks_emitter.remove_finish(resolvable, zypp.REMOVE_NO_ERROR, "Done") + break # one is sufficient + # + # Did the actual callback got executed ? + # + assert removals == 1 + + # this will test the install callback + def testInstallCallback(self): - commit_callbacks.disconnect() -# print "disconnected" - assert None == commit_callbacks.receiver() -# print "callbacks receiver is NULL - good" + # + # Loop over pool - just to get real instances of Resolvable + # + for item in self.Z.pool(): + print "Emitting install of ", item.resolvable() + # + # Use the zypp.CommitCallbacksEmitter to fake an actual package removal + # + resolvable = item.resolvable() + self.commit_callbacks_emitter.install_start(resolvable) + self.commit_callbacks_emitter.install_progress(resolvable, 42) +# self.commit_callbacks_emitter.install_problem(resolvable, zypp.REMOVE_NO_ERROR, "All fine") +# self.commit_callbacks_emitter.install_finish(resolvable, zypp.REMOVE_NO_ERROR, "Done") + break # one is sufficient + # + # Did the actual callback got executed ? + # + assert installs == 1 if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzypp-bindings-0.5.9/swig/ruby/tests/commit_callbacks.rb new/libzypp-bindings-0.5.9/swig/ruby/tests/commit_callbacks.rb --- old/libzypp-bindings-0.5.9/swig/ruby/tests/commit_callbacks.rb 2011-03-01 13:32:06.000000000 +0100 +++ new/libzypp-bindings-0.5.9/swig/ruby/tests/commit_callbacks.rb 2011-10-14 11:21:33.000000000 +0200 @@ -23,6 +23,23 @@ # In Ruby the class is also an object, so we connect to the class commit_callbacks.connect CommitReceiver assert_equal CommitReceiver, commit_callbacks.receiver + + z = Zypp::ZYppFactory::instance.getZYpp + + z.initializeTarget(Zypp::Pathname.new("/")) + t = z.target + t.load + t.buildCache + + emitter = Zypp::CommitCallbacksEmitter.new + p = z.pool + p.each do |item| + puts "Emitting removal of ", item + puts item.methods.inspect + emitter.remove_start(item) + break + end + commit_callbacks.disconnect assert_equal nil, commit_callbacks.receiver end continue with "q"... Remember to have fun... -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org