-
Notifications
You must be signed in to change notification settings - Fork 22
/
inst_repositories_initialization.rb
102 lines (89 loc) · 3.36 KB
/
inst_repositories_initialization.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
# encoding: utf-8
# ------------------------------------------------------------------------------
# Copyright (c) 2016 SUSE LLC
#
# 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.
#
# ------------------------------------------------------------------------------
require "yast"
require "y2packager/product"
Yast.import "Packages"
Yast.import "PackageCallbacks"
Yast.import "Popup"
module Y2Packager
module Clients
# Client to initialize software repositories
#
# It is intended to be used before the inst_complex_welcome client.
# If more than one product is available in the installation media, unselects
# all of them (the user should set a product later).
#
# @see adjust_base_product_selection
class InstRepositoriesInitialization
include Yast::Logger
include Yast::I18n
# Client main method
def main
textdomain "packager"
if !init_installation_repositories
Yast::Popup.Error(
_("Failed to initialize the software repositories.\nAborting the installation.")
)
return :abort
end
if products.empty?
Yast::Popup.Error(
_("Unable to find base products to install.\nAborting the installation.")
)
return :abort
end
adjust_base_product_selection
:next
end
private
# Initialize installation repositories
def init_installation_repositories
Yast::PackageCallbacks.RegisterEmptyProgressCallbacks
Yast::Packages.InitializeCatalogs
return false if Yast::Packages.InitFailed
Yast::Packages.InitializeAddOnProducts
# bnc#886608: Adjusting product name (for &product; macro) right after we
# initialize libzypp and get the base product name (intentionally not translated)
# FIXME: UI.SetProductName(Product.name || "SUSE Linux")
Yast::PackageCallbacks.RestorePreviousProgressCallbacks
true
end
# Adjust product selection
#
# During installation, all products are selected by default. So if there
# is more than 1, we should unselect them all. The user will select one
# later.
#
# On the other hand, if only one product is available, we should make
# sure that it is selected for installation because, during upgrade, it
# is not automatically selected.
#
# @see https://github.com/yast/yast-packager/blob/7e1a0bbb90823b03c15d92f408036a560dca8aa3/src/modules/Packages.rb#L1876
# @see https://github.com/yast/yast-packager/blob/fbc396df910e297915f9f785fc460e72e30d1948/src/modules/Packages.rb#L1905
def adjust_base_product_selection
if products.size == 1
products.first.select
else
products.each(&:restore)
end
end
# Return base available products
#
# @return [Array<Y2Product>] Available base products
def products
@products ||= Y2Packager::Product.available_base_products
end
end
end
end