From 0558c0ca8603ff2f517b12c7372d42323283b9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 10:55:11 +0000 Subject: [PATCH 01/13] Use a .gitignore by subproject --- .gitignore | 60 +----------------------------------------------- web/.gitignore | 3 +++ yastd/.gitignore | 56 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 59 deletions(-) create mode 100644 yastd/.gitignore diff --git a/.gitignore b/.gitignore index 6b9434514a..0367f44502 100644 --- a/.gitignore +++ b/.gitignore @@ -1,59 +1 @@ -*.gem -*.rbc -/.config -/coverage/ -/InstalledFiles -/pkg/ -/spec/reports/ -/spec/examples.txt -/test/tmp/ -/test/version_tmp/ -/tmp/ - -# Used by dotenv library to load environment variables. -# .env - -# Ignore Byebug command history file. -.byebug_history - -## Specific to RubyMotion: -.dat* -.repl_history -build/ -*.bridgesupport -build-iPhoneOS/ -build-iPhoneSimulator/ - -## Specific to RubyMotion (use of CocoaPods): -# -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# -# vendor/Pods/ - -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ - -## Environment normalization: -/.bundle/ -/vendor/bundle -/lib/bundler/man/ - -# for a library or gem, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# Gemfile.lock -# .ruby-version -# .ruby-gemset - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -.rvmrc - -# Used by RuboCop. Remote config files pulled in from inherit_from directive. -# .rubocop-https?--* - -# Web interface logs directory -.log +.yardoc/ diff --git a/web/.gitignore b/web/.gitignore index 4d29575de8..4e9ca8d6a1 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# Web interface logs directory +.log diff --git a/yastd/.gitignore b/yastd/.gitignore new file mode 100644 index 0000000000..e3200e0f81 --- /dev/null +++ b/yastd/.gitignore @@ -0,0 +1,56 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. +.byebug_history + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# vendor/Pods/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# Used by RuboCop. Remote config files pulled in from inherit_from directive. +# .rubocop-https?--* From 3098e80b59d9b768dcbb36952ed36760bea9dab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 14:59:15 +0000 Subject: [PATCH 02/13] [yastd] Run probing and installation on separate threads * Use EventMachine to do polling on the D-Bus socket. --- yastd/bin/yastd | 11 ++++++++++- yastd/lib/yast2/dbus/installer.rb | 8 ++++---- yastd/lib/yast2/dbus/service.rb | 20 +++++++++++++------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/yastd/bin/yastd b/yastd/bin/yastd index f12180c672..8050864368 100755 --- a/yastd/bin/yastd +++ b/yastd/bin/yastd @@ -3,5 +3,14 @@ $LOAD_PATH.unshift File.expand_path("../lib", __dir__) +require "rubygems" +require "bundler/setup" + +require "eventmachine" require "yast2/dbus/service" -Yast2::DBus::Service.new.run + +EM.run do + service = Yast2::DBus::Service.new + service.export + EventMachine::PeriodicTimer.new(0.1) { service.dispatch } +end diff --git a/yastd/lib/yast2/dbus/installer.rb b/yastd/lib/yast2/dbus/installer.rb index adaef0bf1f..5802d38ccf 100644 --- a/yastd/lib/yast2/dbus/installer.rb +++ b/yastd/lib/yast2/dbus/installer.rb @@ -87,17 +87,17 @@ def initialize(installer, logger, *args) dbus_method :Probe, "out result:b" do logger.info "Probe" - - installer.probe + Thread.new { installer.probe } true end dbus_method :Start, "out result:b" do logger.info "Start" - - installer.install + Thread.new { installer.install } true end + + dbus_signal :StatusChanged, "status:n" end dbus_interface PROPERTY_INTERFACE do diff --git a/yastd/lib/yast2/dbus/service.rb b/yastd/lib/yast2/dbus/service.rb index bd5babd681..ecdae7dd5d 100644 --- a/yastd/lib/yast2/dbus/service.rb +++ b/yastd/lib/yast2/dbus/service.rb @@ -40,19 +40,25 @@ class Service # @return [String] D-Bus object path OBJECT_PATH = "/org/opensuse/YaST/Installer" + attr_reader :bus + def initialize(logger = nil) @logger = logger || Logger.new(STDOUT) + @bus = ::DBus::SystemBus.instance end - def run - bus = ::DBus.system_bus + # Exports the installer object through the D-Bus service + def export service = bus.request_service(SERVICE_NAME) - installer_obj = Yast2::DBus::Installer.new(build_installer, logger, OBJECT_PATH) + installer_obj = Yast2::DBus::Installer.new( + build_installer, logger, OBJECT_PATH + ) service.export(installer_obj) - dbus_loop = ::DBus::Main.new - dbus_loop << bus - logger.info "Listening on #{OBJECT_PATH}" - dbus_loop.run + logger.info "Exported #{OBJECT_PATH} object" + end + + def dispatch + bus.dispatch_message_queue end private From 529670bca8cf8aba660188a942fa93745b63f52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 15:01:29 +0000 Subject: [PATCH 03/13] [yastd] Use Bundler to install the dependencies --- README.md | 26 +++++++++++++------------- yastd/Gemfile | 2 ++ yastd/Gemfile.lock | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 yastd/Gemfile.lock diff --git a/README.md b/README.md index d115627ae6..9685d86edb 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,8 @@ installs the software and so on. So you need to tell dbus about the service by c To run the service, type: $ cd yastd - $ sudo ruby bin/yastd + $ bundle install + $ sudo bunle exec bin/yastd You can use a tool like [busctl](https://www.freedesktop.org/wiki/Software/dbus/) (or [D-Feet](https://wiki.gnome.org/Apps/DFeet) if you prefer a graphical one: @@ -46,26 +47,25 @@ JavaScript, etc.). In the future, we could replace it with anything even smaller To start the proxy, just type: - $ cd yastd-proxy - $ bundle install - $ rails s -e production + $ cd yastd-proxy + $ bundle install + $ bundle exec bin/yastd-proxy Now you can try to access the D-Bus service using cURL: - $ curl http://localhost:3000/properties - [{"Disk":"/dev/sda","Product":"openSUSE-Addon-NonOss","Language":"en_US","Status":0}] - $ curl -X PUT -d value=/dev/sda http://localhost:3000/properties/Disk - $ curl -X POST -d meth=GetStorage http://localhost:3000/calls - [{"mount":"/boot/efi","device":"/dev/sda1","type":"vfat","size":"536870912"},... - + $ curl http://localhost:3000/properties + [{"Disk":"/dev/sda","Product":"openSUSE-Addon-NonOss","Language":"en_US","Status":0}] + $ curl -X PUT -d value=/dev/sda http://localhost:3000/properties/Disk + $ curl -X POST -d meth=GetStorage http://localhost:3000/calls + [{"mount":"/boot/efi","device":"/dev/sda1","type":"vfat","size":"536870912"},... ## Web UI The current UI is a small web application built with [React](https://reactjs.org/). It allows to set a few installation parameters and start the installation (not implemented yet). - $ cd we - $ npm install - $ npm start + $ cd web + $ npm install + $ npm start Point your browser to http://localhost:3000 and enjoy! diff --git a/yastd/Gemfile b/yastd/Gemfile index eba16c4b3b..4f97877a66 100644 --- a/yastd/Gemfile +++ b/yastd/Gemfile @@ -4,6 +4,8 @@ source "https://rubygems.org" gem "rake" gem "ruby-dbus" +gem "eventmachine" +gem "nokogiri" # Required by YaST gem "cheetah" diff --git a/yastd/Gemfile.lock b/yastd/Gemfile.lock new file mode 100644 index 0000000000..274cbc83f8 --- /dev/null +++ b/yastd/Gemfile.lock @@ -0,0 +1,27 @@ +GEM + remote: https://rubygems.org/ + specs: + abstract_method (1.2.1) + cheetah (1.0.0) + abstract_method (~> 1.2) + eventmachine (1.2.7) + fast_gettext (2.1.0) + nokogiri (1.12.5-x86_64-linux) + racc (~> 1.4) + racc (1.6.0) + rake (13.0.6) + ruby-dbus (0.16.0) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + cheetah + eventmachine + fast_gettext + nokogiri + rake + ruby-dbus + +BUNDLED WITH + 2.2.27 From cf9a745785d1ad6a441fba5a0544824d1b7cafb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 15:07:06 +0000 Subject: [PATCH 04/13] [yastd] Use a callback to notify status changes * It breaks the circular dependency of DBus::Installer and Installer. * The Installer class knows nothing about D-Bus. --- yastd/lib/yast2/dbus/installer.rb | 8 +++++++- yastd/lib/yast2/dbus/service.rb | 5 +---- yastd/lib/yast2/installer.rb | 29 ++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/yastd/lib/yast2/dbus/installer.rb b/yastd/lib/yast2/dbus/installer.rb index 5802d38ccf..b01d09ec17 100644 --- a/yastd/lib/yast2/dbus/installer.rb +++ b/yastd/lib/yast2/dbus/installer.rb @@ -37,6 +37,11 @@ class Installer < ::DBus::Object def initialize(installer, logger, *args) @installer = installer @logger = logger + + installer.on_status_change do |status| + self.StatusChanged(status.id) + end + super(*args) end @@ -110,7 +115,8 @@ def initialize(installer, logger, *args) end begin - installer.send(propname.downcase.to_s).to_s + value = installer.send(propname.downcase.to_s) + value.respond_to?(:id) ? value.id : value.to_s rescue NoMethodError raise ::DBus.error("org.freedesktop.DBus.Error.InvalidArgs"), "Property '#{interface}.#{propname}' not found on object '#{@path}'" diff --git a/yastd/lib/yast2/dbus/service.rb b/yastd/lib/yast2/dbus/service.rb index ecdae7dd5d..114d3635d8 100644 --- a/yastd/lib/yast2/dbus/service.rb +++ b/yastd/lib/yast2/dbus/service.rb @@ -66,10 +66,7 @@ def dispatch attr_reader :logger def build_installer - installer = Yast2::Installer.new( - dbus_client: Yast2::DBus::InstallerClient.new, - logger: logger - ) + installer = Yast2::Installer.new(logger: logger) installer.probe installer end diff --git a/yastd/lib/yast2/installer.rb b/yastd/lib/yast2/installer.rb index b0174158d2..14b22f9e85 100644 --- a/yastd/lib/yast2/installer.rb +++ b/yastd/lib/yast2/installer.rb @@ -4,7 +4,6 @@ require "y2packager/product" require "y2storage" require "yast2/installer_status" -require "yast2/dbus/installer_client" Yast.import "CommandLine" require "dbus" @@ -30,16 +29,23 @@ class InvalidValue < StandardError; end attr_reader :language # @return [InstallerStatus] - attr_accessor :status + attr_reader :status # Returns a new instance of the Installer class # - # @note DBus::InstallerClient could be replaced with a generic notifier - # in the future which abstracts whether we are using DBus or not. + # @example Probe and run the installation + # installer = Installer.new + # installer.probe + # installer.install + # + # @example Reacting on status change + # installer = Installer.new + # installer.on_status_change do |status| + # log.info "Status changed: #{status}" + # end # - # @param dbus_client [DBus::InstallerClient] Installer client # @param logger [Logger,nil] Logger to write messages to - def initialize(dbus_client:, logger: nil) + def initialize(logger: nil) Yast::Mode.SetUI("commandline") Yast::Mode.SetMode("installation") @disks = [] @@ -113,6 +119,15 @@ def install change_status(InstallerStatus::IDLE) end + # Callback to run when the status changes + # + # This callback receives the new InstallerStatus instance. + # + # @return block [Proc] Code to run when the status changes + def on_status_change(&block) + @on_status_change = block + end + private attr_reader :dbus_client @@ -120,7 +135,7 @@ def install def change_status(new_status) @status = new_status begin - dbus_client.status = status.id + @on_status_change.call(new_status) if @on_status_change rescue ::DBus::Error # DBus object is not available yet end From b560f4d0942b9ae3779f1d501a7708b5848ab8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 15:08:48 +0000 Subject: [PATCH 05/13] [yastd] Remove the InstallerClient --- yastd/lib/yast2/dbus/installer_client.rb | 64 ------------------------ 1 file changed, 64 deletions(-) delete mode 100644 yastd/lib/yast2/dbus/installer_client.rb diff --git a/yastd/lib/yast2/dbus/installer_client.rb b/yastd/lib/yast2/dbus/installer_client.rb deleted file mode 100644 index 94383a5321..0000000000 --- a/yastd/lib/yast2/dbus/installer_client.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -# -# Copyright (c) [2021] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Yast2 - module DBus - # D-Bus client for the installer object - # - # It offers a higher level API to the /org/opensuse/YaST/Installer object. - # - # @example Set the installer status - # client = InstallerClient.new - # client.status = InstallerStatus::IDLE.id - class InstallerClient - SERVICE_NAME = "org.opensuse.YaST" - OBJECT_PATH = "/org/opensuse/YaST/Installer" - IFACE = "org.opensuse.YaST.Installer" - - # Set's the installer status - # - # @param id [Integer] Installer status - # @see InstallerStatus - def status=(id) - installer_obj["org.freedesktop.DBus.Properties"].Set( - IFACE, "Status", id - ) - end - - private - - # @return [DBus::ProxyObject] Returns a proxy object for - # "/org/opensuse/YaST/Installer" - def installer_obj - return @installer_obj if @installer_obj - - bus = ::DBus::SystemBus.instance - service = bus.service(SERVICE_NAME) - @installer_obj = service.object(OBJECT_PATH) - @installer_obj.default_iface = IFACE - @installer_obj - end - end - end -end From 3f3e6a13c8b11557a3fb65302d3c819771966a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 15:09:05 +0000 Subject: [PATCH 06/13] [web] Fix the URL used by the "Install" button --- web/src/lib/InstallerClient.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/lib/InstallerClient.js b/web/src/lib/InstallerClient.js index fe5f8cbc51..9881eb47bc 100644 --- a/web/src/lib/InstallerClient.js +++ b/web/src/lib/InstallerClient.js @@ -83,6 +83,8 @@ export default class InstallerClient { } async startInstallation() { - return await axios.put(`${this.url}/installation.json`, { action: 'start' }); + return await axios.post( + `${this.url}/calls`, { meth: "Start" } + ); } } From 26862b2cf58331599038a249b2530d6bdb34d197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 16:22:54 +0000 Subject: [PATCH 07/13] Add a requirements section to the README file --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9685d86edb..a846536769 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,13 @@ service. At first sight, we have identified these components: * A user interface. For this experiment, we have decided to use a [Cockpit](https://cockpit-project.org/) module. +## Requirements + +To build and run this software you need a few tools. To install them on openSUSE +Tumbleweed just type: + + $ sudo zypper in gcc gcc-c++ make openssl-devel ruby-devel npm + ## yastd `yastd` is a YaST-based service that is able to install a system. You can interact with such a From 23f96d990b093ee7e17c30739245955d3984c0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 16:34:36 +0000 Subject: [PATCH 08/13] [proxy] Forward the StatusChanged to the browser --- web/src/App.js | 1 + yastd-proxy/bin/yastd-proxy | 4 ++++ yastd-proxy/lib/yastd-proxy/dbus_client.rb | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/web/src/App.js b/web/src/App.js index d5f8651d5b..1bafb2dd47 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -48,6 +48,7 @@ function App() { loadOptions(dispatch); loadInstallation(dispatch); registerWebSocketHandler(event => { + // TODO: handle other events console.log("WebSocket Event", event); const { data } = event; const changedKeys = Object.keys(JSON.parse(data)); diff --git a/yastd-proxy/bin/yastd-proxy b/yastd-proxy/bin/yastd-proxy index 592aa3b11b..bb2dba36b2 100755 --- a/yastd-proxy/bin/yastd-proxy +++ b/yastd-proxy/bin/yastd-proxy @@ -55,6 +55,10 @@ EM.run do ws.send changes.to_json end + client.on_status_change do |status_id| + ws.send({ event: "StatusChanged", status: status_id }.to_json) + end + EventMachine::PeriodicTimer.new(0.5) { client.dispatch } end end diff --git a/yastd-proxy/lib/yastd-proxy/dbus_client.rb b/yastd-proxy/lib/yastd-proxy/dbus_client.rb index ae8a71f5fa..485d5ae3cc 100644 --- a/yastd-proxy/lib/yastd-proxy/dbus_client.rb +++ b/yastd-proxy/lib/yastd-proxy/dbus_client.rb @@ -82,12 +82,22 @@ def on_property_change(&block) end end + # Runs a block when the status changes + # + # @param block [Proc] Block to run + def on_status_change(&block) + installer_obj[IFACE].on_signal("StatusChanged") do |status| + block.call(status) + end + end + # Dispatch the message queue in a non-blocking fashion # # This method runs any callback defined using the #on_property_change for # each change. # # @see #on_property_change + # @see #on_status_change def dispatch bus.dispatch_message_queue end From 277af2042816e28e6208d7b517235bd8178e447d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 24 Dec 2021 17:05:06 +0000 Subject: [PATCH 09/13] [yastd] Fix the commented call to inst_prepdisk * This call is still commented, but now it will work if it is uncommented. --- yastd/lib/yast2/installer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yastd/lib/yast2/installer.rb b/yastd/lib/yast2/installer.rb index 14b22f9e85..94b7e4cce9 100644 --- a/yastd/lib/yast2/installer.rb +++ b/yastd/lib/yast2/installer.rb @@ -44,6 +44,7 @@ class InvalidValue < StandardError; end # log.info "Status changed: #{status}" # end # + # @param dbus_client [DBus::InstallerClient] Installer client # @param logger [Logger,nil] Logger to write messages to def initialize(logger: nil) Yast::Mode.SetUI("commandline") @@ -109,7 +110,7 @@ def install Yast::Installation.destdir = "/mnt" logger.info "Installing(partitioning)" change_status(InstallerStatus::PARTITIONING) - # Yast::WFM.CallFunction(["inst_prepdisk"], []) + # Yast::WFM.CallFunction("inst_prepdisk", []) sleep 5 # Install software logger.info "Installing(installing software)" From 7f8362b5bc708d5a04c2a373c2fd9520dc6cdf3b Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 27 Dec 2021 16:51:51 +0100 Subject: [PATCH 10/13] fix namespace in pkg callbacks --- yastd/lib/yast2/package_callbacks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yastd/lib/yast2/package_callbacks.rb b/yastd/lib/yast2/package_callbacks.rb index a4acb070cf..7a512507b3 100644 --- a/yastd/lib/yast2/package_callbacks.rb +++ b/yastd/lib/yast2/package_callbacks.rb @@ -40,7 +40,7 @@ def initialize(progress) end def setup - Pkg.CallbackDonePackage( + Yast::Pkg.CallbackDonePackage( fun_ref(method(:package_installed), "string (integer, string)") ) end From 1ff3d69c02781dbcbca70ba999856585343828e7 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 27 Dec 2021 17:02:27 +0100 Subject: [PATCH 11/13] one more namespace fix --- yastd/lib/yast2/software.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yastd/lib/yast2/software.rb b/yastd/lib/yast2/software.rb index 44c18f4b33..caa4efbead 100644 --- a/yastd/lib/yast2/software.rb +++ b/yastd/lib/yast2/software.rb @@ -69,7 +69,7 @@ def install(progress) PackageCallbacks.setup(progress) # TODO: error handling - Yast::Pkg.TargetInitialize(Installation.destdir) + Yast::Pkg.TargetInitialize(Yast::Installation.destdir) commit_result = Yast::PackageInstallation.Commit({}) if commit_result.nil? || commit_result.empty? From ce75fdcf1372ef3093ef0a2a2eaa8c2dfcf62f23 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 27 Dec 2021 17:10:24 +0100 Subject: [PATCH 12/13] fix scoping --- yastd/lib/yast2/package_callbacks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yastd/lib/yast2/package_callbacks.rb b/yastd/lib/yast2/package_callbacks.rb index 7a512507b3..a83fa1d6c5 100644 --- a/yastd/lib/yast2/package_callbacks.rb +++ b/yastd/lib/yast2/package_callbacks.rb @@ -28,13 +28,13 @@ module Yast2 # This class represents the installer status class PackageCallbacks class << self - attr_reader :progress - def setup(progress) new(progress).setup end end + attr_reader :progress + def initialize(progress) @progress = progress end From 60ec49cef3e18a298a879963d07e6483bbd645f5 Mon Sep 17 00:00:00 2001 From: Josef Reidinger Date: Mon, 27 Dec 2021 17:52:24 +0100 Subject: [PATCH 13/13] remove rest of dbus client --- yastd/lib/yast2/installer.rb | 6 +----- yastd/lib/yast2/progress.rb | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/yastd/lib/yast2/installer.rb b/yastd/lib/yast2/installer.rb index 418e86c27a..f0b360a798 100644 --- a/yastd/lib/yast2/installer.rb +++ b/yastd/lib/yast2/installer.rb @@ -49,7 +49,6 @@ class InvalidValue < StandardError; end # log.info "Status changed: #{status}" # end # - # @param dbus_client [DBus::InstallerClient] Installer client # @param logger [Logger,nil] Logger to write messages to def initialize(logger: nil) Yast::Mode.SetUI("commandline") @@ -58,10 +57,9 @@ def initialize(logger: nil) @languages = [] @products = [] @status = InstallerStatus::IDLE - @dbus_client = dbus_client @logger = logger || Logger.new(STDOUT) @software = Software.new(@logger) - @progress = Progress.new(dbus_client) + @progress = Progress.new(nil) # TODO: fix passing progress end def options @@ -139,8 +137,6 @@ def on_status_change(&block) private - attr_reader :dbus_client - def change_status(new_status) @status = new_status begin diff --git a/yastd/lib/yast2/progress.rb b/yastd/lib/yast2/progress.rb index 1839df3dac..9a236a07c0 100644 --- a/yastd/lib/yast2/progress.rb +++ b/yastd/lib/yast2/progress.rb @@ -35,7 +35,7 @@ def packages_to_install=(value) def package_installed @remaining_pkgs -= 1 - @dbus_obj.report_progress( + @dbus_obj&.report_progress( # TODO: localization "Installing packages (#{@remaining_pkgs} remains)", 1, 0, @total_pkgs, @total_pkgs - @remaining_pkgs