Skip to content

Commit

Permalink
Fixed a crash when when adding an addon (bsc#1074766)
Browse files Browse the repository at this point in the history
- 4.0.5
  • Loading branch information
lslezak committed Jan 8, 2018
1 parent aa2449a commit e627889
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
6 changes: 6 additions & 0 deletions package/yast2-add-on.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jan 8 10:57:47 UTC 2018 - lslezak@suse.cz

- Fixed a crash when when adding an addon (bsc#1074766)
- 4.0.5

-------------------------------------------------------------------
Wed Dec 20 16:08:43 CET 2017 - schubi@suse.de

Expand Down
6 changes: 3 additions & 3 deletions package/yast2-add-on.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-add-on
Version: 4.0.4
Version: 4.0.5
Release: 0
Summary: YaST2 - Add-On media installation code
License: GPL-2.0
Expand All @@ -35,8 +35,8 @@ Requires: autoyast2-installation
Requires: yast2 >= 3.0.1
Requires: yast2-country
Requires: yast2-installation
# SourceDialogs.display_addon_checkbox
Requires: yast2-packager >= 3.1.14
# new AddOnProduct.DoInstall argument
Requires: yast2-packager >= 4.0.25
Requires: yast2-ruby-bindings >= 1.0.0

Obsoletes: yast2-add-on-devel-doc
Expand Down
26 changes: 25 additions & 1 deletion src/include/add-on/add-on-workflow.rb
Expand Up @@ -1751,7 +1751,31 @@ def RemoveProductWithDependencies

def RunAddProductWorkflow
WFM.CallFunction("inst_addon_update_sources", [])
AddOnProduct.DoInstall

# partition the addons into two groups:
# - plain addons (no installation.xml)
# - addons with installation.xml
# handle each group separately
plain_addons, workflow_addons = @added_repos.partition do |repo|
WorkflowManager.GetCachedWorkflowFilename(:addon, repo, "").nil?
end

plain_addons.each do |repo|
AddOnProduct.src_id = repo
# just handle each repository separately, select the packages but do not
# install them yet
AddOnProduct.DoInstall(false)
end

# install all packages at once
AddOnProduct.DoInstall_NoControlFile unless plain_addons.empty?

workflow_addons.each do |repo|
AddOnProduct.src_id = repo
# run the installation.xml
AddOnProduct.DoInstall
end

# Write only when there are some changes
Write()

Expand Down
23 changes: 23 additions & 0 deletions test/repositories_include_test.rb
Expand Up @@ -105,4 +105,27 @@ def main
end
end
end

describe "#RunAddProductWorkflow" do
before do
allow(Yast::WFM).to receive(:CallFunction).with("inst_addon_update_sources", [])
allow(Yast::Pkg).to receive(:SourceReleaseAll)
allow(AddonIncludeTester).to receive(:Write)
AddonIncludeTester.instance_variable_set("@added_repos", [1, 2])
end

it "installs the selected products at once" do
expect(Yast::WorkflowManager).to receive(:GetCachedWorkflowFilename).and_return(nil).twice
expect(Yast::AddOnProduct).to receive(:DoInstall).with(false).twice
expect(Yast::AddOnProduct).to receive(:DoInstall_NoControlFile)
AddonIncludeTester.RunAddProductWorkflow
end

it "handles addons with installation.xml" do
expect(Yast::WorkflowManager).to receive(:GetCachedWorkflowFilename).and_return("foo").twice
expect(Yast::AddOnProduct).to receive(:DoInstall).twice
expect(Yast::AddOnProduct).to_not receive(:DoInstall_NoControlFile)
AddonIncludeTester.RunAddProductWorkflow
end
end
end

0 comments on commit e627889

Please sign in to comment.