Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on /etc/install.inf being available [15-SP4] #613

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/yast2-packager.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Apr 27 13:31:36 UTC 2022 - Stefan Hundhammer <shundhammer@suse.com>

- Don't rely on install.inf availability #(bsc#1198560)
- 4.4.30

-------------------------------------------------------------------
Wed Apr 27 11:24:44 UTC 2022 - Ladislav Slezák <lslezak@suse.cz>

Expand Down
2 changes: 1 addition & 1 deletion 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.4.29
Version: 4.4.30
Release: 0
Summary: YaST2 - Package Library
License: GPL-2.0-or-later
Expand Down
10 changes: 9 additions & 1 deletion src/lib/y2packager/product_spec_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Y2Packager
class ProductSpecReader
include Yast::Logger
Yast.import "Mode"
Yast.import "Linuxrc"

# Returns the list of product specifications.
#
Expand All @@ -35,7 +36,7 @@ def products
# products_from_control || products_from_offline || products_from_libzypp

# online migration (in installed system)
return products_from_libzypp if Yast::Mode.normal
return products_from_libzypp if Yast::Mode.normal || !install_inf?

if InstallationMedium.contain_multi_repos?
products_from_multi_repos
Expand Down Expand Up @@ -70,5 +71,12 @@ def products_from_libzypp
log.info "Products from libzypp: #{libzypp_products.map(&:name).join(", ")}"
libzypp_products
end

# Is information from an install.inf file available?
#
# @return [Boolean]
def install_inf?
!Yast::Linuxrc.keys.empty?
end
end
end
15 changes: 15 additions & 0 deletions test/lib/product_spec_reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
let(:full_products) { [instance_double(Y2Packager::ProductSpec, name: "SLES")] }
let(:control_products) { [instance_double(Y2Packager::ProductSpec, name: "SLED")] }
let(:libzypp_products) { [instance_double(Y2Packager::ProductSpec, name: "SLE-HA")] }
let(:linuxrc_fake) { { foo: "bar" } }
let(:linuxrc_empty) { {} }
let(:linuxrc_keys) { linuxrc_fake }

describe "#products" do
before do
Expand All @@ -47,6 +50,7 @@
allow(Y2Packager::InstallationMedium).to receive(:contain_repo?).and_return(false)
allow(Y2Packager::InstallationMedium).to receive(:contain_multi_repos?).and_return(false)
allow(Yast::Mode).to receive(:normal).and_return(false)
allow(Yast::Linuxrc).to receive(:keys).and_return(linuxrc_keys)
end

context "when medium does not contain any repository" do
Expand Down Expand Up @@ -85,5 +89,16 @@
expect(reader.products).to eq(libzypp_products)
end
end

context "without /etc/install.inf" do
let(:linuxrc_keys) { linuxrc_empty }
before do
allow(Yast::Mode).to receive(:normal).and_return(false)
end

it "returns the libzypp products" do
expect(reader.products).to eq(libzypp_products)
end
end
end
end