Skip to content

Commit

Permalink
Merge pull request #762 from openSUSE/list_software_patterns
Browse files Browse the repository at this point in the history
List software patterns
  • Loading branch information
jreidinger authored Sep 21, 2023
2 parents f971322 + fe0fecc commit 4f83fb4
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 65 deletions.
6 changes: 3 additions & 3 deletions doc/dbus/bus/org.opensuse.Agama.Software1.bus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<method name="SelectProduct">
<arg name="ProductID" direction="in" type="s"/>
</method>
<method name="ProvisionSelected">
<arg name="Provision" direction="in" type="s"/>
<arg name="Result" direction="out" type="b"/>
<method name="ListPatterns">
<arg name="Filtered" direction="in" type="b"/>
<arg name="Result" direction="out" type="a{s(ssssi)}"/>
</method>
<method name="ProvisionsSelected">
<arg name="Provisions" direction="in" type="as"/>
Expand Down
15 changes: 15 additions & 0 deletions doc/dbus/bus/org.opensuse.Agama1.Locale.bus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@
<method name="LabelsForLocales">
<arg type="a((ss)(ss))" direction="out"/>
</method>
<!--
Gets list of locales available on system.
# Examples
```
use agama_dbus_server::locale::Locale;
let locale = Locale::new();
assert!(locale.list_ui_locales().unwrap().len() > 0);
```
-->
<method name="ListUILocales">
<arg type="as" direction="out"/>
</method>
<method name="ListVConsoleKeyboards">
<arg type="as" direction="out"/>
</method>
Expand All @@ -56,6 +70,7 @@
<property name="Locales" type="as" access="readwrite"/>
<property name="SupportedLocales" type="as" access="readwrite"/>
<property name="Timezone" type="s" access="readwrite"/>
<property name="UILocale" type="s" access="readwrite"/>
<property name="VConsoleKeyboard" type="s" access="readwrite"/>
</interface>
</node>
96 changes: 96 additions & 0 deletions doc/dbus/org.opensuse.Agama.Software1.bus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/opensuse/Agama/Software1">
<node name="Proposal"/>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" direction="out" type="s"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="value" direction="out" type="v"/>
</method>
<method name="Set">
<arg name="interface_name" direction="in" type="s"/>
<arg name="property_name" direction="in" type="s"/>
<arg name="val" direction="in" type="v"/>
</method>
<method name="GetAll">
<arg name="interface_name" direction="in" type="s"/>
<arg name="value" direction="out" type="a{sv}"/>
</method>
<signal name="PropertiesChanged">
<arg name="interface" type="s"/>
<arg name="changed_properties" type="a{sv}"/>
<arg name="invalidated_properties" type="as"/>
</signal>
</interface>
<interface name="org.opensuse.Agama.Software1">
<!--
SelectProduct:
@ProductID: product identifier
Select product for Installation.
-->
<method name="SelectProduct">
<arg name="ProductID" direction="in" type="s"/>
</method>
<!--
ListPatterns:
@Filtered: Flag if result should contain only filtered patterns for user.
Decision about criteria is on backend.
@Result: map with pattern id as key and as value is struct with
category, description, icon, summary and order for pattern
List available patterns.
-->
<method name="ListPatterns">
<arg name="Filtered" direction="in" type="b"/>
<arg name="Result" direction="out" type="a{s(ssssi)}"/>
</method>
<method name="ProvisionsSelected">
<arg name="Provisions" direction="in" type="as"/>
<arg name="Result" direction="out" type="ab"/>
</method>
<method name="IsPackageInstalled">
<arg name="Name" direction="in" type="s"/>
<arg name="Result" direction="out" type="b"/>
</method>
<method name="UsedDiskSpace">
<arg name="SpaceSize" direction="out" type="s"/>
</method>
<method name="Probe">
</method>
<method name="Propose">
</method>
<method name="Install">
</method>
<method name="Finish">
</method>
<!--
property that defines list of available base products.
It is id of product, human readable name and dict for future extensions
It is ordered by display priority
-->
<property type="a(ssa{sv})" name="AvailableBaseProducts" access="read"/>
<!--
property that shows which base product was selected
-->
<property type="s" name="SelectedBaseProduct" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Progress">
<property type="u" name="TotalSteps" access="read"/>
<property type="(us)" name="CurrentStep" access="read"/>
<property type="b" name="Finished" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.ServiceStatus">
<property type="aa{sv}" name="All" access="read"/>
<property type="u" name="Current" access="read"/>
</interface>
<interface name="org.opensuse.Agama1.Validation">
<property type="as" name="Errors" access="read"/>
<property type="b" name="Valid" access="read"/>
</interface>
</node>
10 changes: 10 additions & 0 deletions doc/dbus/org.opensuse.Agama1.Locale.doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
<method name="LabelsForLocales">
<arg type="a((ss)(ss))" direction="out"/>
</method>
<!--
Gets list of locales available on system.
-->
<method name="ListUILocales">
<arg type="as" direction="out"/>
</method>
<method name="ListVConsoleKeyboards">
<arg type="as" direction="out"/>
</method>
Expand All @@ -31,6 +37,10 @@
<property name="Locales" type="as" access="readwrite"/>
<property name="SupportedLocales" type="as" access="readwrite"/>
<property name="Timezone" type="s" access="readwrite"/>
<!--
Property that controls in which localization human string from backend will come.
-->
<property name="UILocale" type="s" access="readwrite"/>
<property name="VConsoleKeyboard" type="s" access="readwrite"/>
</interface>
</node>
Expand Down
30 changes: 3 additions & 27 deletions doc/dbus_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,10 @@ See the new-style [reference][lang-ref] ([source][lang-src]).

Iface: o.o.Agama.Software1

#### methods:

- SelectProduct(string ProductId) -> void
Select product for installation.
TODO: do we need version or arch or any other parameter? should we add generic dict(sv) to it?
Example:

InstallProduct("SLES") -> () # only name from available BaseProducts is supported

#### Properties (all read only):

- AvailableBaseProducts -> array(struct(string ProductId, string ProductLabel, dict(string, variant) details))
List of all available base product to install on target system.
Note: List is sorted according to defined display order
Example:

AvailableBaseProducts -> [["SLES", "SUSE Linux Enterprise Server", {}]] # it is product name, human readable name and dict for future extensions to provide more data

- SelectedBaseProduct -> string ProductId
Base product selected for installation. It is always defined.
Example:

SelectedBaseProduct -> "SLES" # only name from available BaseProducts is supported

#### Signals:

- PropertiesChanged ( only standard one from org.freedesktop.DBus.Properties interface )
See the new-style [reference][lang-ref] ([source][lang-src]).

[lang-ref]: https://opensuse.github.io/agama/dbus/ref-org.opensuse.Agama.Software1.html
[lang-src]: dbus/org.opensuse.Agama.Software1.doc.xml

## `org.opensuse.Agama.Storage1` Service

Expand Down
3 changes: 0 additions & 3 deletions rust/agama-lib/src/software/proxies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ trait Software1 {
/// Propose method
fn propose(&self) -> zbus::Result<()>;

/// ProvisionSelected method
fn provision_selected(&self, provision: &str) -> zbus::Result<bool>;

/// ProvisionsSelected method
fn provisions_selected(&self, provisions: &[&str]) -> zbus::Result<Vec<bool>>;

Expand Down
9 changes: 0 additions & 9 deletions service/lib/agama/dbus/clients/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ def finish
dbus_object.Finish
end

# Determine whether the given tag are provided by the selected packages
#
# @param tag [String] Tag to search for (package names, requires/provides, or file
# names)
# @return [Boolean] true if it is provided; false otherwise
def provision_selected?(tag)
dbus_object.ProvisionSelected(tag)
end

# Determine whether the given tags are provided by the selected packages
#
# @param tags [Array<String>] Tags to search for (package names, requires/provides, or file
Expand Down
17 changes: 14 additions & 3 deletions service/lib/agama/dbus/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,20 @@ def initialize(backend, logger)
update_validation # as different product means different software selection
end

# TODO: just for performance comparison (see `perf.rb`)
dbus_method :ProvisionSelected, "in Provision:s, out Result:b" do |provision|
backend.provision_selected?(provision)
# value of result hash is category, description, icon, summary and order
dbus_method :ListPatterns, "in Filtered:b, out Result:a{s(ssssi)}" do |filtered|
[
backend.patterns(filtered).each_with_object({}) do |pattern, result|
value = [
pattern.category,
pattern.description,
pattern.icon,
pattern.summary,
pattern.order.to_i
]
result[pattern.name] = value
end
]
end

dbus_method :ProvisionsSelected, "in Provisions:as, out Result:ab" do |provisions|
Expand Down
13 changes: 13 additions & 0 deletions service/lib/agama/software/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
require "agama/with_progress"
require "agama/validation_error"
require "y2packager/product"
require "y2packager/resolvable"
require "yast2/arch_filter"
require "agama/software/callbacks"
require "agama/software/proposal"
Expand Down Expand Up @@ -177,6 +178,18 @@ def provision_selected?(tag)
Yast::Pkg.IsSelected(tag) || Yast::Pkg.IsProvided(tag)
end

# Enlist available patterns
#
# @param filtered [Boolean] If list of patterns should be filtered.
# Filtering criteria can change.
# @return [Array<Y2Packager::Resolvable>]
def patterns(filtered)
patterns = Y2Packager::Resolvable.find(kind: :pattern)
patterns = patterns.select(&:user_visible) if filtered

patterns
end

# Determines whether a package is installed
#
# @param name [String] Package name
Expand Down
20 changes: 0 additions & 20 deletions service/perf.rb

This file was deleted.

0 comments on commit 4f83fb4

Please sign in to comment.