d-installer 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +75 -0
- data/bin/d-installer +74 -0
- data/etc/d-installer.yaml +284 -0
- data/lib/dinstaller/can_ask_question.rb +48 -0
- data/lib/dinstaller/cmdline_args.rb +80 -0
- data/lib/dinstaller/cockpit_manager.rb +176 -0
- data/lib/dinstaller/config.rb +128 -0
- data/lib/dinstaller/config_reader.rb +164 -0
- data/lib/dinstaller/dbus/base_object.rb +58 -0
- data/lib/dinstaller/dbus/clients/base.rb +71 -0
- data/lib/dinstaller/dbus/clients/language.rb +86 -0
- data/lib/dinstaller/dbus/clients/manager.rb +76 -0
- data/lib/dinstaller/dbus/clients/software.rb +185 -0
- data/lib/dinstaller/dbus/clients/users.rb +112 -0
- data/lib/dinstaller/dbus/clients/with_progress.rb +56 -0
- data/lib/dinstaller/dbus/clients/with_service_status.rb +75 -0
- data/lib/dinstaller/dbus/clients.rb +34 -0
- data/lib/dinstaller/dbus/interfaces/progress.rb +113 -0
- data/lib/dinstaller/dbus/interfaces/service_status.rb +89 -0
- data/lib/dinstaller/dbus/language.rb +93 -0
- data/lib/dinstaller/dbus/language_service.rb +92 -0
- data/lib/dinstaller/dbus/manager.rb +147 -0
- data/lib/dinstaller/dbus/manager_service.rb +132 -0
- data/lib/dinstaller/dbus/question.rb +176 -0
- data/lib/dinstaller/dbus/questions.rb +124 -0
- data/lib/dinstaller/dbus/service_runner.rb +97 -0
- data/lib/dinstaller/dbus/service_status.rb +87 -0
- data/lib/dinstaller/dbus/software/manager.rb +131 -0
- data/lib/dinstaller/dbus/software/proposal.rb +82 -0
- data/lib/dinstaller/dbus/software.rb +31 -0
- data/lib/dinstaller/dbus/software_service.rb +86 -0
- data/lib/dinstaller/dbus/storage/proposal.rb +170 -0
- data/lib/dinstaller/dbus/storage.rb +30 -0
- data/lib/dinstaller/dbus/users.rb +132 -0
- data/lib/dinstaller/dbus/users_service.rb +92 -0
- data/lib/dinstaller/dbus/with_service_status.rb +48 -0
- data/lib/dinstaller/dbus/y2dir/manager/modules/Package.rb +51 -0
- data/lib/dinstaller/dbus/y2dir/manager/modules/PackagesProposal.rb +62 -0
- data/lib/dinstaller/dbus/y2dir/modules/Autologin.rb +214 -0
- data/lib/dinstaller/dbus/y2dir/software/modules/SpaceCalculation.rb +44 -0
- data/lib/dinstaller/dbus.rb +11 -0
- data/lib/dinstaller/errors.rb +28 -0
- data/lib/dinstaller/installation_phase.rb +106 -0
- data/lib/dinstaller/language.rb +73 -0
- data/lib/dinstaller/luks_activation_question.rb +92 -0
- data/lib/dinstaller/manager.rb +261 -0
- data/lib/dinstaller/network.rb +53 -0
- data/lib/dinstaller/package_callbacks.rb +69 -0
- data/lib/dinstaller/progress.rb +149 -0
- data/lib/dinstaller/question.rb +103 -0
- data/lib/dinstaller/questions_manager.rb +145 -0
- data/lib/dinstaller/security.rb +96 -0
- data/lib/dinstaller/service_status_recorder.rb +58 -0
- data/lib/dinstaller/software.rb +232 -0
- data/lib/dinstaller/storage/actions.rb +90 -0
- data/lib/dinstaller/storage/callbacks/activate.rb +93 -0
- data/lib/dinstaller/storage/callbacks/activate_luks.rb +93 -0
- data/lib/dinstaller/storage/callbacks/activate_multipath.rb +77 -0
- data/lib/dinstaller/storage/callbacks.rb +30 -0
- data/lib/dinstaller/storage/manager.rb +104 -0
- data/lib/dinstaller/storage/proposal.rb +197 -0
- data/lib/dinstaller/storage.rb +30 -0
- data/lib/dinstaller/users.rb +156 -0
- data/lib/dinstaller/with_progress.rb +63 -0
- data/lib/dinstaller.rb +5 -0
- data/share/dbus.conf +38 -0
- data/share/dbus.service +5 -0
- data/share/systemd.service +14 -0
- metadata +295 -0
@@ -0,0 +1,62 @@
|
|
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
|
+
require "dinstaller/dbus/clients/software"
|
22
|
+
|
23
|
+
# :nodoc:
|
24
|
+
module Yast
|
25
|
+
# Replacement for the Yast::PackagesProposal module
|
26
|
+
class PackagesProposalClass < Module
|
27
|
+
def main
|
28
|
+
puts "Loading mocked module #{__FILE__}"
|
29
|
+
@client = DInstaller::DBus::Clients::Software.new
|
30
|
+
end
|
31
|
+
|
32
|
+
# @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/general/src/modules/PackagesProposal.rb#L118
|
33
|
+
def AddResolvables(unique_id, type, resolvables, optional: false)
|
34
|
+
client.add_resolvables(unique_id, type, resolvables || [], optional: optional)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
# @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/general/src/modules/PackagesProposal.rb#L145
|
39
|
+
def SetResolvables(unique_id, type, resolvables, optional: false)
|
40
|
+
client.set_resolvables(unique_id, type, resolvables || [], optional: optional)
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
# @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/general/src/modules/PackagesProposal.rb#L285
|
45
|
+
def GetResolvables(unique_id, type, optional: false)
|
46
|
+
client.get_resolvables(unique_id, type, optional: optional)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @see https://github.com/yast/yast-yast2/blob/b8cd178b7f341f6e3438782cb703f4a3ab0529ed/library/general/src/modules/PackagesProposal.rb#L177
|
50
|
+
def RemoveResolvables(unique_id, type, resolvables, optional: false)
|
51
|
+
client.remove_resolvables(unique_id, type, resolvables || [], optional: optional)
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
attr_reader :client
|
58
|
+
end
|
59
|
+
|
60
|
+
PackagesProposal = PackagesProposalClass.new
|
61
|
+
PackagesProposal.main
|
62
|
+
end
|
@@ -0,0 +1,214 @@
|
|
1
|
+
# ------------------------------------------------------------------------------
|
2
|
+
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# This program is free software; you can redistribute it and/or modify it under
|
6
|
+
# the terms of version 2 of the GNU General Public License as published by the
|
7
|
+
# 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 FITNESS
|
11
|
+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License along with
|
14
|
+
# this program; if not, contact Novell, Inc.
|
15
|
+
#
|
16
|
+
# To contact Novell about this file by physical or electronic mail, you may find
|
17
|
+
# current contact information at www.novell.com.
|
18
|
+
# ------------------------------------------------------------------------------
|
19
|
+
|
20
|
+
# File: modules/Autologin.ycp
|
21
|
+
# Package: yast2
|
22
|
+
# Summary: Autologin read/write routines
|
23
|
+
# Author: Jiri Suchomel <jsuchome@suse.cz>
|
24
|
+
# Flags: Stable
|
25
|
+
#
|
26
|
+
# $Id$
|
27
|
+
require "yast"
|
28
|
+
require "dinstaller/dbus/clients/software"
|
29
|
+
|
30
|
+
module Yast
|
31
|
+
class AutologinClass < Module
|
32
|
+
include Yast::Logger
|
33
|
+
|
34
|
+
# Display managers that support autologin.
|
35
|
+
# Notice that xdm does NOT support it!
|
36
|
+
#
|
37
|
+
# "autologin-support" is a pseudo-"provides" that maintainers of display
|
38
|
+
# manager packages can add to indicate that the package has that
|
39
|
+
# capability.
|
40
|
+
DISPLAY_MANAGERS = ["autologin-support", "kdm", "gdm", "sddm", "lightdm"].freeze
|
41
|
+
|
42
|
+
def main
|
43
|
+
textdomain "pam"
|
44
|
+
|
45
|
+
Yast.import "Popup"
|
46
|
+
|
47
|
+
# User to log in automaticaly
|
48
|
+
@user = ""
|
49
|
+
|
50
|
+
# Login without passwords?
|
51
|
+
@pw_less = false
|
52
|
+
|
53
|
+
# Is autologin used? Usualy true when user is not empty, but for the first
|
54
|
+
# time (during installation), this can be true by default although user is ""
|
55
|
+
# (depends on the control file)
|
56
|
+
@used = false
|
57
|
+
|
58
|
+
# Autologin settings modified?
|
59
|
+
@modified = false
|
60
|
+
|
61
|
+
# Pkg stuff initialized?
|
62
|
+
@pkg_initialized = false
|
63
|
+
|
64
|
+
# Software service client
|
65
|
+
@dbus_client = nil
|
66
|
+
end
|
67
|
+
|
68
|
+
def available
|
69
|
+
@available = supported? if @available.nil?
|
70
|
+
@available
|
71
|
+
end
|
72
|
+
|
73
|
+
# Read autologin settings
|
74
|
+
# @return used?
|
75
|
+
def Read
|
76
|
+
if SCR.Read(path(".target.size"), "/etc/sysconfig/displaymanager") == -1
|
77
|
+
@available = false
|
78
|
+
@user = ""
|
79
|
+
@used = false
|
80
|
+
return false
|
81
|
+
end
|
82
|
+
|
83
|
+
@available = supported?
|
84
|
+
@user = Convert.to_string(
|
85
|
+
SCR.Read(path(".sysconfig.displaymanager.DISPLAYMANAGER_AUTOLOGIN"))
|
86
|
+
)
|
87
|
+
@pw_less = Convert.to_string(
|
88
|
+
SCR.Read(
|
89
|
+
path(".sysconfig.displaymanager.DISPLAYMANAGER_PASSWORD_LESS_LOGIN")
|
90
|
+
)
|
91
|
+
) == "yes"
|
92
|
+
|
93
|
+
@user = "" if @user.nil? || @user == ""
|
94
|
+
|
95
|
+
@used = @user != ""
|
96
|
+
@used
|
97
|
+
end
|
98
|
+
|
99
|
+
# Write autologin settings
|
100
|
+
# @param [Boolean] write_only when true, suseconfig script will not be run
|
101
|
+
# @return written anything?
|
102
|
+
def Write(_write_only)
|
103
|
+
return false if !available || !@modified
|
104
|
+
|
105
|
+
Builtins.y2milestone(
|
106
|
+
"writing user %1 for autologin; pw_less is %2",
|
107
|
+
@user,
|
108
|
+
@pw_less
|
109
|
+
)
|
110
|
+
|
111
|
+
SCR.Write(
|
112
|
+
path(".sysconfig.displaymanager.DISPLAYMANAGER_AUTOLOGIN"),
|
113
|
+
@user
|
114
|
+
)
|
115
|
+
SCR.Write(
|
116
|
+
path(".sysconfig.displaymanager.DISPLAYMANAGER_PASSWORD_LESS_LOGIN"),
|
117
|
+
@pw_less ? "yes" : "no"
|
118
|
+
)
|
119
|
+
SCR.Write(path(".sysconfig.displaymanager"), nil)
|
120
|
+
|
121
|
+
@modified = false
|
122
|
+
true
|
123
|
+
end
|
124
|
+
|
125
|
+
# Disable autologin
|
126
|
+
def Disable
|
127
|
+
@user = ""
|
128
|
+
@pw_less = false
|
129
|
+
@used = false
|
130
|
+
@modified = true
|
131
|
+
|
132
|
+
nil
|
133
|
+
end
|
134
|
+
|
135
|
+
# Wrapper for setting the 'used' variable
|
136
|
+
def Use(use)
|
137
|
+
if @used != use
|
138
|
+
@used = use
|
139
|
+
@modified = true
|
140
|
+
end
|
141
|
+
|
142
|
+
nil
|
143
|
+
end
|
144
|
+
|
145
|
+
# Disable autologin and write it (used probably for automatic
|
146
|
+
# disabling without asking)
|
147
|
+
# @param [Boolean] write_only when true, suseconfig script will not be run
|
148
|
+
# @return written anything?
|
149
|
+
def DisableAndWrite(write_only)
|
150
|
+
Disable()
|
151
|
+
Write(write_only)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Ask if autologin should be disabled (and disable it in such case)
|
155
|
+
# @param [String] new The reason for disabling autologin (e.g. new set of users)
|
156
|
+
# @return Is autologin used?
|
157
|
+
def AskForDisabling(new)
|
158
|
+
# popup text (%1 is user name, %2 is additional info,
|
159
|
+
# like "Now LDAP was enabled")
|
160
|
+
question = Builtins.sformat(
|
161
|
+
_(
|
162
|
+
"The automatic login feature is enabled for user %1.\n" +
|
163
|
+
"%2\n" +
|
164
|
+
"Disable automatic login?"
|
165
|
+
),
|
166
|
+
@user,
|
167
|
+
new
|
168
|
+
)
|
169
|
+
|
170
|
+
Disable() if @used && Popup.YesNo(question)
|
171
|
+
@used
|
172
|
+
end
|
173
|
+
|
174
|
+
# Check if autologin is supported with the currently selected or installed
|
175
|
+
# packages.
|
176
|
+
#
|
177
|
+
# @return Boolean
|
178
|
+
def supported?
|
179
|
+
supported = dbus_client.provisions_selected?(DISPLAY_MANAGERS).any?
|
180
|
+
|
181
|
+
if supported
|
182
|
+
log.info("Autologin is supported")
|
183
|
+
else
|
184
|
+
log.info("Autologin is not supported: No package provides any of #{DISPLAY_MANAGERS}")
|
185
|
+
end
|
186
|
+
|
187
|
+
supported
|
188
|
+
end
|
189
|
+
|
190
|
+
publish variable: :user, type: "string"
|
191
|
+
publish variable: :pw_less, type: "boolean"
|
192
|
+
publish variable: :used, type: "boolean"
|
193
|
+
publish variable: :modified, type: "boolean"
|
194
|
+
publish function: :Read, type: "boolean ()"
|
195
|
+
publish function: :Write, type: "boolean (boolean)"
|
196
|
+
publish function: :Disable, type: "void ()"
|
197
|
+
publish function: :Use, type: "void (boolean)"
|
198
|
+
publish function: :supported?, type: "boolean ()"
|
199
|
+
publish function: :DisableAndWrite, type: "boolean (boolean)"
|
200
|
+
publish function: :AskForDisabling, type: "boolean (string)"
|
201
|
+
|
202
|
+
private
|
203
|
+
|
204
|
+
# Software service client
|
205
|
+
#
|
206
|
+
# @return [DInstaller::DBus::Clients::Software] Software service client
|
207
|
+
def dbus_client
|
208
|
+
@dbus_client ||= DInstaller::DBus::Clients::Software.new
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
Autologin = AutologinClass.new
|
213
|
+
Autologin.main
|
214
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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::SpaceCalculation module.
|
25
|
+
class SpaceCalculationClass < Module
|
26
|
+
def main
|
27
|
+
puts "Loading mocked module #{__FILE__}"
|
28
|
+
end
|
29
|
+
|
30
|
+
# @see https://github.com/yast/yast-packager/blob/master/src/modules/SpaceCalculation.rb#L711
|
31
|
+
def GetPartitionInfo; end
|
32
|
+
|
33
|
+
# @see https://github.com/yast/yast-packager/blob/master/src/modules/SpaceCalculation.rb#L860
|
34
|
+
def CheckDiskSize; end
|
35
|
+
|
36
|
+
# @see https://github.com/yast/yast-packager/blob/master/src/modules/SpaceCalculation.rb#L60
|
37
|
+
def GetFailedMounts
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
SpaceCalculation = SpaceCalculationClass.new
|
43
|
+
SpaceCalculation.main
|
44
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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 containing common errors
|
24
|
+
module Errors
|
25
|
+
# Invalid value given by the user
|
26
|
+
class InvalidValue < StandardError; end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,106 @@
|
|
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
|
+
# Represents the installation phase of the manager service and allows to configure callbacks to be
|
24
|
+
# called when the installation phase value changes
|
25
|
+
class InstallationPhase
|
26
|
+
# Possible installation phase values
|
27
|
+
STARTUP = "startup"
|
28
|
+
CONFIG = "config"
|
29
|
+
INSTALL = "install"
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@on_change_callbacks = []
|
33
|
+
end
|
34
|
+
|
35
|
+
# Whether the current installation phase value is startup
|
36
|
+
#
|
37
|
+
# @return [Boolean]
|
38
|
+
def startup?
|
39
|
+
value == STARTUP
|
40
|
+
end
|
41
|
+
|
42
|
+
# Whether the current installation phase value is config
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
def config?
|
46
|
+
value == CONFIG
|
47
|
+
end
|
48
|
+
|
49
|
+
# Whether the current installation phase value is install
|
50
|
+
#
|
51
|
+
# @return [Boolean]
|
52
|
+
def install?
|
53
|
+
value == INSTALL
|
54
|
+
end
|
55
|
+
|
56
|
+
# Sets the installation phase value to startup
|
57
|
+
#
|
58
|
+
# @note Callbacks are called.
|
59
|
+
#
|
60
|
+
# @return [self]
|
61
|
+
def startup
|
62
|
+
change_to(STARTUP)
|
63
|
+
self
|
64
|
+
end
|
65
|
+
|
66
|
+
# Sets the installation phase value to config
|
67
|
+
#
|
68
|
+
# @note Callbacks are called.
|
69
|
+
#
|
70
|
+
# @return [self]
|
71
|
+
def config
|
72
|
+
change_to(CONFIG)
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
# Sets the installation phase value to install
|
77
|
+
#
|
78
|
+
# @note Callbacks are called.
|
79
|
+
#
|
80
|
+
# @return [self]
|
81
|
+
def install
|
82
|
+
change_to(INSTALL)
|
83
|
+
self
|
84
|
+
end
|
85
|
+
|
86
|
+
# Registers callbacks to be called when the installation phase value changes
|
87
|
+
#
|
88
|
+
# @param block [Proc]
|
89
|
+
def on_change(&block)
|
90
|
+
@on_change_callbacks << block
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
# @return [STARTUP, CONFIG, INSTALL]
|
96
|
+
attr_reader :value
|
97
|
+
|
98
|
+
# Changes the installation phase value and runs the callbacks
|
99
|
+
#
|
100
|
+
# @param value [STARTUP, CONFIG, INSTALL]
|
101
|
+
def change_to(value)
|
102
|
+
@value = value
|
103
|
+
@on_change_callbacks.each(&:call)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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 "yast"
|
23
|
+
require "dinstaller/errors"
|
24
|
+
|
25
|
+
Yast.import "Language"
|
26
|
+
|
27
|
+
module DInstaller
|
28
|
+
# Backend for handling language settings
|
29
|
+
class Language
|
30
|
+
# @return [Hash<Array<String,Array<String>>>] Known languages, where the key
|
31
|
+
# is the language code and value is an array containing the translated name,
|
32
|
+
# the english name, etc.
|
33
|
+
attr_reader :languages
|
34
|
+
|
35
|
+
def initialize(logger)
|
36
|
+
@logger = logger
|
37
|
+
@languages = []
|
38
|
+
end
|
39
|
+
|
40
|
+
# Probes the available system languages
|
41
|
+
def probe
|
42
|
+
logger.info "Probing languages"
|
43
|
+
@languages = Yast::Language.GetLanguagesMap(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Writes the language settings
|
47
|
+
def finish
|
48
|
+
Yast::Language.Save
|
49
|
+
end
|
50
|
+
|
51
|
+
# Sets the language
|
52
|
+
#
|
53
|
+
# @param name [String] Language code
|
54
|
+
# @raise Errors::InvalidValue
|
55
|
+
def language=(name)
|
56
|
+
raise Errors::InvalidValue unless languages.include?(name)
|
57
|
+
|
58
|
+
Yast::Language.Set(name)
|
59
|
+
Yast::Language.languages = Yast::Language.RemoveSuffix(name)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns the selected language
|
63
|
+
#
|
64
|
+
# @return [String] Language code
|
65
|
+
def language
|
66
|
+
Yast::Language.language
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
attr_reader :logger
|
72
|
+
end
|
73
|
+
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 "dinstaller/question"
|
23
|
+
|
24
|
+
module DInstaller
|
25
|
+
# This class represent a question to ask whether to activate a LUKS device
|
26
|
+
#
|
27
|
+
# Clients have to answer one of these options:
|
28
|
+
# * skip: to skip the activation of the LUKS device
|
29
|
+
# * decrypt: to activate the device using the provided password
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# question = LuksActivationQuestion.new("/dev/sda1", label: "mydata", size: "10 GiB")
|
33
|
+
# question.password = "n0ts3cr3t"
|
34
|
+
#
|
35
|
+
# question.answer = :skip # in case you do not want to activate the device
|
36
|
+
#
|
37
|
+
# question.answer = :decrypt # in case you want to decrypt with the given password
|
38
|
+
class LuksActivationQuestion < Question
|
39
|
+
# Current attempt to decrypt the device
|
40
|
+
#
|
41
|
+
# @return [Integer]
|
42
|
+
attr_reader :attempt
|
43
|
+
|
44
|
+
# Constructor
|
45
|
+
#
|
46
|
+
# @param device [String] name of the device to be activated (e.g., "/dev/sda1")
|
47
|
+
# @param label [String, nil] label of the device
|
48
|
+
# @param size [String, nil] size of the device (e.g., "5 GiB")
|
49
|
+
def initialize(device, label: nil, size: nil, attempt: 1)
|
50
|
+
@device = device
|
51
|
+
@label = label
|
52
|
+
@size = size
|
53
|
+
@attempt = attempt
|
54
|
+
|
55
|
+
super(generate_text, options: [:skip, :decrypt])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Password to activate the LUKS device
|
59
|
+
#
|
60
|
+
# @return [String, nil] nil means a password has not been provided yet
|
61
|
+
attr_accessor :password
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
# @return [String]
|
66
|
+
attr_reader :device
|
67
|
+
|
68
|
+
# @return [String, nil]
|
69
|
+
attr_reader :label
|
70
|
+
|
71
|
+
# @return [String, nil]
|
72
|
+
attr_reader :size
|
73
|
+
|
74
|
+
# Generate the text for the question
|
75
|
+
#
|
76
|
+
# @return [String]
|
77
|
+
def generate_text
|
78
|
+
"The device #{device_info} is encrypted. Do you want to decrypt it?"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Device information to include in the question
|
82
|
+
#
|
83
|
+
# @return [String]
|
84
|
+
def device_info
|
85
|
+
info = [device]
|
86
|
+
info << label unless label.to_s.empty?
|
87
|
+
info << "(#{size})" unless size.to_s.empty?
|
88
|
+
|
89
|
+
info.join(" ")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|