Skip to content

Commit

Permalink
Merge 38ee7a7 into 2910427
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Apr 10, 2019
2 parents 2910427 + 38ee7a7 commit c403613
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 21 deletions.
6 changes: 6 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Apr 9 09:56:17 CEST 2019 - schubi@suse.de

- Update proposal: Showing product obsoletes. (bsc#1131503)
4.1.37

-------------------------------------------------------------------
Wed Apr 3 10:38:03 CEST 2019 - schubi@suse.de

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


Name: yast2-packager
Version: 4.1.36
Version: 4.1.37
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand All @@ -35,8 +35,8 @@ BuildRequires: yast2-storage-ng >= 4.0.141
# break the yast2-packager -> yast2-storage-ng -> yast2-packager build cycle
#!BuildIgnore: yast2-packager

# Y2Packager::ProductLicense
BuildRequires: yast2 >= 4.0.63
# Y2Packager::will_be_obsoleted_by
BuildRequires: yast2 >= 4.0.68

# Pkg::PrdLicenseLocales
BuildRequires: yast2-pkg-bindings >= 4.0.8
Expand All @@ -50,8 +50,8 @@ Requires: yast2-country-data >= 2.16.3
# Pkg::PrdLicenseLocales
Requires: yast2-pkg-bindings >= 4.0.8

# Y2Packager::ProductLicense
Requires: yast2 >= 4.0.63
# Y2Packager::will_be_obsoleted_by
Requires: yast2 >= 4.0.68

# unzipping license file
Requires: unzip
Expand Down
37 changes: 26 additions & 11 deletions src/modules/Packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require "cgi"
require "shellwords"

require "y2packager/product_upgrade"

# Yast namespace
module Yast
# Package selections
Expand Down Expand Up @@ -731,19 +733,27 @@ def product_update_summary(products)
end

ret += status[:removed].map do |product|
transact_by = product["transact_by"]
log.warn "Product will be removed (by #{transact_by}): #{product}"
obsolete = Y2Packager::ProductUpgrade.will_be_obsoleted_by(product["name"])
if obsolete.empty?
transact_by = product["transact_by"]
log.warn "Product will be removed (by #{transact_by}): #{product}"

# Removing another product might be an issue
# (just warn if removed by user or by YaST)
msg = if [:user, :app_high].include?(transact_by)
_("<b>Warning:</b> Product <b>%s</b> will be removed.") % h(product_label(product))
else
_("<b>Error:</b> Product <b>%s</b> will be automatically removed.") %
h(product_label(product))
end

# Removing another product might be an issue
# (just warn if removed by user or by YaST)
msg = if [:user, :app_high].include?(transact_by)
_("<b>Warning:</b> Product <b>%s</b> will be removed.") % h(product_label(product))
re = HTML.Colorize(msg, "red")
else
_("<b>Error:</b> Product <b>%s</b> will be automatically removed.") %
h(product_label(product))
# TRANSLATORS: Product %{p} will be obsoleted by %{o} products
re = _("Product <b>%{p}</b> will be obsoleted by %{o}") %
{ p: h(product_label(product)), o: obsolete.join(", ") }
end

HTML.Colorize(msg, "red")
re
end

log.info "Product update summary: #{ret}"
Expand All @@ -758,7 +768,12 @@ def product_update_summary(products)
def product_update_warning(products)
status = group_products_by_status(products)

return {} if status[:removed].all? { |product| product["transact_by"] != :solver }
ret = status[:removed].all? do |product|
product["transact_by"] != :solver ||
!Y2Packager::ProductUpgrade.will_be_obsoleted_by(product["name"]).empty?
end

return {} if ret

# Automatic product removal MUST be confirmed by user, otherwise update
# cannot be started.
Expand Down
31 changes: 26 additions & 5 deletions test/packages_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,9 @@ def product(properties = {})

describe "#product_update_summary" do
let(:products) { load_zypp("products_update.yml") }
before do
allow(Y2Packager::ProductUpgrade).to receive(:will_be_obsoleted_by).and_return([])
end

it "describes the product update as a human readable summary" do
summary_string = Yast::Packages.product_update_summary(products).to_s
Expand Down Expand Up @@ -479,13 +482,31 @@ def product(properties = {})
describe "#product_update_warning" do
let(:products) { load_zypp("products_update.yml") }

it "returns a hash with warning when there is an automatically removed product" do
expect(Yast::Packages.product_update_warning(products)).to include("warning", "warning_level")
context "product will be removed due an obsolete" do
before do
allow(Y2Packager::ProductUpgrade).to receive(:will_be_obsoleted_by)
.and_return(["new_product"])
end

it "returns empty hash" do
expect(Yast::Packages.product_update_warning(products)).to eq({})
end
end

it "returns empty hash when there is no automatically removed product" do
products.each { |product| product["transact_by"] = :user }
expect(Yast::Packages.product_update_warning(products)).to eq({})
context "product will be removed" do
before do
allow(Y2Packager::ProductUpgrade).to receive(:will_be_obsoleted_by).and_return([])
end

it "returns a hash with warning when there is an automatically removed product" do
expect(Yast::Packages.product_update_warning(products)).to include("warning",
"warning_level")
end

it "returns empty hash when there is no automatically removed product" do
products.each { |product| product["transact_by"] = :user }
expect(Yast::Packages.product_update_warning(products)).to eq({})
end
end
end

Expand Down

0 comments on commit c403613

Please sign in to comment.