diff --git a/package/autoyast2.changes b/package/autoyast2.changes index 4239b70a5..97de908ba 100644 --- a/package/autoyast2.changes +++ b/package/autoyast2.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Wed Sep 14 17:19:01 CEST 2016 - schubi@suse.de + +- Adding an missing PREP partition for PPC, BUT not for + Power8 system (powerNV). PowerNV do not have PREP partitions + and do not need any because they do not call grub2-install + (bnc#989392). +- 3.1.151 + ------------------------------------------------------------------- Wed Sep 7 07:27:53 UTC 2016 - igonzalezsosa@suse.com diff --git a/package/autoyast2.spec b/package/autoyast2.spec index 93f3fe572..209057e91 100644 --- a/package/autoyast2.spec +++ b/package/autoyast2.spec @@ -17,7 +17,7 @@ Name: autoyast2 -Version: 3.1.150 +Version: 3.1.151 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff --git a/src/include/autoinstall/autopart.rb b/src/include/autoinstall/autopart.rb index f08337aa2..b8aba9355 100644 --- a/src/include/autoinstall/autopart.rb +++ b/src/include/autoinstall/autopart.rb @@ -270,7 +270,12 @@ def preprocess_partition_config(xmlflex) end def try_add_boot(conf, disk) - conf = deep_copy(conf) + tc = Builtins.eval(conf) + # If it is a ppc but not a baremetal Power8 system (powerNV). + # powerNV do not have prep partition and do not need any because + # they do not call grub2-install (bnc#989392). + return tc if Arch.ppc && Arch.board_powernv + disk = deep_copy(disk) dlabel = disk.fetch("label", "") root = Ops.greater_than( @@ -279,16 +284,13 @@ def try_add_boot(conf, disk) end), 0 ) - tc = Builtins.eval(conf) + if !@planHasBoot && root && - (Ops.greater_than( - Ops.get_integer(disk, "cyl_count", 0), - Partitions.BootCyl - ) || - Arch.ia64 || - Arch.ppc || - Arch.sparc) + (Ops.greater_than( + Ops.get_integer(disk, "cyl_count", 0), + Partitions.BootCyl) || Arch.ppc) pb = {} + # PPCs do not need /boot but prep partition only. if !Arch.ppc Ops.set(pb, "mount", Partitions.BootMount) Ops.set(pb, "fsys", Partitions.DefaultBootFs) diff --git a/test/fixtures/profiles/ppc_partitions.xml b/test/fixtures/profiles/ppc_partitions.xml new file mode 100644 index 000000000..d76702e62 --- /dev/null +++ b/test/fixtures/profiles/ppc_partitions.xml @@ -0,0 +1,316 @@ + + + + + + /dev/rhel + msdos + true + true + + + true + false + ext4 + true + false + home + device + 1 + false + 224730808320 + + + true + false + xfs + true + false + root + device + 1 + false + 53687091200 + + + true + false + swap + true + defaults + false + swap + swap + device + 130 + 1 + false + 4294967296 + + + 4M + CT_LVM + all + + + /dev/rhel_ltc-tuleta12 + msdos + true + true + + + true + false + ext4 + true + false + home + device + 1 + false + 81017176064 + + + true + false + xfs + true + false + root + device + 1 + false + 53687091200 + + + true + false + swap + true + defaults + false + swap + swap + device + 130 + 1 + false + 4294967296 + + + 4M + CT_LVM + all + + + /dev/sda + msdos + true + true + + + true + false + false + false + device + 65 + 1 + false + 8225280 + + + true + false + xfs + true + false + device + 131 + 2 + false + 516062720 + + + true + false + false + false + rhel_ltc-tuleta12 + device + 142 + 3 + false + 139057069568 + + + + CT_DISK + all + + + /dev/sdb + gpt + true + true + + + true + false + false + false + device + 264 + 1 + false + 8225280 + + + true + false + ext4 + true + false + device + 264 + 2 + false + 8225280 + + + true + false + swap + true + defaults + false + swap + uuid + 130 + 3 + false + 5687639552 + + + true + false + ext4 + true + false + device + 131 + 4 + false + 133872909824 + + + + CT_DISK + all + + + /dev/sdc + gpt + true + true + + + true + false + btrfs + true + defaults + false + / + uuid + 131 + 1 + false + 42943544832 + + opt + srv + tmp + usr/local + var/cache + var/crash + var/lib/libvirt/images + var/lib/machines + var/lib/mailman + var/lib/mariadb + var/lib/mysql + var/lib/named + var/lib/pgsql + var/log + var/opt + var/spool + var/tmp + + + + true + false + xfs + true + defaults + false + /home + uuid + 131 + 2 + false + 240832904704 + + + + CT_DISK + all + + + /dev/sdd + msdos + true + true + + + true + false + false + false + device + 65 + 1 + false + 8225280 + + + true + false + xfs + true + false + device + 131 + 2 + false + 1065516544 + + + true + false + false + false + rhel + device + 142 + 3 + false + 282707787264 + + + + CT_DISK + all + + + diff --git a/test/fixtures/storage/target_ppc.yml b/test/fixtures/storage/target_ppc.yml new file mode 100644 index 000000000..10af0427d --- /dev/null +++ b/test/fixtures/storage/target_ppc.yml @@ -0,0 +1,117 @@ +--- +"/dev/btrfs": + device: "/dev/btrfs" + name: btrfs + partitions: [] + type: :CT_BTRFS + used_by_device: '' + used_by_type: :UB_NONE +"/dev/sda": + bus: SCSI + cyl_count: 16971 + cyl_size: 8225280 + dasd_format: 0 + dasd_type: 0 + device: "/dev/sda" + driver: ipr + driver_module: ipr + label: msdos + max_logical: 255 + max_primary: 4 + model: IPR-0 6AB10B00 + name: sda + partitions: [] + proposal_name: 1. SCSI Disk, 130.01 GiB, /dev/sda, IBM-IPR-0 6AB10B00 + sector_size: 512 + size_k: 136323072 + transport: :unknown + type: :CT_DISK + udev_id: + - scsi-1IBM_IPR-0_6AB10B0000000080 + udev_path: pci-0001=>04=>00.0-scsi-0=>2=>0=>0 + unique: R7kM.8Hl8kKEBU0D + used_by_device: '' + used_by_type: :UB_NONE + vendor: IBM +"/dev/sdb": + bus: SCSI + cyl_count: 16971 + cyl_size: 8225280 + dasd_format: 0 + dasd_type: 0 + device: "/dev/sdb" + driver: ipr + driver_module: ipr + label: gpt + max_logical: 0 + max_primary: 128 + model: IPR-0 6AB10B00 + name: sdb + partitions: [] + proposal_name: 2. SCSI Disk, 130.01 GiB, /dev/sdb, IBM-IPR-0 6AB10B00 + sector_size: 512 + size_k: 136323072 + transport: :unknown + type: :CT_DISK + udev_id: + - scsi-1IBM_IPR-0_6AB10B0000000060 + udev_path: pci-0001=>04=>00.0-scsi-0=>2=>1=>0 + unique: uI_Q.8Hl8kKEBU0D + used_by_device: '' + used_by_type: :UB_NONE + vendor: IBM +"/dev/sdc": + bus: SCSI + cyl_count: 34502 + cyl_size: 8225280 + dasd_format: 0 + dasd_type: 0 + device: "/dev/sdc" + driver: ipr + driver_module: ipr + label: gpt + max_logical: 0 + max_primary: 128 + model: IPR-0 6AB10B00 + name: sdc + partitions: [] + proposal_name: 3. SCSI Disk, 264.30 GiB, /dev/sdc, IBM-IPR-0 6AB10B00 + sector_size: 512 + size_k: 277143552 + transport: :unknown + type: :CT_DISK + udev_id: + - scsi-0IBM_IPR-0_6AB10B00_0 + - scsi-1IBM_IPR-0_6AB10B0000000040 + udev_path: pci-0001=>04=>00.0-scsi-0=>2=>2=>0 + unique: LUEV.8Hl8kKEBU0D + used_by_device: '' + used_by_type: :UB_NONE + vendor: IBM +"/dev/sdd": + bus: SCSI + cyl_count: 34502 + cyl_size: 8225280 + dasd_format: 0 + dasd_type: 0 + device: "/dev/sdd" + driver: ipr + driver_module: ipr + label: msdos + max_logical: 255 + max_primary: 4 + model: IPR-0 6AB10B00 + name: sdd + partitions: [] + proposal_name: 4. SCSI Disk, 264.30 GiB, /dev/sdd, IBM-IPR-0 6AB10B00 + sector_size: 512 + size_k: 277143552 + transport: :unknown + type: :CT_DISK + udev_id: + - scsi-1IBM_IPR-0_6AB10B0000000020 + udev_path: pci-0001=>04=>00.0-scsi-0=>2:3:0 + unique: ofUZ.8Hl8kKEBU0D + used_by_device: '' + used_by_type: :UB_NONE + vendor: IBM diff --git a/test/include/autopart_test.rb b/test/include/autopart_test.rb new file mode 100755 index 000000000..46569d144 --- /dev/null +++ b/test/include/autopart_test.rb @@ -0,0 +1,112 @@ +#!/usr/bin/env rspec + +require_relative "../test_helper" +require "yaml" +require "yast" + +Yast.import "Profile" +Yast.import "Arch" +Yast.import "Partitions" + +describe "Yast::AutoinstallAutopartInclude" do + FIXTURES_PATH = File.join(File.dirname(__FILE__), '../fixtures') + + module DummyYast + class AutoinstallAutopartClient < Yast::Client + def main + Yast.include self, "autoinstall/autopart.rb" + @planHasBoot=false + end + + def initialize + main + end + def plan_has_boot_or_prep_partition + @planHasBoot + end + def plan_has_boot_or_prep_partition=(v) + @planHasBoot = v + end + end + end + + subject(:client) { DummyYast::AutoinstallAutopartClient.new } + + describe "#autopart" do + + context "ppc partitioning" do + let(:target_map) { YAML.load_file(File.join(FIXTURES_PATH, 'storage', 'target_ppc.yml')) } + let(:ay_device) { Yast::Profile.current['partitioning'].find {|x| x["device"] == checked_device} } + before do + allow(Yast::Arch).to receive(:ppc).and_return(true) + allow(Yast::Partitions).to receive(:MinimalNeededBootsize).and_return(800000) + allow(Yast::Partitions).to receive(:DefaultBootFs).and_return(:ext4) + allow(Yast::Partitions).to receive(:FsidBoot).and_return(Yast::Partitions.fsid_gpt_prep) + Yast::Profile.ReadXML(File.join(FIXTURES_PATH, 'profiles', 'ppc_partitions.xml')) + end + + context "AY configuration file has no prep partition" do + before do + client.plan_has_boot_or_prep_partition=false + end + + context "checking device with root partition" do + let(:checked_device) { "/dev/sdc" } + + it "do not add an additional prep partition if it is a powernv system" do + # bnc#989392 + allow(Yast::Arch).to receive(:board_powernv).and_return(true) + ret = client.try_add_boot( ay_device, target_map[checked_device]) + expect(ret["partitions"].size).to eq(ay_device["partitions"].size) + end + + it "adds an additional prep partition if it is NOT a powernv system" do + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + ret = client.try_add_boot( ay_device, target_map[checked_device]) + expect(ret["partitions"].size).to eq(ay_device["partitions"].size + 1) + # added disk has no mount point + expect((ret["partitions"] - ay_device["partitions"]).first.key?("mount")).to eq(false) + # added disk has no fsys + expect((ret["partitions"] - ay_device["partitions"]).first.key?("fsys")).to eq(false) + end + end + + context "checking device without root partition" do + let(:checked_device) { "/dev/sdb" } + + it "do not add an additional prep partition for ppc" do + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + ret = client.try_add_boot( ay_device, target_map[checked_device]) + expect(ret["partitions"].size).to eq(ay_device["partitions"].size) + end + end + end + + context "AY configuration file has a prep partition" do + before do + client.plan_has_boot_or_prep_partition=true + end + + context "checking device with root partition" do + let(:checked_device) { "/dev/sdc" } + + it "do not add an additional prep partition if it is NOT a powernv system" do + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + ret = client.try_add_boot( ay_device, target_map[checked_device]) + expect(ret["partitions"].size).to eq(ay_device["partitions"].size) + end + end + + context "checking device without root partition" do + let(:checked_device) { "/dev/sdb" } + + it "do not add an additional prep partition for ppc" do + allow(Yast::Arch).to receive(:board_powernv).and_return(false) + ret = client.try_add_boot( ay_device, target_map[checked_device]) + expect(ret["partitions"].size).to eq(ay_device["partitions"].size) + end + end + end + end + end +end