d-installer 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +29 -0
  3. data/Gemfile.lock +75 -0
  4. data/bin/d-installer +74 -0
  5. data/etc/d-installer.yaml +284 -0
  6. data/lib/dinstaller/can_ask_question.rb +48 -0
  7. data/lib/dinstaller/cmdline_args.rb +80 -0
  8. data/lib/dinstaller/cockpit_manager.rb +176 -0
  9. data/lib/dinstaller/config.rb +128 -0
  10. data/lib/dinstaller/config_reader.rb +164 -0
  11. data/lib/dinstaller/dbus/base_object.rb +58 -0
  12. data/lib/dinstaller/dbus/clients/base.rb +71 -0
  13. data/lib/dinstaller/dbus/clients/language.rb +86 -0
  14. data/lib/dinstaller/dbus/clients/manager.rb +76 -0
  15. data/lib/dinstaller/dbus/clients/software.rb +185 -0
  16. data/lib/dinstaller/dbus/clients/users.rb +112 -0
  17. data/lib/dinstaller/dbus/clients/with_progress.rb +56 -0
  18. data/lib/dinstaller/dbus/clients/with_service_status.rb +75 -0
  19. data/lib/dinstaller/dbus/clients.rb +34 -0
  20. data/lib/dinstaller/dbus/interfaces/progress.rb +113 -0
  21. data/lib/dinstaller/dbus/interfaces/service_status.rb +89 -0
  22. data/lib/dinstaller/dbus/language.rb +93 -0
  23. data/lib/dinstaller/dbus/language_service.rb +92 -0
  24. data/lib/dinstaller/dbus/manager.rb +147 -0
  25. data/lib/dinstaller/dbus/manager_service.rb +132 -0
  26. data/lib/dinstaller/dbus/question.rb +176 -0
  27. data/lib/dinstaller/dbus/questions.rb +124 -0
  28. data/lib/dinstaller/dbus/service_runner.rb +97 -0
  29. data/lib/dinstaller/dbus/service_status.rb +87 -0
  30. data/lib/dinstaller/dbus/software/manager.rb +131 -0
  31. data/lib/dinstaller/dbus/software/proposal.rb +82 -0
  32. data/lib/dinstaller/dbus/software.rb +31 -0
  33. data/lib/dinstaller/dbus/software_service.rb +86 -0
  34. data/lib/dinstaller/dbus/storage/proposal.rb +170 -0
  35. data/lib/dinstaller/dbus/storage.rb +30 -0
  36. data/lib/dinstaller/dbus/users.rb +132 -0
  37. data/lib/dinstaller/dbus/users_service.rb +92 -0
  38. data/lib/dinstaller/dbus/with_service_status.rb +48 -0
  39. data/lib/dinstaller/dbus/y2dir/manager/modules/Package.rb +51 -0
  40. data/lib/dinstaller/dbus/y2dir/manager/modules/PackagesProposal.rb +62 -0
  41. data/lib/dinstaller/dbus/y2dir/modules/Autologin.rb +214 -0
  42. data/lib/dinstaller/dbus/y2dir/software/modules/SpaceCalculation.rb +44 -0
  43. data/lib/dinstaller/dbus.rb +11 -0
  44. data/lib/dinstaller/errors.rb +28 -0
  45. data/lib/dinstaller/installation_phase.rb +106 -0
  46. data/lib/dinstaller/language.rb +73 -0
  47. data/lib/dinstaller/luks_activation_question.rb +92 -0
  48. data/lib/dinstaller/manager.rb +261 -0
  49. data/lib/dinstaller/network.rb +53 -0
  50. data/lib/dinstaller/package_callbacks.rb +69 -0
  51. data/lib/dinstaller/progress.rb +149 -0
  52. data/lib/dinstaller/question.rb +103 -0
  53. data/lib/dinstaller/questions_manager.rb +145 -0
  54. data/lib/dinstaller/security.rb +96 -0
  55. data/lib/dinstaller/service_status_recorder.rb +58 -0
  56. data/lib/dinstaller/software.rb +232 -0
  57. data/lib/dinstaller/storage/actions.rb +90 -0
  58. data/lib/dinstaller/storage/callbacks/activate.rb +93 -0
  59. data/lib/dinstaller/storage/callbacks/activate_luks.rb +93 -0
  60. data/lib/dinstaller/storage/callbacks/activate_multipath.rb +77 -0
  61. data/lib/dinstaller/storage/callbacks.rb +30 -0
  62. data/lib/dinstaller/storage/manager.rb +104 -0
  63. data/lib/dinstaller/storage/proposal.rb +197 -0
  64. data/lib/dinstaller/storage.rb +30 -0
  65. data/lib/dinstaller/users.rb +156 -0
  66. data/lib/dinstaller/with_progress.rb +63 -0
  67. data/lib/dinstaller.rb +5 -0
  68. data/share/dbus.conf +38 -0
  69. data/share/dbus.service +5 -0
  70. data/share/systemd.service +14 -0
  71. metadata +295 -0
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ module DInstaller
23
+ module DBus
24
+ # Name space for software D-Bus classes
25
+ module Software
26
+ end
27
+ end
28
+ end
29
+
30
+ require "dinstaller/dbus/software/manager"
31
+ require "dinstaller/dbus/software/proposal"
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ require "dbus"
23
+ require "dinstaller/dbus/software"
24
+ require "dinstaller/software"
25
+
26
+ module DInstaller
27
+ module DBus
28
+ # D-Bus service (org.opensuse.DInstaller.Software)
29
+ #
30
+ # It connects to the system D-Bus and answers requests on objects below
31
+ # `/org/opensuse/DInstaller/Software`.
32
+ class SoftwareService
33
+ SERVICE_NAME = "org.opensuse.DInstaller.Software"
34
+ private_constant :SERVICE_NAME
35
+
36
+ # D-Bus connection
37
+ #
38
+ # @return [::DBus::Connection]
39
+ attr_reader :bus
40
+
41
+ # @param config [Config] Configuration object
42
+ # @param logger [Logger]
43
+ def initialize(config, logger = nil)
44
+ @logger = logger || Logger.new($stdout)
45
+ @bus = ::DBus::SystemBus.instance
46
+ @backend = DInstaller::Software.new(config, logger)
47
+ @backend.on_progress_change { dispatch }
48
+ end
49
+
50
+ # Exports the software object through the D-Bus service
51
+ def export
52
+ dbus_objects.each { |o| service.export(o) }
53
+ paths = dbus_objects.map(&:path).join(", ")
54
+ logger.info "Exported #{paths} objects"
55
+ end
56
+
57
+ # Call this from some main loop to dispatch the D-Bus messages
58
+ def dispatch
59
+ bus.dispatch_message_queue
60
+ end
61
+
62
+ private
63
+
64
+ # @return [Logger]
65
+ attr_reader :logger, :backend
66
+
67
+ # @return [::DBus::Service]
68
+ def service
69
+ @service ||= bus.request_service(SERVICE_NAME)
70
+ end
71
+
72
+ # @return [Array<::DBus::Object>]
73
+ def dbus_objects
74
+ @dbus_objects ||= [
75
+ dbus_software_manager,
76
+ DInstaller::DBus::Software::Proposal.new(logger)
77
+ ]
78
+ end
79
+
80
+ # @return [DInstaller::DBus::Software::Manager]
81
+ def dbus_software_manager
82
+ @dbus_software_manager ||= DInstaller::DBus::Software::Manager.new(@backend, logger)
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ require "dbus"
23
+ require "dinstaller/dbus/base_object"
24
+ require "dinstaller/dbus/with_service_status"
25
+ require "dinstaller/dbus/interfaces/service_status"
26
+ require "dinstaller/storage/proposal"
27
+
28
+ module DInstaller
29
+ module DBus
30
+ module Storage
31
+ # D-Bus object to manage a storage proposal
32
+ class Proposal < BaseObject
33
+ include WithServiceStatus
34
+ include Interfaces::ServiceStatus
35
+
36
+ PATH = "/org/opensuse/DInstaller/Storage/Proposal1"
37
+ private_constant :PATH
38
+
39
+ # Constructor
40
+ #
41
+ # @param backend [DInstaller::Storage::Proposal]
42
+ # @param logger [Logger]
43
+ def initialize(backend, logger)
44
+ super(PATH, logger: logger)
45
+ @backend = backend
46
+
47
+ register_callbacks
48
+ register_service_status_callbacks
49
+ end
50
+
51
+ STORAGE_PROPOSAL_INTERFACE = "org.opensuse.DInstaller.Storage.Proposal1"
52
+ private_constant :STORAGE_PROPOSAL_INTERFACE
53
+
54
+ dbus_interface STORAGE_PROPOSAL_INTERFACE do
55
+ dbus_reader :lvm, "b", dbus_name: "LVM"
56
+
57
+ dbus_reader :candidate_devices, "as"
58
+
59
+ # The first string is the name of the device (as expected by #Calculate for
60
+ # the setting CandidateDevices), the second one is the label to represent that device in
61
+ # the UI when further information is needed.
62
+ #
63
+ # TODO: this representation is a temporary solution. In the future we should likely
64
+ # return more complex structures, probably with an interface similar to
65
+ # com.redhat.Blivet0.Device or org.freedesktop.UDisks2.Block.
66
+ dbus_reader :available_devices, "a(ssa{sv})"
67
+
68
+ # result: 0 success; 1 error
69
+ dbus_method :Calculate, "in settings:a{sv}, out result:u" do |settings|
70
+ success = busy_while do
71
+ backend.calculate(to_proposal_properties(settings))
72
+ end
73
+
74
+ success ? 0 : 1
75
+ end
76
+
77
+ dbus_reader :actions, "aa{sv}"
78
+ end
79
+
80
+ # List of disks available for installation
81
+ #
82
+ # Each device is represented by an array containing id and UI label. See the documentation
83
+ # of the available_devices DBus reader.
84
+ #
85
+ # @see DInstaller::Storage::Proposal
86
+ #
87
+ # @return [Array<Array>]
88
+ def available_devices
89
+ backend.available_devices.map do |dev|
90
+ [dev.name, backend.device_label(dev), {}]
91
+ end
92
+ end
93
+
94
+ # @see DInstaller::Storage::Proposal
95
+ def lvm
96
+ backend.lvm?
97
+ rescue DInstaller::Storage::Proposal::NoProposalError
98
+ false
99
+ end
100
+
101
+ # @see DInstaller::Storage::Proposal
102
+ def candidate_devices
103
+ backend.candidate_devices
104
+ rescue DInstaller::Storage::Proposal::NoProposalError
105
+ []
106
+ end
107
+
108
+ # List of sorted actions in D-Bus format
109
+ #
110
+ # @see #to_dbus
111
+ #
112
+ # @return [Array<Hash>]
113
+ def actions
114
+ backend.actions.all.map { |a| action_to_dbus(a) }
115
+ end
116
+
117
+ private
118
+
119
+ # @return [DInstaller::Storage::Proposal]
120
+ attr_reader :backend
121
+
122
+ # @return [Logger]
123
+ attr_reader :logger
124
+
125
+ # Equivalence between properties names in D-Bus and backend.
126
+ PROPOSAL_PROPERTIES = {
127
+ "LVM" => "use_lvm",
128
+ "CandidateDevices" => "candidate_devices"
129
+ }.freeze
130
+ private_constant :PROPOSAL_PROPERTIES
131
+
132
+ # Registers callback to be called when properties change
133
+ def register_callbacks
134
+ backend.add_on_change_listener do
135
+ dbus_properties_changed(STORAGE_PROPOSAL_INTERFACE, { "LVM" => lvm,
136
+ "CandidateDevices" => candidate_devices,
137
+ "AvailableDevices" => available_devices,
138
+ "Actions" => actions }, [])
139
+ end
140
+ end
141
+
142
+ # Converts settings from D-Bus to backend names
143
+ #
144
+ # @example
145
+ # settings = { "LVM" => true, "CandidateDevices" => ["/dev/sda"] }
146
+ # to_proposal_settings(settings) #=>
147
+ # { "use_lvm" => true, "candidate_devices" => ["/dev/sda"] }
148
+ #
149
+ # @param settings [Hash]
150
+ def to_proposal_properties(settings)
151
+ settings.each_with_object({}) do |e, h|
152
+ h[PROPOSAL_PROPERTIES[e.first]] = e.last
153
+ end
154
+ end
155
+
156
+ # Converts an action to D-Bus format
157
+ #
158
+ # @param action [Y2Storage::CompoundAction]
159
+ # @return [Hash]
160
+ def action_to_dbus(action)
161
+ {
162
+ "Text" => action.sentence,
163
+ "Subvol" => action.device_is?(:btrfs_subvolume),
164
+ "Delete" => action.delete?
165
+ }
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ module DInstaller
23
+ module DBus
24
+ # Namespace for storage D-Bus classes
25
+ module Storage
26
+ end
27
+ end
28
+ end
29
+
30
+ require "dinstaller/dbus/storage/proposal"
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ require "dbus"
23
+ require "dinstaller/users"
24
+ require "dinstaller/dbus/base_object"
25
+ require "dinstaller/dbus/with_service_status"
26
+ require "dinstaller/dbus/interfaces/service_status"
27
+
28
+ module DInstaller
29
+ module DBus
30
+ # YaST D-Bus object (/org/opensuse/DInstaller/Users1)
31
+ class Users < BaseObject
32
+ include WithServiceStatus
33
+ include Interfaces::ServiceStatus
34
+
35
+ PATH = "/org/opensuse/DInstaller/Users1"
36
+ private_constant :PATH
37
+
38
+ # Constructor
39
+ #
40
+ # @param backend [DInstaller::Users]
41
+ # @param logger [Logger]
42
+ def initialize(backend, logger)
43
+ super(PATH, logger: logger)
44
+ @backend = backend
45
+ register_service_status_callbacks
46
+ end
47
+
48
+ USERS_INTERFACE = "org.opensuse.DInstaller.Users1"
49
+ private_constant :USERS_INTERFACE
50
+
51
+ FUSER_SIG = "in FullName:s, in UserName:s, in Password:s, in AutoLogin:b, in data:a{sv}"
52
+ private_constant :FUSER_SIG
53
+
54
+ # rubocop:disable Metrics/BlockLength
55
+ dbus_interface USERS_INTERFACE do
56
+ dbus_reader :root_password_set, "b"
57
+
58
+ dbus_reader :root_ssh_key, "s", dbus_name: "RootSSHKey"
59
+
60
+ dbus_reader :first_user, "(ssba{sv})"
61
+
62
+ dbus_method :SetRootPassword,
63
+ "in Value:s, in Encrypted:b, out result:u" do |value, encrypted|
64
+ logger.info "Setting Root Password"
65
+ backend.assign_root_password(value, encrypted)
66
+
67
+ dbus_properties_changed(USERS_INTERFACE, { "RootPasswordSet" => !value.empty? }, [])
68
+ 0
69
+ end
70
+
71
+ dbus_method :RemoveRootPassword, "out result:u" do
72
+ logger.info "Clearing the root password"
73
+ backend.remove_root_password
74
+
75
+ dbus_properties_changed(USERS_INTERFACE, { "RootPasswordSet" => backend.root_password? },
76
+ [])
77
+ 0
78
+ end
79
+
80
+ dbus_method :SetRootSSHKey, "in Value:s, out result:u" do |value|
81
+ logger.info "Setting Root ssh key"
82
+ backend.root_ssh_key = (value)
83
+
84
+ dbus_properties_changed(USERS_INTERFACE, { "RootSSHKey" => value }, [])
85
+ 0
86
+ end
87
+
88
+ dbus_method :SetFirstUser,
89
+ FUSER_SIG + ", out result:u" do |full_name, user_name, password, auto_login, data|
90
+ logger.info "Setting first user #{full_name}"
91
+ backend.assign_first_user(full_name, user_name, password, auto_login, data)
92
+
93
+ dbus_properties_changed(USERS_INTERFACE, { "FirstUser" => first_user }, [])
94
+ 0
95
+ end
96
+
97
+ dbus_method :RemoveFirstUser, "out result:u" do
98
+ logger.info "Removing the first user"
99
+ backend.remove_first_user
100
+
101
+ dbus_properties_changed(USERS_INTERFACE, { "FirstUser" => first_user }, [])
102
+ 0
103
+ end
104
+
105
+ dbus_method :Write, "out result:u" do
106
+ logger.info "Writting users"
107
+
108
+ backend.write
109
+ 0
110
+ end
111
+ end
112
+ # rubocop:enable Metrics/BlockLength
113
+
114
+ def root_ssh_key
115
+ backend.root_ssh_key
116
+ end
117
+
118
+ def first_user
119
+ backend.first_user
120
+ end
121
+
122
+ def root_password_set
123
+ backend.root_password?
124
+ end
125
+
126
+ private
127
+
128
+ # @return [DInstaller::Users]
129
+ attr_reader :backend
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ require "dbus"
23
+ require "dinstaller/dbus/users"
24
+ require "dinstaller/users"
25
+
26
+ module DInstaller
27
+ module DBus
28
+ # D-Bus service (org.opensuse.DInstaller.Users)
29
+ #
30
+ # It connects to the system D-Bus and answers requests on objects below
31
+ # `/org/opensuse/DInstaller/Users1`.
32
+ class UsersService
33
+ # Service name
34
+ #
35
+ # @return [String]
36
+ SERVICE_NAME = "org.opensuse.DInstaller.Users"
37
+ private_constant :SERVICE_NAME
38
+
39
+ # System D-Bus
40
+ #
41
+ # @return [::DBus::Connection]
42
+ attr_reader :bus
43
+
44
+ # @param config [Config] Configuration object
45
+ # @param logger [Logger]
46
+ def initialize(_config, logger = nil)
47
+ @logger = logger || Logger.new($stdout)
48
+ @bus = ::DBus::SystemBus.instance
49
+ end
50
+
51
+ # Exports the installer object through the D-Bus service
52
+ def export
53
+ dbus_objects.each { |o| service.export(o) }
54
+
55
+ paths = dbus_objects.map(&:path).join(", ")
56
+ logger.info "Exported #{paths} objects"
57
+ end
58
+
59
+ # Call this from some main loop to dispatch the D-Bus messages
60
+ def dispatch
61
+ bus.dispatch_message_queue
62
+ end
63
+
64
+ private
65
+
66
+ # @return [Logger]
67
+ attr_reader :logger
68
+
69
+ # @return [::DBus::Service]
70
+ def service
71
+ @service ||= bus.request_service(SERVICE_NAME)
72
+ end
73
+
74
+ # @return [Array<::DBus::Object>]
75
+ def dbus_objects
76
+ @dbus_objects ||= [
77
+ users_dbus
78
+ ]
79
+ end
80
+
81
+ # @return [DInstaller::DBus::Users]
82
+ def users_dbus
83
+ @users_dbus ||= DInstaller::DBus::Users.new(users_backend(logger), logger)
84
+ end
85
+
86
+ # @return [DInstaller::Users]
87
+ def users_backend(logger)
88
+ @users_backend ||= DInstaller::Users.new(logger)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) [2022] SUSE LLC
4
+ #
5
+ # All Rights Reserved.
6
+ #
7
+ # This program is free software; you can redistribute it and/or modify it
8
+ # under the terms of version 2 of the GNU General Public License as published
9
+ # by the Free Software Foundation.
10
+ #
11
+ # This program is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
+ # more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License along
17
+ # with this program; if not, contact SUSE LLC.
18
+ #
19
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
20
+ # find current contact information at www.suse.com.
21
+
22
+ require "dinstaller/dbus/service_status"
23
+
24
+ module DInstaller
25
+ module DBus
26
+ # Mixin to be included by D-Bus objects that needs to register a service status
27
+ module WithServiceStatus
28
+ # Service status
29
+ #
30
+ # @return [ServiceStatus]
31
+ def service_status
32
+ @service_status ||= ServiceStatus.new.idle
33
+ end
34
+
35
+ # Sets the service status to busy meanwhile the given block is running
36
+ #
37
+ # @param block [Proc]
38
+ # @return [Object] the result of the given block
39
+ def busy_while(&block)
40
+ service_status.busy
41
+ result = block.call
42
+ service_status.idle
43
+
44
+ result
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright (c) [2022] SUSE LLC
2
+ #
3
+ # All Rights Reserved.
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify it
6
+ # under the terms of version 2 of the GNU General Public License as published
7
+ # by the Free Software Foundation.
8
+ #
9
+ # This program is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ # more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License along
15
+ # with this program; if not, contact SUSE LLC.
16
+ #
17
+ # To contact SUSE LLC about this file by physical or electronic mail, you may
18
+ # find current contact information at www.suse.com.
19
+
20
+ require "yast"
21
+
22
+ # :nodoc:
23
+ module Yast
24
+ # Replacement for the Yast::Package module
25
+ #
26
+ # @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/packages/src/modules/Package.rb
27
+ class PackageClass < Module
28
+ def main
29
+ puts "Loading mocked module #{__FILE__}"
30
+ end
31
+
32
+ # Determines whether the package is available
33
+ #
34
+ # @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/packages/src/modules/Package.rb#L72
35
+ # @todo Perform a real D-Bus call.
36
+ def Available(_package_name)
37
+ true
38
+ end
39
+
40
+ # Determines whether the package is available
41
+ #
42
+ # @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/packages/src/modules/Package.rb#L121
43
+ # @todo Perform a real D-Bus call.
44
+ def Installed(_package_name, target: nil)
45
+ false
46
+ end
47
+ end
48
+
49
+ Package = PackageClass.new
50
+ Package.main
51
+ end