Skip to content

Commit

Permalink
Merge pull request #649 from shundhammer/huha-os-prober
Browse files Browse the repository at this point in the history
Add os-prober package (SLE-15-SP3)
  • Loading branch information
shundhammer committed Jul 6, 2021
2 parents 4ab7c9d + 6b6544f commit e21a169
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 3 deletions.
8 changes: 8 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Jul 5 14:49:59 UTC 2021 - Stefan Hundhammer <shundhammer@suse.com>

- Add the os-prober package to the set of packages to install
if the package is available and supported on the arch
(bsc#1186369)
- 4.3.30

-------------------------------------------------------------------
Wed Jun 9 13:51:01 UTC 2021 - Guillaume GARDET <guillaume.gardet@opensuse.org>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.3.29
Version: 4.3.30
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
13 changes: 12 additions & 1 deletion src/lib/bootloader/grub2_widgets.rb
Expand Up @@ -7,6 +7,7 @@
require "bootloader/serial_console"
require "bootloader/cpu_mitigations"
require "bootloader/systeminfo"
require "bootloader/os_prober"
require "cfa/matcher"

Yast.import "BootStorage"
Expand Down Expand Up @@ -1103,7 +1104,7 @@ def contents
TimeoutWidget.new(hiden_menu_widget),
HSpacing(1),
VBox(
Left(Yast::Arch.s390 ? CWM::Empty.new("os_prober") : OSProberWidget.new),
os_prober_widget,
VSpacing(1),
Left(hiden_menu_widget)
),
Expand All @@ -1115,5 +1116,15 @@ def contents
VStretch()
)
end

private

def os_prober_widget
if OsProber.available? # Checks !Arch.s390 and if package is available
Left(OSProberWidget.new)
else
CWM::Empty.new("os_prober")
end
end
end
end
18 changes: 18 additions & 0 deletions src/lib/bootloader/grub2base.rb
Expand Up @@ -10,6 +10,7 @@
require "bootloader/udev_mapping"
require "bootloader/serial_console"
require "bootloader/language"
require "bootloader/os_prober"
require "cfa/grub2/default"
require "cfa/grub2/grub_cfg"
require "cfa/matcher"
Expand Down Expand Up @@ -184,6 +185,23 @@ def merge(other)
self.update_nvram = other.update_nvram unless other.update_nvram.nil?
end

def packages
res = super
res << OsProber.package_name if include_os_prober_package?
res
end

# Checks if the os-prober package should be included.
#
# This default implementation checks if os-prober is supported on the
# current architecture (all except s/390) and if the package is available
# (not all products include it).
#
# @return [Boolean] true if the os-prober package should be included; false otherwise.
def include_os_prober_package?
OsProber.available?
end

def enable_serial_console(console_arg_string)
@console = SerialConsole.load_from_console_args(console_arg_string)
raise ::Bootloader::InvalidSerialConsoleArguments unless @console
Expand Down
33 changes: 33 additions & 0 deletions src/lib/bootloader/os_prober.rb
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require "yast"

Yast.import "Package"
Yast.import "Arch"

module Bootloader
# Helper methods for the os-prober package
class OsProber
class << self
def package_name
"os-prober"
end

# Check if os-prober is supported on this architecture and if the package
# is available
def available?
arch_supported? && package_available?
end

# Check if the os-prober package is available for installation
def package_available?
Yast::Package.Available(package_name)
end

# Check if os-prober is supported on this architecture
def arch_supported?
!Yast::Arch.s390
end
end
end
end
1 change: 1 addition & 0 deletions test/bootloader/auto_client_test.rb
Expand Up @@ -29,6 +29,7 @@

before do
allow(Yast::Bootloader).to receive(:Import).and_return(imported)
allow(Yast::Package).to receive(:Available).and_return(true)
end

it "imports the configuration" do
Expand Down
1 change: 1 addition & 0 deletions test/bootloader_proposal_client_test.rb
Expand Up @@ -15,6 +15,7 @@
Bootloader::BootloaderFactory.clear_cache

allow(Yast::Bootloader).to receive(:Reset)
allow(Yast::Package).to receive(:Available).and_return(true)
end

describe "#description" do
Expand Down
1 change: 1 addition & 0 deletions test/bootloader_test.rb
Expand Up @@ -29,6 +29,7 @@ def kernel_line(target)
before do
allow(Yast::PackageSystem).to receive(:InstallAll).and_return(false)
allow(Yast2::Popup).to receive(:show)
allow(Yast::Package).to receive(:Available).and_return(true)
end

it "shows an information message" do
Expand Down
1 change: 1 addition & 0 deletions test/grub2_efi_test.rb
Expand Up @@ -18,6 +18,7 @@
allow(Yast::BootStorage).to receive(:available_swap_partitions).and_return([])
allow(Bootloader::GrubInstall).to receive(:new).and_return(double.as_null_object)
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
allow(Yast::Package).to receive(:Available).and_return(true)
end

describe "#read" do
Expand Down
31 changes: 30 additions & 1 deletion test/grub2_test.rb
Expand Up @@ -151,6 +151,7 @@
before do
allow(Yast::Stage).to receive(:initial).and_return(initial_stage)
allow(Bootloader::Stage1).to receive(:new).and_return(stage1)
allow(Yast::Package).to receive(:Available).and_return(true)
end

it "contains grub2 package" do
Expand Down Expand Up @@ -214,11 +215,39 @@
allow(subject).to receive(:trusted_boot).and_return(false)
end

it "does not contain the trusged grub packages" do
it "does not contain the trusted grub packages" do
expect(subject.packages).to_not include("trustedgrub2")
expect(subject.packages).to_not include("trustedgrub2-i386-pc")
end
end

context "on non-s390 architectures" do
before do
allow(Yast::Arch).to receive(:s390).and_return(false)
end

context "if the os-prober package is available" do
it "contains the os-prober package" do
expect(subject.packages).to include("os-prober")
end
end

context "if the os-prober package is not available" do
it "does not contain the os-prober package" do
expect(subject.packages).to include("os-prober")
end
end
end

context "on the s390 architecture" do
before do
allow(Yast::Arch).to receive(:s390_64).and_return(true)
end

it "does not contain the os-prober package" do
expect(subject.packages).to_not include("os-prober")
end
end
end

describe "#summary" do
Expand Down
1 change: 1 addition & 0 deletions test/grub2_widgets_test.rb
Expand Up @@ -818,6 +818,7 @@ def stub_widget_value(id, value)

describe Bootloader::BootloaderTab do
before do
allow(Yast::Package).to receive(:Available).and_return(true)
assign_bootloader
end

Expand Down
63 changes: 63 additions & 0 deletions test/os_prober_test.rb
@@ -0,0 +1,63 @@
# frozen_string_literal: true

require_relative "test_helper"

describe Bootloader::OsProber do
subject = described_class

describe "#package_name" do
it "Returns the correct package name" do
expect(subject.package_name).to eq "os-prober"
end
end

describe "#arch_supported?" do
context "on non-s390 architectures" do
before do
allow(Yast::Arch).to receive(:s390).and_return(false)
end

it "os-prober is supported" do
expect(subject.arch_supported?).to eq true
end
end

context "on the s390 architecture" do
before do
allow(Yast::Arch).to receive(:s390).and_return(true)
end

it "os-prober is not supported" do
expect(subject.arch_supported?).to eq false
end
end
end

describe "#available?" do
context "on non-s390 architectures" do
before do
allow(Yast::Arch).to receive(:s390).and_return(false)
end

context "if the os-prober package is available" do
before do
allow(Yast::Package).to receive(:Available).and_return(true)
end

it "os-prober is available" do
expect(subject.available?).to eq true
end
end

context "if the os-prober package is not available" do
before do
allow(Yast::Package).to receive(:Available).and_return(false)
end

it "os-prober is not available" do
expect(subject.available?).to eq false
end
end
end
end
end

0 comments on commit e21a169

Please sign in to comment.