Skip to content

Commit

Permalink
Merge pull request #64 from yast/sle-12-sp2-update-proposal
Browse files Browse the repository at this point in the history
Install additional packages during upgrade
  • Loading branch information
imobachgs committed Jan 30, 2017
2 parents 207f25d + 7f29df9 commit aa2a128
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ before_install:
# disable rvm, use system Ruby
- rvm reset
- wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-packager yast2-installation-control" -g "rspec:3.3.0 yast-rake gettext"
- sh ./travis_setup.sh -p "rake yast2-devtools yast2-testsuite yast2 yast2-packager yast2-installation-control yast2-country" -g "rspec:3.3.0 yast-rake gettext"
script:
- rake check:syntax
- rake check:pot
Expand Down
6 changes: 6 additions & 0 deletions package/yast2-update.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Jan 30 12:07:55 UTC 2017 - igonzalezsosa@suse.com

- Allow YaST modules to add packages during upgrade (bsc#1009834)
- 3.1.44

-------------------------------------------------------------------
Thu Sep 29 08:02:43 UTC 2016 - igonzalezsosa@suse.com

Expand Down
9 changes: 5 additions & 4 deletions package/yast2-update.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-update
Version: 3.1.43
Version: 3.1.44
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand All @@ -29,7 +29,8 @@ BuildRequires: update-desktop-files
BuildRequires: yast2-devtools >= 3.1.15
BuildRequires: yast2-ruby-bindings >= 1.0.0
BuildRequires: yast2 >= 3.1.126
BuildRequires: yast2-packager
# Packages#proposal_for_update
BuildRequires: yast2-packager >= 3.1.120

# xmllint
BuildRequires: libxml2-tools
Expand All @@ -46,8 +47,8 @@ Requires: yast2-storage >= 2.22.9
Requires: yast2 >= 3.1.126
Requires: yast2-installation

# packager/product_patterns.rb
Requires: yast2-packager >= 3.1.95
# Packages#proposal_for_update
Requires: yast2-packager >= 3.1.120

# Pkg.TargetInitializeOptions()
Requires: yast2-pkg-bindings >= 3.1.14
Expand Down
24 changes: 19 additions & 5 deletions src/clients/packages_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def main
Yast.import "Packages"
Yast.import "SpaceCalculation"
Yast.import "PackagesUI"
Yast.import "Packages"

Yast.import "Update"

Expand All @@ -62,6 +63,9 @@ def main
# SpaceCalculation::ShowPartitionWarning ();
@warning = SpaceCalculation.GetPartitionWarning

# Make an update proposal
Packages.proposal_for_update

# Count statistics -->
# Pkg::GetPackages()
# `installed all installed packages
Expand Down Expand Up @@ -145,26 +149,36 @@ def main
)
)

@ret = {
"trigger" => {
"expect" => {
"class" => "Yast::Packages",
"method" => "PackagesProposalChanged"
},
"value" => false
}
}

if Ops.greater_than(Update.solve_errors, 0)
# the proposal for the packages requires manual invervention
@ret = {
@ret.merge!({
"preformatted_proposal" => HTML.List(@tmp),
"links" => [PACKAGER_LINK],
# TRANSLATORS: warning text, keep the HTML tags (<a href...>) untouched
"warning" => _(
"Cannot solve all conflicts. <a href=\"%s\">Manual intervention is required.</a>"
) % PACKAGER_LINK,
"warning_level" => :blocker
}
})
elsif Ops.greater_than(Builtins.size(@warning), 0)
# the proposal for the packages requires manual intervention
@ret = {
@ret.merge!({
"preformatted_proposal" => HTML.List(@tmp),
"warning" => Builtins.mergestring(@warning, "<br>"),
"warning_level" => :warning
}
})
else
@ret = { "preformatted_proposal" => HTML.List(@tmp) }
@ret.merge!({ "preformatted_proposal" => HTML.List(@tmp) })
end

Builtins.y2milestone(
Expand Down
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ TESTS = \
root_part_test.rb \
suse_release_test.rb \
inst_update_partition_auto_test.rb \
packages_proposal_test.rb \
update_test.rb

TEST_EXTENSIONS = .rb
Expand Down
57 changes: 57 additions & 0 deletions test/packages_proposal_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env rspec

require_relative "test_helper"
require_relative "../src/clients/packages_proposal"

describe Yast::PackagesProposalClient do
subject(:client) { described_class.new }

before do
allow(Yast::WFM).to receive(:Args) do |n|
n.nil? ? args : args[n]
end
end

describe "#main" do
context "when action is MakeProposal" do
let(:args) { ["MakeProposal"] }

PACKAGES = {
installed: ["grub", "elilo"],
selected: ["grub", "grub2-efi", "grub2-pc"],
removed: ["elilo"]
}

before do
allow(Yast::SpaceCalculation).to receive(:GetPartitionWarning)
.and_return(nil)
allow(Yast::Packages).to receive(:proposal_for_update)
allow(Yast::Pkg).to receive(:GetPackages).with(anything, true) do |status, _names_only|
PACKAGES[status]
end
end

it "asks for a packages selection proposal" do
expect(Yast::Packages).to receive(:proposal_for_update)
client.main
end

it "summarizes packages to update/install/remove" do
expect(Yast::Update).to receive(:packages_to_update=)
.with(1)
expect(Yast::Update).to receive(:packages_to_install=)
.with(2)
expect(Yast::Update).to receive(:packages_to_remove=)
.with(1)
client.main
end

it "is meant to be triggered if packages proposal changes" do
expect(client.main["trigger"]).to eq({
"expect" => { "class" => "Yast::Packages", "method" => "PackagesProposalChanged" },
"value" => false
})
end
end
end
end

0 comments on commit aa2a128

Please sign in to comment.