-
Notifications
You must be signed in to change notification settings - Fork 20
/
inst_autopost.rb
140 lines (118 loc) · 4.22 KB
/
inst_autopost.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File: clients/autoinst_post.ycp
# Package: Auto-installation
# Author: Anas Nashif <nashif@suse.de>
# Summary: This module finishes auto-installation and configures
# the system as described in the profile file.
#
# $Id$
require "autoinstall/entries/registry"
require "autoinstall/importer"
require "autoinstall/ask/runner"
require "autoinstall/ask/stage"
module Yast
class InstAutopostClient < Client
def main
Yast.import "UI"
textdomain "autoinst"
Yast.import "Profile"
Yast.import "AutoInstall"
Yast.import "AutoinstGeneral"
Yast.import "Call"
Yast.import "AutoinstSoftware"
Yast.import "AutoinstScripts"
Yast.import "Report"
Yast.import "Progress"
Yast.import "PackageSystem"
Yast.import "AutoinstConfig"
Builtins.y2debug("Profile=%1", Profile.current)
Report.Import(Ops.get_map(Profile.current, "report", {}))
@autoinstall = SCR.Read(path(".etc.install_inf.AutoYaST"))
Builtins.y2milestone("cmd line=%1", @autoinstall)
if !@autoinstall.nil? && Ops.is_string?(@autoinstall)
AutoinstConfig.ParseCmdLine(Convert.to_string(@autoinstall))
AutoinstConfig.directory = dirname(AutoinstConfig.filepath)
Builtins.y2milestone("dir = %1", AutoinstConfig.directory)
end
@packages = []
@resource = ""
@module_auto = ""
if Ops.get_map(Profile.current, "report", {}) != {}
Report.Import(Ops.get_map(Profile.current, "report", {}))
end
@help_text = _(
"<p>\nPlease wait while the system is prepared for autoinstallation.</p>\n"
)
@progress_stages = [_("Install required packages")]
registry = Y2Autoinstallation::Entries::Registry.instance
modules_to_write = registry.writable_descriptions.select do |description|
description.managed_keys.any? { |k| Profile.current[k] }
end
steps = modules_to_write.size
steps += 3
Progress.New(
_("Preparing System for Automatic Installation"),
"", # progress_title
steps, # progress bar length
@progress_stages,
[],
@help_text
)
Progress.NextStage
Progress.Title(_("Checking for required packages..."))
Y2Autoinstall::Ask::Runner.new(
Yast::Profile.current, stage: Y2Autoinstall::Ask::Stage::CONT
).run
# FIXME: too late here, even though it would be the better place
# if (Profile::current["general"]:$[] != $[])
# AutoinstGeneral::Import(Profile::current["general"]:$[]);
# AutoinstGeneral::SetSignatureHandling();
Builtins.y2milestone("Steps: %1", steps)
importer = Y2Autoinstallation::Importer.new(Profile.current)
modules_to_write.each do |description|
Builtins.y2milestone("current resource: %1", description.resource_name)
# determine name of client, if not use default name
module_auto = description.client_name
importer.import_entry(description)
out = Call.Function(module_auto, ["Packages"])
@packages.concat(out["install"] || []) if out
end
# Checking result of semantic checks of imported values.
return :abort unless AutoInstall.valid_imported_values
# Add all found packages
Progress.NextStep
Progress.Title(_("Adding found packages..."))
@packages = Builtins.filter(@packages) { |p| !PackageSystem.Installed(p) }
AutoinstSoftware.addPostPackages(@packages)
# Finish
Progress.NextStage
Progress.Finish
Builtins.y2milestone("Finished required package collection")
:auto
end
def Step(s)
Progress.NextStep
Progress.Title(
Builtins.sformat(_("Checking for packages required for %1..."), s)
)
nil
end
# Get directory name
# @param filePath [Strig] string path
# @return [String] dirname
def dirname(filePath)
pathComponents = Builtins.splitstring(filePath, "/")
last = Ops.get_string(
pathComponents,
Ops.subtract(Builtins.size(pathComponents), 1),
""
)
ret = Builtins.substring(
filePath,
0,
Ops.subtract(Builtins.size(filePath), Builtins.size(last))
)
ret
end
end
end
Yast::InstAutopostClient.new.main