Skip to content

Commit

Permalink
Merge c9cbf63 into c09523e
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Sep 16, 2020
2 parents c09523e + c9cbf63 commit a1f925c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/include/add-on/add-on-workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module Yast
module AddOnAddOnWorkflowInclude
include Yast::Logger

# remember that the Full medium add-ons have been selected by user
@@media_addons_selected = false

def initialize_add_on_add_on_workflow(include_target)
Yast.import "UI"
Yast.import "Pkg"
Expand Down Expand Up @@ -910,7 +913,7 @@ def RunAddOnMainDialog(enable_back, enable_next, enable_abort, back_button, next
ret = nil

not_enough_memory = Stage.initial && HasInsufficientMemory()
no_addons = Builtins.size(AddOnProduct.add_on_products) == 0
no_addons = AddOnProduct.add_on_products.empty?

# bugzilla #239630
# It might be dangerous to add more installation sources in installation
Expand All @@ -929,7 +932,7 @@ def RunAddOnMainDialog(enable_back, enable_next, enable_abort, back_button, next
# FATE #301928 - Saving one click
# Bugzilla #893103 be consistent, so always when there is no add-on skip
# Bugzilla #1102705 Do not redraw when skipping
if no_addons
if no_addons || (offline_medium? && !media_addons_selected?)
Builtins.y2milestone("Skipping to media_select")
ret = :skip_to_add
else
Expand Down Expand Up @@ -1051,6 +1054,9 @@ def RunAddOnMainDialog(enable_back, enable_next, enable_abort, back_button, next
# Release all sources after adding a new one
# because of CD/DVD + url cd://
Pkg.SourceReleaseAll

# do not ask again for Full medium addons
media_addons_selected if offline_medium?
elsif ret2 == :cancel
log.info("Aborted, removing add-on repositories: #{@added_repos.inspect}")

Expand Down Expand Up @@ -1909,7 +1915,8 @@ def media_type_selection
# @return [Boolean] `true` if the addons should be offered automatically
#
def offer_media_addons?
if !AddOnProduct.add_on_products.empty? || !Stage.initial || !Y2Packager::MediumType.offline?
# media addons already selected or not Full medium
if media_addons_selected? || !offline_medium?
return false
end

Expand Down Expand Up @@ -1941,5 +1948,24 @@ def product_label(product)
# fallback to the internal product name
selected_product&.display_name || product
end

# return product addons (i.e. filter out the Driver Update add-ons)
# @return [Array<Hash>] the addons without the driver update add-ons
def product_addons
# the product name contains the DUD number, e.g. it is "Driver Update 0" for the first DUD
AddOnProduct.add_on_products.reject{|a| a["product"].start_with?("Driver Update")}
end

def media_addons_selected?
@@media_addons_selected
end

def media_addons_selected(value = true)
@@media_addons_selected = value
end

def offline_medium?
Stage.initial && Y2Packager::MediumType.offline?
end
end
end
42 changes: 42 additions & 0 deletions test/repositories_include_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,46 @@ def main
AddonIncludeTester.RunAddProductWorkflow
end
end

describe "#RunAddOnMainDialog" do
before do
allow(Yast::Pkg).to receive(:SourceReleaseAll)
allow(Yast::Stage).to receive(:initial).and_return(true)
allow(AddonIncludeTester).to receive(:HasInsufficientMemory).and_return(false)
allow(Yast::WorkflowManager).to receive(:SetBaseWorkflow)
allow(Yast::Wizard).to receive(:SetTitleIcon)
allow(AddonIncludeTester).to receive(:Redraw)
allow(Yast::AddOnProduct).to receive(:PrepareForRegistration)
allow(Yast::AddOnProduct).to receive(:Integrate)
allow(Yast::AddOnProduct).to receive(:ProcessRegistration)
allow(Yast::AddOnProduct).to receive(:ReIntegrateFromScratch)
allow(Yast::Wizard).to receive(:RestoreBackButton)
allow(Yast::Wizard).to receive(:RestoreAbortButton)
allow(Yast::Wizard).to receive(:RestoreNextButton)
allow(Yast::UI).to receive(:UserInput).and_return(:next)
end

context "a DUD add-on present, using Full medium" do
before do
allow(Yast::AddOnProduct).to receive(:add_on_products).and_return([
{
"media" => 4,
"product" => "Driver Update 0",
"autoyast_product" => "Driver Update 0",
"media_url" => "dir:///update/000/repo?alias=DriverUpdate0",
"product_dir" => "",
"priority" => 50
}
])
allow(Y2Packager::MediumType).to receive(:offline?).and_return(true)
end

it "asks for the media addons and stores the state" do
expect(AddonIncludeTester).to receive(:RunWizard).and_return(:next)
expect { AddonIncludeTester.RunAddOnMainDialog(true, true, true, "", "", "", true) }.to \
change { Yast::AddOnAddOnWorkflowInclude.class_variable_get(:@@media_addons_selected) } \
.from(false).to(true)
end
end
end
end

0 comments on commit a1f925c

Please sign in to comment.