Skip to content

Commit

Permalink
Warns the user when a PReP/CHRP partition is needed and /boot is yet …
Browse files Browse the repository at this point in the history
…mounted
  • Loading branch information
imobachgs committed Sep 11, 2015
1 parent b4674bc commit f232c2e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/include/partitioning/custom_part_check_generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def check_created_partition_table(targetMap, installation)
partition_mounted_but_not_formated = false
swap_found = false
boot_found = false
boot_mount_point = ""
root_found = false
gpt_boot_ia64 = false
boot_end = 0
Expand Down Expand Up @@ -158,6 +159,7 @@ def check_created_partition_table(targetMap, installation)
gpt_boot_ia64 = true
end
boot_found = true
boot_mount_point = mountpoint
if Ops.get_symbol(diskinfo, "type", :CT_UNKNOWN) == :CT_DISK
boot_end = Region.End(Ops.get_list(part, "region", []))
else
Expand All @@ -174,18 +176,21 @@ def check_created_partition_table(targetMap, installation)
if Partitions.PrepBoot &&
(fsid == Partitions.FsidBoot(dlabel) || fsid == 6)
boot_found = true
boot_mount_point = mountpoint
boot_end = Region.End(Ops.get_list(part, "region", []))
boot_fs = Ops.get_symbol(part, "used_fs", :unknown)
boot_size_k = Ops.get_integer(part, "size_k", 0)
boot_fsid = Partitions.FsidBoot(dlabel)
elsif Arch.board_mac &&
Ops.get_symbol(part, "used_fs", :unknown) == :hfs
boot_found = true
boot_mount_point = mountpoint
boot_end = Region.End(Ops.get_list(part, "region", []))
boot_fs = Ops.get_symbol(part, "used_fs", :unknown)
boot_size_k = Ops.get_integer(part, "size_k", 0)
elsif !Partitions.EfiBoot() && fsid == Partitions.fsid_bios_grub
boot_found = true
boot_mount_point = mountpoint
boot_end = Region.End(Ops.get_list(part, "region", []))
boot_fs = :none
boot_size_k = Ops.get_integer(part, "size_k", 0)
Expand Down Expand Up @@ -294,6 +299,20 @@ def check_created_partition_table(targetMap, installation)
ok = false if !Popup.YesNo(message)
end

# A PReP/CHRP partition is not supposed to be mounted. So if we find any
# other /boot partition, we should warn the user.
if boot_found && Partitions.PrepBoot && !boot_mount_point.empty? && !Arch.board_iseries && installation || show_all_popups
message = _(
"Warning:\n" \
"Your system needs a boot partition with type 0x41 PReP/CHRP.\n" \
"Please, consider creating one.\n" \
"\n" \
"Really use this setup?\n"
)

ok = false if !Popup.YesNo(message)
end

if boot_found && boot_fsid!=Partitions.fsid_bios_grub && installation || show_all_popups
if Ops.greater_or_equal(boot_end, Partitions.BootCyl) || show_all_popups
# popup text, %1 is a number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,31 @@ def build_map(name)
end
end
end

context "and a /boot partition is present but it's not PReP/CHRP" do
let(:map) do
build_map("gpt-ppc-btrfs").tap do |m|
m["/dev/sda"]["partitions"][0].merge!("fsid" => 131, "fstype" => "Linux native")
end
end

it "warns the user and returns false" do
expect(Yast::Popup).to receive(:YesNo).with(/There is no partition mounted as \/boot/)
.and_return(false)
expect(client.check_created_partition_table(map, installation)).to eq(false)
end

context "and machine belongs to iSeries" do
before do
allow(Yast::Arch).to receive(:board_iseries).and_return(true)
end

it "returns true" do
expect(Yast::Popup).to_not receive(:YesNo)
expect(client.check_created_partition_table(map, installation)).to eq(true)
end
end
end
end

context "when /boot partition is not present" do
Expand Down Expand Up @@ -751,6 +776,30 @@ def build_map(name)
end
end
end

context "and a /boot partition is present but it's not PReP/CHRP" do
let(:map) do
build_map("gpt-ppc-btrfs").tap do |m|
m["/dev/sda"]["partitions"][0].merge!("fsid" => 131, "fstype" => "Linux native")
end
end

it "warns the user and returns false" do
expect(Yast::Popup).to_not receive(:YesNo)
expect(client.check_created_partition_table(map, installation)).to eq(true)
end

context "and machine belongs to iSeries" do
before do
allow(Yast::Arch).to receive(:board_iseries).and_return(true)
end

it "returns true" do
expect(Yast::Popup).to_not receive(:YesNo)
expect(client.check_created_partition_table(map, installation)).to eq(true)
end
end
end
end

context "when /boot partition is not present" do
Expand Down

0 comments on commit f232c2e

Please sign in to comment.