Skip to content

Commit

Permalink
Added the Pkg.Resolvables() and Pkg.AnyResolvable() calls (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed May 27, 2019
1 parent 0cc8f75 commit 69151b9
Show file tree
Hide file tree
Showing 6 changed files with 553 additions and 349 deletions.
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings-devel-doc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-pkg-bindings-devel-doc
Version: 4.1.2
Version: 4.2.0
Release: 0
License: GPL-2.0-only
Group: Documentation/HTML
Expand Down
7 changes: 7 additions & 0 deletions package/yast2-pkg-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu May 23 07:09:08 UTC 2019 - Ladislav Slezák <lslezak@suse.cz>

- Added Pkg.Resolvables() and Pkg.AnyResolvable() calls
(related to bsc#1132650)
- 4.2.0

-------------------------------------------------------------------
Fri Mar 8 11:44:51 UTC 2019 - mvidner@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-pkg-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-pkg-bindings
Version: 4.1.2
Version: 4.2.0
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
30 changes: 28 additions & 2 deletions smoke_test_run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def log_file
# to y2log without affecting the return value :-(
def check_y2log
y2log = File.read(log_file).split("\n")

# keep only errors and higher
y2log.select! { |l| l =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} <[3-5]>/ }

Expand All @@ -28,7 +28,7 @@ def check_y2log
# ignore "Can't openfile '/var/lib/zypp/LastDistributionFlavor' for writing"
# (when running as non-root)
y2log.reject! { |l| l =~ /\/var\/lib\/zypp\/LastDistributionFlavor/ }

if !y2log.empty?
puts "Found errors in #{log_file}:"
puts y2log
Expand Down Expand Up @@ -80,5 +80,31 @@ def check_y2log
end
puts "OK"

# Check all packages - this expects at least one package is available/installed
puts "Checking Pkg.Resolvabless..."
resolvables = Yast::Pkg.Resolvables({kind: :package}, [])
raise "Pkg.Resolvables failed!" unless resolvables
raise "No package found!" if resolvables.empty?
# compare with the old Pkg.ResolvableProperties call
raise "Different number of packages found!" if packages.size != resolvables.size
puts "OK (found #{resolvables.size} packages)"

patterns = Yast::Pkg.Resolvables({kind: :pattern}, [:name])
raise "Pkg.Resolvables failed!" unless patterns
raise "No pattern found!" if patterns.empty?
raise "Pattern devel_yast not found" unless patterns.include?("name" => "devel_yast")
puts "OK (found #{patterns.size} patterns)"

installed_products = Yast::Pkg.Resolvables({kind: :product, status: :installed}, [:name, :display_name])
available_products = Yast::Pkg.Resolvables({kind: :product, status: :available}, [:name, :display_name])
selected_products = Yast::Pkg.Resolvables({kind: :product, status: :selected}, [:name, :display_name])
raise "Pkg.Resolvables failed!" unless patterns
raise "No installed product found!" if installed_products.empty?
raise "No available product found!" if available_products.empty?
raise "A selected product found, nothing should be selected now!" unless selected_products.empty?
puts "Found #{installed_products.size} installed products: #{installed_products.map{|p| p["display_name"]}}"
puts "Found #{available_products.size} available products: #{available_products.map{|p| p["display_name"]}}"
puts "OK"

# scan y2log for errors
check_y2log
9 changes: 7 additions & 2 deletions src/PkgFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class PkgFunctions

bool CreateBaseProductSymlink();

YCPMap Resolvable2YCPMap(const zypp::PoolItem &item, const std::string &req_kind, bool dependencies);
YCPMap Resolvable2YCPMap(const zypp::PoolItem &item, bool all, bool deps, const YCPList &attrs);

// CommitPolicy used for commit
zypp::ZYppCommitPolicy *commit_policy;
Expand Down Expand Up @@ -766,6 +766,11 @@ class PkgFunctions
/* TYPEINFO: boolean(symbol,symbol)*/
YCPValue IsAnyResolvable(const YCPSymbol& kind_r, const YCPSymbol& status);

/* TYPEINFO: list<map<string,any> >(map<symbol,any>, list<symbol>) */
YCPValue Resolvables(const YCPMap& filter, const YCPList& attrs);
/* TYPEINFO: boolean(map<symbol,any>) */
YCPValue AnyResolvable(const YCPMap& filter);

// keyring related
/* TYPEINFO: boolean(string,boolean)*/
YCPValue ImportGPGKey(const YCPString& filename, const YCPBoolean& trusted);
Expand Down Expand Up @@ -821,7 +826,7 @@ class PkgFunctions
/* TYPEINFO: boolean(string) */
YCPValue UrlSchemeIsDownloading(const YCPString &url_scheme);

YCPValue ResolvablePropertiesEx(const YCPString& name, const YCPSymbol& kind_r, const YCPString& version, bool dependencies);
YCPValue ResolvablePropertiesEx(const YCPString& name, const YCPSymbol& kind_r, const YCPString& version, bool all, bool deps, const YCPList &attrs);
YCPValue ResolvableSetPatches(const YCPSymbol& kind_r, bool preselect);

/* TYPEINFO: integer(string, string) */
Expand Down
Loading

0 comments on commit 69151b9

Please sign in to comment.