Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,7 @@ def table(rows) | |
:hostaddress, | ||
:network, | ||
:domain, | ||
:efi, | ||
:arch, | ||
:karch, | ||
:product, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Yast.import "Linuxrc" | ||
Yast.import "Stage" | ||
|
||
module Y2Autoinstallation | ||
# This class is responsible of detecting if the system was booted using EFI or not | ||
class EFIDetector | ||
EFI_VARS_DIRS = ["/sys/firmware/efi/efivars", "/sys/firmware/efi/vars/"].freeze | ||
|
||
# Returns whether the system was booted using UEFI or not | ||
# | ||
# During the First Stage of the installation it relies on linuxrc for detecting the boot | ||
# but in the rest of cases it checks if any of the EFI vars directories exist | ||
# | ||
# @return [Boolean] whether the system was booted using UEFI or not | ||
def self.boot_efi? | ||
if Yast::Stage.initial | ||
Yast::Linuxrc.InstallInf("EFI") == "1" | ||
else | ||
EFI_VARS_DIRS.any? { |d| Dir.exist?(d) } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require_relative "../test_helper" | ||
require "autoinstall/efi_detector" | ||
|
||
describe Y2Autoinstallation::EFIDetector do | ||
describe ".boot_efi?" do | ||
let(:efi) { true } | ||
|
||
context "when called in the initial Stage" do | ||
before do | ||
allow(Yast::Linuxrc).to receive(:InstallInf).with("EFI").and_return(efi) | ||
end | ||
|
||
context "and EFI is read as '1' from the Install.inf file" do | ||
it "returns true" do | ||
expect(described_class.boot_efi?) | ||
end | ||
end | ||
|
||
context "and EFI is not read as '1' from the Install.inf file" do | ||
let(:efi) { false } | ||
|
||
it "returns false" do | ||
expect(described_class.boot_efi?) | ||
end | ||
end | ||
end | ||
|
||
context "when called in normal Mode" do | ||
before do | ||
allow(Dir).to receive(:exist?) | ||
end | ||
|
||
described_class.const_get("EFI_VARS_DIRS").each do |dir| | ||
it "returns true if '#{dir}' exists" do | ||
expect(Dir).to receive(:exist?).with(dir).and_return(true) | ||
expect(described_class.boot_efi?).to eq(true) | ||
end | ||
end | ||
|
||
it "returns false otherwise" do | ||
described_class.const_get("EFI_VARS_DIRS").each do |dir| | ||
allow(Dir).to receive(:exist?).with(dir).and_return(false) | ||
end | ||
|
||
expect(described_class.boot_efi?).to eq(false) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters