Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f5be76a
Move dbus/software to dbus/software/main
imobachgs Jun 16, 2022
84f844c
Support a Y2DIR per service
imobachgs Jun 16, 2022
db07625
Adapt DBus::Software::Main to its new location
imobachgs Jun 17, 2022
67e03a8
Export package proposal through D-Bus
imobachgs Jun 17, 2022
e56283d
Minor documentation fix
imobachgs Jun 17, 2022
adff45f
Add support for packages proposal to the software client
imobachgs Jun 17, 2022
8782652
Add replacements for some Yast modules
imobachgs Jun 17, 2022
ee12d97
Remove an unneeded require
imobachgs Jun 17, 2022
a128291
Wait 1 second after starting each service
imobachgs Jun 17, 2022
b045ebc
Rename DInstaller::DBus::Software::Main to Manager
imobachgs Jun 17, 2022
715d087
Add a unit test for Software#finish
imobachgs Jun 17, 2022
cd28830
Do not the call pre_umount_finish client
imobachgs Jun 17, 2022
9978963
Fix unit tests
imobachgs Jun 17, 2022
f1a0cb7
Make RuboCop happy
imobachgs Jun 17, 2022
2f2bdef
Remove an unneeded include
imobachgs Jun 17, 2022
b469856
Remove Package#Install mock
imobachgs Jun 17, 2022
08a05ff
Implement the Package.AVailable over D-Bus
imobachgs Jun 20, 2022
2bed1aa
Fix method name in the software client tests
imobachgs Jun 20, 2022
68c4396
Update from code review
imobachgs Jun 20, 2022
d480557
Add support for "optional" param in software proposal
imobachgs Jun 20, 2022
788897a
Log the backtrace when probing fails
imobachgs Jun 20, 2022
4dfa620
Revert "Implement the Package.AVailable over D-Bus"
imobachgs Jun 20, 2022
317bb77
Move old DInstaller client methods to Software
imobachgs Jun 20, 2022
3ac5deb
Document "optional" argument in package proposal methods
imobachgs Jun 20, 2022
55e3cdd
available_base_products is not writable anymore
imobachgs Jun 20, 2022
faf9b02
Remove watcher on available_base_products
imobachgs Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions service/bin/d-installer
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
# find current contact information at www.suse.com.

# TEMPORARY overwrite of Y2DIR to use DBus for communication with dependent yast modules
ENV["Y2DIR"] = File.expand_path("../lib/dinstaller/dbus/y2dir", __dir__)

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)

Expand All @@ -35,10 +34,12 @@ require "dinstaller/dbus/service_runner"
# @param name [Symbol] Service name
# @see ORDERED_SERVICES
def start_service(name)
general_y2dir = File.expand_path("../lib/dinstaller/dbus/y2dir", __dir__)
module_y2dir = File.expand_path("../lib/dinstaller/dbus/y2dir/#{name}", __dir__)
ENV["Y2DIR"] = "#{module_y2dir}:#{general_y2dir}"

logger = Logger.new($stdout, progname: name.to_s)
service_runner = DInstaller::DBus::ServiceRunner.new(
name, logger: logger
)
service_runner = DInstaller::DBus::ServiceRunner.new(name, logger: logger)
service_runner.run
end

Expand All @@ -51,6 +52,8 @@ ORDERED_SERVICES = [:software, :users, :manager].freeze
def start_all_services
ORDERED_SERVICES.map do |name|
fork { exec("#{__FILE__} #{name}") }
# TODO: implement a better mechanism to check whether the service is running
sleep(1)
end
end

Expand Down
59 changes: 0 additions & 59 deletions service/lib/dinstaller/dbus/clients/dinstaller.rb

This file was deleted.

71 changes: 71 additions & 0 deletions service/lib/dinstaller/dbus/clients/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,15 @@ module DBus
module Clients
# D-Bus client for software configuration
class Software
TYPES = [:package, :pattern].freeze
private_constant :TYPES

def initialize
@dbus_object = service.object("/org/opensuse/DInstaller/Software1")
@dbus_object.introspect

@dbus_proposal = service.object("/org/opensuse/DInstaller/Software/Proposal1")
@dbus_proposal.introspect
end

# Available products for the installation
Expand Down Expand Up @@ -79,8 +85,73 @@ 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
# names)
# @return [Array<Boolean>] An array containing whether each tag is selected or not
def provisions_selected?(tags)
dbus_object.ProvisionsSelected(tags)
end

# Add the given list of resolvables to the packages proposal
#
# @param unique_id [String] Unique identifier for the resolvables list
# @param type [Symbol] Resolvables type (:package or :pattern)
# @param resolvables [Array<String>] Resolvables to add
# @param [Boolean] optional True for optional list, false (the default) for
# the required list
def add_resolvables(unique_id, type, resolvables, optional: false)
Comment thread
imobachgs marked this conversation as resolved.
dbus_proposal.AddResolvables(unique_id, TYPES.index(type), resolvables, optional)
end

# Returns a list of resolvables
#
# @param unique_id [String] Unique identifier for the resolvables list
# @param type [Symbol] Resolvables type (:package or :pattern)
# @param [Boolean] optional True for optional list, false (the default) for
# the required list
# @return [Array<String>] Resolvables
def get_resolvables(unique_id, type, optional: false)
dbus_proposal.GetResolvables(unique_id, TYPES.index(type), optional).first
end

# Replace a list of resolvables in the packages proposal
#
# @param unique_id [String] Unique identifier for the resolvables list
# @param type [Symbol] Resolvables type (:package or :pattern)
# @param resolvables [Array<String>] List of resolvables
# @param [Boolean] optional True for optional list, false (the default) for
# the required list
def set_resolvables(unique_id, type, resolvables, optional: false)
dbus_proposal.SetResolvables(unique_id, TYPES.index(type), resolvables, optional)
end

# Remove resolvables from a list
#
# @param unique_id [String] Unique identifier for the resolvables list
# @param type [Symbol] Resolvables type (:package or :pattern)
# @param resolvables [Array<String>] Resolvables to remove
# @param [Boolean] optional True for optional list, false (the default) for
# the required list
def remove_resolvables(unique_id, type, resolvables, optional: false)
dbus_proposal.RemoveResolvables(unique_id, TYPES.index(type), resolvables, optional)
end

private

# @return [::DBus::Object]
attr_reader :dbus_proposal

# @return [::DBus::Object]
attr_reader :dbus_object

Expand Down
113 changes: 5 additions & 108 deletions service/lib/dinstaller/dbus/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,116 +19,13 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "dbus"
require "dinstaller/progress"

module DInstaller
module DBus
# D-Bus object to manage software installation
class Software < ::DBus::Object
PATH = "/org/opensuse/DInstaller/Software1"
private_constant :PATH

SOFTWARE_INTERFACE = "org.opensuse.DInstaller.Software1"
private_constant :SOFTWARE_INTERFACE

# Constructor
#
# @param backend [DInstaller::Software]
# @param logger [Logger]
def initialize(backend, logger)
@backend = backend
@logger = logger

register_progress_callback

super(PATH)
end

# rubocop:disable Metrics/BlockLength
dbus_interface SOFTWARE_INTERFACE do
dbus_reader :available_base_products, "a(ssa{sv})"
attr_writer :available_base_products

dbus_watcher :available_base_products

dbus_reader :selected_base_product, "s"

dbus_method :SelectProduct, "in ProductID:s" do |product_id|
logger.info "SelectProduct #{product_id}"

select_product(product_id)
PropertiesChanged(SOFTWARE_INTERFACE, { "SelectedBaseProduct" => product_id }, [])
end

dbus_method :ProvisionSelected, "in Provision:s, out Result:b" do |provision|
backend.provision_selected?(provision)
end

dbus_method :ProvisionsSelected, "in Provisions:as, out Result:ab" do |provisions|
[provisions.map { |p| backend.provision_selected?(p) }]
end

dbus_method :Propose do
backend.propose
end

dbus_method :Probe do
backend.probe
end

dbus_method :Install do
backend.install
end

dbus_method :Finish do
backend.finish
end

# Progress has struct with values:
# s message
# t total major steps to do
# t current major step (0-based)
# t total minor steps. Can be zero which means no minor steps
# t current minor step
dbus_reader :progress, "(stttt)"
end
# rubocop:enable Metrics/BlockLength

def available_base_products
backend.products.map do |product|
[product.name, product.display_name, {}].freeze
end
end

def selected_base_product
backend.product
end

def select_product(product_id)
backend.select_product(product_id)
end

def progress
backend.progress.to_a
end

private

# @return [Logger]
attr_reader :logger

# @return [DInstaller::Software]
attr_reader :backend

# Registers callback to be called when the progress changes
#
# The callback will emit a signal
def register_progress_callback
backend.progress.on_change do
PropertiesChanged(SOFTWARE_INTERFACE, { "Progress" => progress }, [])
end
end
# Name space for software D-Bus classes
module Software
end
end
end

require "dinstaller/dbus/software/manager"
require "dinstaller/dbus/software/proposal"
Loading