Hello community,

here is the log from the commit of package yast2-pkg-bindings for 
openSUSE:Factory checked in at 2020-09-03 01:09:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-pkg-bindings (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-pkg-bindings.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-pkg-bindings"

Thu Sep  3 01:09:10 2020 rev:212 rq:829770 version:4.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-pkg-bindings/yast2-pkg-bindings.changes    
2020-07-24 09:54:19.525302451 +0200
+++ 
/work/SRC/openSUSE:Factory/.yast2-pkg-bindings.new.3399/yast2-pkg-bindings.changes
  2020-09-03 01:09:32.200374636 +0200
@@ -1,0 +2,7 @@
+Mon Aug 24 11:53:42 UTC 2020 - Ladislav Slezák <lsle...@suse.cz>
+
+- Improved Pkg::Resolvables() call to allow filtering by RPM
+  dependencies (provides, obsoletes,...) (related to bsc#1175317)
+- 4.3.0
+
+-------------------------------------------------------------------

Old:
----
  yast2-pkg-bindings-4.2.9.tar.bz2

New:
----
  yast2-pkg-bindings-4.3.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-pkg-bindings-devel-doc.spec ++++++
--- /var/tmp/diff_new_pack.pXSd44/_old  2020-09-03 01:09:33.392375034 +0200
+++ /var/tmp/diff_new_pack.pXSd44/_new  2020-09-03 01:09:33.396375035 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package yast2-pkg-bindings-devel-doc
 #
-# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,12 +12,12 @@
 # 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/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           yast2-pkg-bindings-devel-doc
-Version:        4.2.9
+Version:        4.3.0
 Release:        0
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Source0:        yast2-pkg-bindings-%{version}.tar.bz2

++++++ yast2-pkg-bindings.spec ++++++
--- /var/tmp/diff_new_pack.pXSd44/_old  2020-09-03 01:09:33.420375043 +0200
+++ /var/tmp/diff_new_pack.pXSd44/_new  2020-09-03 01:09:33.424375044 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package yast2-pkg-bindings
 #
-# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,12 +12,12 @@
 # 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/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           yast2-pkg-bindings
-Version:        4.2.9
+Version:        4.3.0
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-pkg-bindings-4.2.9.tar.bz2 -> yast2-pkg-bindings-4.3.0.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings-devel-doc.spec 
new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings-devel-doc.spec
--- old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings-devel-doc.spec      
2020-07-22 16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings-devel-doc.spec      
2020-08-25 10:48:45.000000000 +0200
@@ -16,7 +16,7 @@
 #
 
 Name:           yast2-pkg-bindings-devel-doc
-Version:        4.2.9
+Version:        4.3.0
 Release:        0
 License:        GPL-2.0-only
 Group:          Documentation/HTML
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings.changes 
new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings.changes
--- old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings.changes     
2020-07-22 16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings.changes     
2020-08-25 10:48:45.000000000 +0200
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Mon Aug 24 11:53:42 UTC 2020 - Ladislav Slezák <lsle...@suse.cz>
+
+- Improved Pkg::Resolvables() call to allow filtering by RPM
+  dependencies (provides, obsoletes,...) (related to bsc#1175317)
+- 4.3.0
+
+-------------------------------------------------------------------
 Wed Jul 22 16:02:16 CEST 2020 - aschn...@suse.com
 
 - Expand URL when libzypp expects an expanded URL. Fixes weird zypp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings.spec 
new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings.spec
--- old/yast2-pkg-bindings-4.2.9/package/yast2-pkg-bindings.spec        
2020-07-22 16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/package/yast2-pkg-bindings.spec        
2020-08-25 10:48:45.000000000 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-pkg-bindings
-Version:        4.2.9
+Version:        4.3.0
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-4.2.9/smoke_test_prepare.sh 
new/yast2-pkg-bindings-4.3.0/smoke_test_prepare.sh
--- old/yast2-pkg-bindings-4.2.9/smoke_test_prepare.sh  2020-07-22 
16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/smoke_test_prepare.sh  2020-08-25 
10:48:45.000000000 +0200
@@ -10,3 +10,7 @@
 
 # clear the log if present, it will be checked later
 rm -f /var/log/YaST2/y2log
+
+# disable the OSS repository, it contains over 60k packages and that slows down
+# some Pkg tests a lot
+zypper mr -d repo-oss
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-4.2.9/smoke_test_run.rb 
new/yast2-pkg-bindings-4.3.0/smoke_test_run.rb
--- old/yast2-pkg-bindings-4.2.9/smoke_test_run.rb      2020-07-22 
16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/smoke_test_run.rb      2020-08-25 
10:48:45.000000000 +0200
@@ -107,7 +107,7 @@
 puts "OK"
 
 # Check all packages - this expects at least one package is available/installed
-puts "Checking Pkg.Resolvabless..."
+puts "Checking Pkg.Resolvables..."
 resolvables = Yast::Pkg.Resolvables({kind: :package}, [])
 raise "Pkg.Resolvables failed!" unless resolvables
 raise "No package found!" if resolvables.empty?
@@ -130,6 +130,18 @@
 raise "A package is selected to install (???)" unless selected_packages.empty?
 puts "OK (no package selected)"
 
+obsolete_packages = Yast::Pkg.Resolvables({kind: :package, obsoletes_regexp: 
"^yast2-config-"}, [])
+raise "No package with yast2-config obsoletes found" if 
obsolete_packages.empty?
+puts "OK (found #{obsolete_packages.size} packages with yast2-config-* 
obsoletes)"
+
+supplement_packages = Yast::Pkg.Resolvables({kind: :package, 
supplements_regexp: "^autoyast\\(.*\\)"}, [])
+raise "No package with autoyast() supplements found" if 
supplement_packages.empty?
+puts "OK (found #{supplement_packages.size} packages with autoyast() 
supplements)"
+
+provide_packages = Yast::Pkg.Resolvables({kind: :package, provides: 
"y2c_online_update"}, [])
+raise "No package with y2c_online_update provides found" if 
provide_packages.empty?
+puts "OK (found #{provide_packages.size} packages providing y2c_online_update)"
+
 removed = Yast::Pkg.ResolvableRemove("yast2-core", :package)
 raise "Cannot select yast2-core to uninstall" unless removed
 puts "OK (yast2-core selected to uninstall"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-pkg-bindings-4.2.9/src/Package.cc 
new/yast2-pkg-bindings-4.3.0/src/Package.cc
--- old/yast2-pkg-bindings-4.2.9/src/Package.cc 2020-07-22 16:41:34.000000000 
+0200
+++ new/yast2-pkg-bindings-4.3.0/src/Package.cc 2020-08-25 10:48:45.000000000 
+0200
@@ -80,8 +80,14 @@
 // ------------------------
 /**
  *  @builtin PkgQueryProvides
- *  @short List all package instances providing 'tag'
+ *  @short [OBSOLETE] List all package instances providing 'tag'
  *  @description
+ *
+ *  **Obsolete**
+ *
+ *  This call is obsolete, use `Resolvables()` call instead, it can
+ *  use also the other RPM dependencies and allows using regexps.
+ *
  *  A package instance is itself a list of three items:
  *
  *  - string name: The package name
@@ -114,6 +120,9 @@
 YCPList
 PkgFunctions::PkgQueryProvides( const YCPString& tag )
 {
+       y2warning("Pkg::PkgQueryProvides() is obsolete.");
+       y2warning("Use Pkg::Resolvables({provides: ...}, [...]) instead.");
+
     YCPList ret;
     std::string name = tag->value();
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-pkg-bindings-4.2.9/src/Resolvable_Properties.cc 
new/yast2-pkg-bindings-4.3.0/src/Resolvable_Properties.cc
--- old/yast2-pkg-bindings-4.2.9/src/Resolvable_Properties.cc   2020-07-22 
16:41:34.000000000 +0200
+++ new/yast2-pkg-bindings-4.3.0/src/Resolvable_Properties.cc   2020-08-25 
10:48:45.000000000 +0200
@@ -29,6 +29,8 @@
 #include "log.h"
 #include "ycpTools.h"
 
+#include <set>
+
 #include <ycp/YCPBoolean.h>
 #include <ycp/YCPInteger.h>
 #include <ycp/YCPSymbol.h>
@@ -48,6 +50,7 @@
 #include <zypp/sat/LocaleSupport.h>
 #include <zypp/parser/ProductFileReader.h>
 #include <zypp/base/Regex.h>
+#include <zypp/PoolQuery.h>
 
 /**
    @builtin ResolvableProperties
@@ -806,7 +809,15 @@
        ResolvableFilter(const YCPMap &attributes, const PkgFunctions &pf)
                : pkg(pf), check_repo(false), check_transact_by(false), 
check_vendor(false),
                check_locked(false), check_on_system(false), 
check_license_confirmed(false),
-               medium_nr(-1)
+               medium_nr(-1),
+               check_provides(false), check_regexp_provides(false),
+               check_obsoletes(false), check_regexp_obsoletes(false),
+               check_conflicts(false), check_regexp_conflicts(false),
+               check_requires(false), check_regexp_requires(false),
+               check_recommends(false), check_regexp_recommends(false),
+               check_suggests(false), check_regexp_suggests(false),
+               check_supplements(false), check_regexp_supplements(false),
+               check_enhances(false), check_regexp_enhances(false)
        {
                YCPValue kind_symbol = attributes->value(YCPSymbol("kind"));
                if (!kind_symbol.isNull() && kind_symbol->isSymbol())
@@ -884,6 +895,33 @@
                        check_license_confirmed = true;
                        license_confirmed = 
license_confirmed_value->asBoolean()->value();
                }
+
+#define QUERY_DEPS(NAME) \
+               YCPValue value_regexp_##NAME = 
attributes->value(YCPSymbol(#NAME "_regexp")); \
+               if (!value_regexp_##NAME.isNull() && 
value_regexp_##NAME->isString()) \
+               { \
+                       check_regexp_##NAME = true; \
+                       fill_deps(regexp_##NAME, zypp::sat::SolvAttr::NAME, 
value_regexp_##NAME->asString()->value(), true); \
+               } \
+               \
+               YCPValue str_##NAME = attributes->value(YCPSymbol(#NAME)); \
+               if (!str_##NAME.isNull() && str_##NAME->isString()) \
+               { \
+                       check_##NAME = true; \
+                       fill_deps(NAME, zypp::sat::SolvAttr::NAME, 
str_##NAME->asString()->value(), false); \
+               }
+
+               QUERY_DEPS(provides)
+               QUERY_DEPS(obsoletes)
+               QUERY_DEPS(conflicts)
+               QUERY_DEPS(requires)
+               QUERY_DEPS(recommends)
+               QUERY_DEPS(suggests)
+               QUERY_DEPS(supplements)
+               QUERY_DEPS(enhances)
+
+#undef QUERY_DEPS
+
        }
 
        // The main filtering function, returns true/false for each resolvable 
in the pool
@@ -960,6 +998,25 @@
                if (medium_nr >= 0 && medium_nr != r->mediaNr())
                        return false;
 
+               // check the matching dependencies
+
+#define CHECK_DEPS(NAME) \
+               if (check_##NAME && NAME.find(zypp::sat::Solvable(r)) == 
NAME.end()) \
+                       return false; \
+               if (check_regexp_##NAME && 
regexp_##NAME.find(zypp::sat::Solvable(r)) == regexp_##NAME.end()) \
+                       return false;
+
+               CHECK_DEPS(provides)
+               CHECK_DEPS(obsoletes)
+               CHECK_DEPS(conflicts)
+               CHECK_DEPS(requires)
+               CHECK_DEPS(recommends)
+               CHECK_DEPS(suggests)
+               CHECK_DEPS(supplements)
+               CHECK_DEPS(enhances)
+
+#undef CHECK_DEPS
+
                return true;
        }
 
@@ -981,17 +1038,66 @@
        bool check_on_system, on_system;
        bool check_license_confirmed, license_confirmed;
        long long medium_nr;
+
+       // define dependency filters
+#define DEFINE_DEPS(NAME) \
+       bool check_##NAME; \
+       bool check_regexp_##NAME; \
+       std::set<zypp::sat::Solvable> regexp_##NAME; \
+       std::set<zypp::sat::Solvable> NAME;
+
+       DEFINE_DEPS(provides)
+       DEFINE_DEPS(obsoletes)
+       DEFINE_DEPS(conflicts)
+       DEFINE_DEPS(requires)
+       DEFINE_DEPS(recommends)
+       DEFINE_DEPS(suggests)
+       DEFINE_DEPS(supplements)
+       DEFINE_DEPS(enhances)
+
+#undef DEFINE_DEPS
+
+private:
+
+    void fill_deps(std::set<zypp::sat::Solvable> &set, zypp::sat::SolvAttr 
attr, const std::string &query, bool regexp)
+    {
+        zypp::PoolQuery q;
+        regexp ? q.setMatchRegex() : q.setMatchExact();
+        q.addAttribute(attr, query);
+
+        for (zypp::PoolQuery::const_iterator it = q.begin(), end = q.end(); it 
!= end; ++it)
+            set.insert(*it);
+    }
 };
 
 /**
    @builtin Resolvables
-   @short Is there any resolvable matching the input filter?
+   @short Return resolvables matching the input filter, if the regexp is 
invalid
+          (for example by confusing it with a shell pattern), nil is returned.
    @param map filter
    @param list attrs the list of required attributes
-   @return boolean true if a resolvable was found, false otherwise
+   @return list list of found resolvables (maps), nil
+          if an error occurred (call Pkg.LastError() to get the details)
 
    See the ResolvableProperties() call for the accepted filtering keys
    and returned attributes.
+
+        Additionally it also accepts RPM depency filters, it is possible to 
check for all
+        dependency types: provides, obsoletes, conflicts, requires, recommends,
+        suggests, supplements and enhances.
+
+        Pass the dependency name as the key (as a string) and the requested 
text
+        as the value. You can add "_regexp" suffix, then the value will be used
+        as a POSIX extended regular expression.
+
+        Examples (Ruby Hash):
+                provides: "pattern()"
+                provides: "release-notes()"
+                obsoletes_regexp: "^yast2-config-"
+                supplements_regexp: "^autoyast\\(.*\\)"
+
+        You can pass several dependency filters, in that case the result is 
logical AND,
+        i.e. all required dependency filters must match.
 */
 YCPValue PkgFunctions::Resolvables(const YCPMap& filter, const YCPList& attrs)
 {
@@ -1000,21 +1106,38 @@
 
        YCPList ret;
 
-       for (const auto &r : 
zypp::ResPool::instance().filter(ResolvableFilter(filter, *this)) )
-               ret->add(Resolvable2YCPMap(r, false, false, attrs));
+       try {
+        for (const auto &r : 
zypp::ResPool::instance().filter(ResolvableFilter(filter, *this)) )
+            ret->add(Resolvable2YCPMap(r, false, false, attrs));
+       }
+       catch(const zypp::MatchInvalidRegexException &e)
+       {
+               _last_error.setLastError(ExceptionAsString(e));
+               return YCPVoid();
+       }
 
        return ret;
 }
 
 /**
    @builtin AnyResolvable
-   @short Is there any resolvable matching the input filter?
+   @short Is there any resolvable matching the input filter? If the regexp is 
invalid
+          (for example by confusing it with a shell pattern), nil is returned.
    @param map filter
-   @return boolean true if a resolvable was found, false otherwise
+   @return boolean true if a resolvable was found, false otherwise, nil
+          if an error occurred (call Pkg.LastError() to get the details)
 
    See the ResolvableProperties() call for the accepted filtering keys.
+        See the Resolvables() call for the details about the dependency 
filters.
 */
 YCPValue PkgFunctions::AnyResolvable(const YCPMap& filter)
 {
-       return 
YCPBoolean(!zypp::ResPool::instance().filter(ResolvableFilter(filter, 
*this)).empty());
+       try {
+               return 
YCPBoolean(!zypp::ResPool::instance().filter(ResolvableFilter(filter, 
*this)).empty());
+       }
+       catch(const zypp::MatchInvalidRegexException &e)
+       {
+               _last_error.setLastError(ExceptionAsString(e));
+               return YCPVoid();
+       }
 }


Reply via email to