Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2016-08-31 00:03:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2016-08-03 11:42:37.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new/yast2-bootloader.changes 2016-08-31 00:03:09.000000000 +0200 @@ -1,0 +2,28 @@ +Tue Aug 30 13:31:14 UTC 2016 - [email protected] + +- import properly device map in autoyast profile (found during + debugging bnc#995627) +- log device map entries before written them, to allow easier + debugging of augeas lenses failure (bnc#995627) +- 3.1.203 + +------------------------------------------------------------------- +Tue Aug 30 08:42:25 UTC 2016 - [email protected] + +- fix crash when activating partition on md raid (bnc#995627) +- 3.1.202 + +------------------------------------------------------------------- +Fri Aug 26 09:25:49 UTC 2016 - [email protected] + +- warn user if enabling TPM when not available (bsc#994556) +- 3.1.201 + +------------------------------------------------------------------- +Tue Aug 23 14:20:15 UTC 2016 - [email protected] + +- fix proposing generic mbr if proposed to boot from MBR + ( found during debugging bnc#994348 ) +- 3.1.200 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-3.1.199.tar.bz2 New: ---- yast2-bootloader-3.1.203.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.FSTw3j/_old 2016-08-31 00:03:10.000000000 +0200 +++ /var/tmp/diff_new_pack.FSTw3j/_new 2016-08-31 00:03:10.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.199 +Version: 3.1.203 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-bootloader-3.1.199.tar.bz2 -> yast2-bootloader-3.1.203.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/CONTRIBUTING.md new/yast2-bootloader-3.1.203/CONTRIBUTING.md --- old/yast2-bootloader-3.1.199/CONTRIBUTING.md 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/CONTRIBUTING.md 2016-08-30 15:58:39.000000000 +0200 @@ -3,7 +3,7 @@ YaST is an open source project and as such it welcomes all kinds of contributions. If you decide to contribute, please follow these guidelines to -ensure the process is effective and pleasant both for you and YaST maintainers. +ensure the process is effective and pleasant both for you and the YaST maintainers. There are two main forms of contribution: reporting bugs and performing code changes. @@ -17,13 +17,11 @@ registration](https://secure-www.novell.com/selfreg/jsp/createSimpleAccount.jsp) if you don't have an account yet.) -If you find a problem, please report it either using -[Bugzilla](https://bugzilla.suse.com/) or GitHub issues. We can't guarantee -that every bug will be fixed, but we'll try. - When creating a bug report, please follow our [bug reporting guidelines](http://en.opensuse.org/openSUSE:Report_a_YaST_bug). +We can't guarantee that every bug will be fixed, but we'll try. + Code Changes ------------ @@ -44,15 +42,22 @@ to the [Ruby style guide](https://github.com/SUSE/style-guides/blob/master/Ruby.md). - 4. Make sure your change didn't break anything by building the RPM package + 4. Update the package version (in `packages/*.spec`, usually by + `rake version:bump`) and add a new entry to the `package/*.changes` file + (by `osc vc package`). + For bigger changes or changes which need longer discussion it is advised to + add this as a separate last commit so it can be easily updated when another + change is merged in the meantime. + + 5. Make sure your change didn't break anything by building the RPM package (`rake osc:build`). The build process includes running the full testsuite. - 5. Publish the branch and create a pull request. + 6. Publish the branch and create a pull request. - 6. YaST developers will review your change and possibly point out issues. + 7. YaST developers will review your change and possibly point out issues. Adapt the code under their guidance until they are all resolved. - 7. Finally, the pull request will get merged or rejected. + 8. Finally, the pull request will get merged or rejected. See also [GitHub's guide on contributing](https://help.github.com/articles/fork-a-repo). @@ -60,9 +65,6 @@ If you want to do multiple unrelated changes, use separate branches and pull requests. -Do not change the `VERSION` and `*.changes` files as this could lead to -conflicts. - ### Commits Each commit in the pull request should do only one thing, which is clearly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/package/yast2-bootloader.changes new/yast2-bootloader-3.1.203/package/yast2-bootloader.changes --- old/yast2-bootloader-3.1.199/package/yast2-bootloader.changes 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/package/yast2-bootloader.changes 2016-08-30 15:58:39.000000000 +0200 @@ -1,4 +1,32 @@ ------------------------------------------------------------------- +Tue Aug 30 13:31:14 UTC 2016 - [email protected] + +- import properly device map in autoyast profile (found during + debugging bnc#995627) +- log device map entries before written them, to allow easier + debugging of augeas lenses failure (bnc#995627) +- 3.1.203 + +------------------------------------------------------------------- +Tue Aug 30 08:42:25 UTC 2016 - [email protected] + +- fix crash when activating partition on md raid (bnc#995627) +- 3.1.202 + +------------------------------------------------------------------- +Fri Aug 26 09:25:49 UTC 2016 - [email protected] + +- warn user if enabling TPM when not available (bsc#994556) +- 3.1.201 + +------------------------------------------------------------------- +Tue Aug 23 14:20:15 UTC 2016 - [email protected] + +- fix proposing generic mbr if proposed to boot from MBR + ( found during debugging bnc#994348 ) +- 3.1.200 + +------------------------------------------------------------------- Mon Jul 18 14:56:27 UTC 2016 - [email protected] - do not fail tests when run in environment connected by serial diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/package/yast2-bootloader.spec new/yast2-bootloader-3.1.203/package/yast2-bootloader.spec --- old/yast2-bootloader-3.1.199/package/yast2-bootloader.spec 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/package/yast2-bootloader.spec 2016-08-30 15:58:39.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.199 +Version: 3.1.203 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/lib/bootloader/autoyast_converter.rb new/yast2-bootloader-3.1.203/src/lib/bootloader/autoyast_converter.rb --- old/yast2-bootloader-3.1.199/src/lib/bootloader/autoyast_converter.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/lib/bootloader/autoyast_converter.rb 2016-08-30 15:58:39.000000000 +0200 @@ -3,6 +3,7 @@ require "bootloader/bootloader_factory" Yast.import "BootStorage" +Yast.import "Arch" module Bootloader # Represents unsupported bootloader type error @@ -32,6 +33,7 @@ import_grub2(data, bootloader) import_stage1(data, bootloader) import_default(data, bootloader.grub_default) + import_device_map(data, bootloader) # TODO: import Initrd log.warn "autoyast profile contain sections which won't be processed" if data["sections"] @@ -52,6 +54,9 @@ export_grub2(global, config) if config.name == "grub2" export_stage1(global, config.stage1) if config.respond_to?(:stage1) export_default(global, config.grub_default) + # Do not export device map as device name are very unpredictable and is used only as + # work-around when automatic ones do not work for what-ever reasons ( it can really safe + # your day in L3 ) res end @@ -106,6 +111,19 @@ end end + def import_device_map(data, bootloader) + return unless bootloader.name == "grub2" + return if !Yast::Arch.x86_64 && !Yast::Arch.i386 + + dev_map = data["device_map"] + return unless dev_map + + bootloader.device_map.clear_mapping + dev_map.each do |entry| + bootloader.device_map.add_mapping(entry["firmware"], entry["linux"]) + end + end + STAGE1_DEVICES_MAPPING = { "boot_root" => :RootPartitionDevice, "boot_boot" => :BootPartitionDevice, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/lib/bootloader/device_map.rb new/yast2-bootloader-3.1.203/src/lib/bootloader/device_map.rb --- old/yast2-bootloader-3.1.199/src/lib/bootloader/device_map.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/lib/bootloader/device_map.rb 2016-08-30 15:58:39.000000000 +0200 @@ -33,6 +33,7 @@ end def write + log.info "writing device map: #{self}" @model.save end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/lib/bootloader/grub2_widgets.rb new/yast2-bootloader-3.1.203/src/lib/bootloader/grub2_widgets.rb --- old/yast2-bootloader-3.1.199/src/lib/bootloader/grub2_widgets.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/lib/bootloader/grub2_widgets.rb 2016-08-30 15:58:39.000000000 +0200 @@ -8,6 +8,7 @@ Yast.import "Label" Yast.import "Report" Yast.import "UI" +Yast.import "Mode" module Bootloader # Adds to generic widget grub2 specific helpers @@ -295,7 +296,13 @@ def help # TRANSLATORS: TrustedGRUB2 is a name, don't translate it - _("<b>Trusted Boot</b> will install TrustedGRUB2 instead of regular GRUB2.\n") + _("<p><b>Trusted Boot</b> will install TrustedGRUB2\n" \ + "instead of regular GRUB2.</p>\n" \ + "<p>It means measuring the integrity of the boot process,\n" \ + "with the help from the hardware (a TPM, Trusted Platform Module,\n" \ + "chip).</p>\n" \ + "<p>First you need to make sure Trusted Boot is enabled in the BIOS\n" \ + "setup (the setting may be named Security Chip, for example).</p>\n") end def init @@ -305,6 +312,20 @@ def store grub2.trusted_boot = value end + + def validate + return true if Yast::Mode.config || !value + tpm_files = Dir.glob("/sys/**/pcrs") + if !tpm_files.empty? + # check for file size does not work, since FS reports it 4096 + # even if the file is in fact empty and a single byte cannot + # be read, therefore testing real reading (details: bsc#994556) + return true unless File.read(tpm_files[0], 1).nil? + end + Yast::Popup.ContinueCancel(_("Trusted Platform Module not found.\n" \ + "Make sure it is enabled in BIOS.\n" \ + "The system will not boot otherwise.")) + end end # Represents grub password protection widget diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/lib/bootloader/mbr_update.rb new/yast2-bootloader-3.1.203/src/lib/bootloader/mbr_update.rb --- old/yast2-bootloader-3.1.199/src/lib/bootloader/mbr_update.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/lib/bootloader/mbr_update.rb 2016-08-30 15:58:39.000000000 +0200 @@ -1,6 +1,7 @@ require "yast" require "bootloader/boot_record_backup" +require "bootloader/stage1_device" require "yast2/execute" Yast.import "Arch" @@ -45,7 +46,7 @@ end def mbr_is_gpt? - mbr_storage_object = Yast::Storage.GetTargetMap[mbr_disk] + mbr_storage_object = target_map[mbr_disk] raise "Cannot find in storage mbr disk #{mbr_disk}" unless mbr_storage_object mbr_type = mbr_storage_object["label"] log.info "mbr type = #{mbr_type}" @@ -138,24 +139,35 @@ ret = [mbr_disk] # Add to disks only if part of raid on base devices lives on mbr_disk ret.concat(mbrs) if mbrs.include?(mbr_disk) + # get only real disks + ret = ret.each_with_object([]) do |disk, res| + res.concat(::Bootloader::Stage1Device.new(disk).real_devices) + end ret.uniq end def first_base_device_to_boot(md_device) - md = Yast::BootStorage.Md2Partitions(md_device) - md.reduce do |res, items| - device, bios_id = items - next device unless res + md = ::Bootloader::Stage1Device.new(md_device) + md.real_devices.min_by { |device| bios_id_for(device) } + end - bios_id < md[res] ? device : res - end + MAX_BIOS_ID = 1000 + def bios_id_for(device) + disk = Yast::Storage.GetDiskPartition(device)["disk"] + disk_info = target_map[disk] + return MAX_BIOS_ID unless disk_info + + bios_id = disk_info["bios_id"] + # prefer device without bios id over ones without disk info + return MAX_BIOS_ID - 1 if !bios_id || bios_id !~ /0x[0-9a-fA-F]+/ + + bios_id[2..-1].to_i(16) - 0x80 end # List of partition for disk that can be used for setting boot flag def activatable_partitions(disk) - tm = Yast::Storage.GetTargetMap - partitions = tm.fetch(disk, {}).fetch("partitions", []) + partitions = target_map.fetch(disk, {}).fetch("partitions", []) # do not select swap and do not select BIOS grub partition # as it clear its special flags (bnc#894040) partitions.select do |p| @@ -173,28 +185,20 @@ end # Given a device name to which we install the bootloader (loader_device), - # get the name of the partition which should be activated. - # Also return the device file name of the disk device that corresponds to - # loader_device (i.e. where the corresponding MBR can be found). + # gets back disk and partition number to activate. If empty Hash is returned + # then no suitable partition to activate found. # @param [String] loader_device string the device to install bootloader to - # @return a map $[ "mbr": string, "num": any] - # containing device (eg. "/dev/hda4"), disk (eg. "/dev/hda") and - # partition number (eg. 4) + # @return a Hash `{ "mbr" => String, "num" => Integer }` + # containing disk (eg. "/dev/hda") and partition number (eg. 4) def partition_to_activate(loader_device) - p_dev = Yast::Storage.GetDiskPartition(loader_device) + real_device = first_base_device_to_boot(loader_device) + log.info "real devices for #{loader_device} is #{real_device}" + + p_dev = Yast::Storage.GetDiskPartition(real_device) num = p_dev["nr"].to_i mbr_dev = p_dev["disk"] raise "Invalid loader device #{loader_device}" unless mbr_dev - # If loader_device is /dev/md* (which means bootloader is installed to - # /dev/md*), then call recursive method with partition that lays on device - # with the lowest bios id number or first one if noone have bios id - # FIXME: use ::storage to detect md devices, not by name! - if loader_device.start_with?("/dev/md") - base_device = first_base_device_to_boot(loader_device) - return partition_to_activate(base_device) if base_device - end - # (bnc # 337742) - Unable to boot the openSUSE (32 and 64 bits) after installation # if loader_device is disk Choose any partition which is not swap to # satisfy such bios (bnc#893449) @@ -234,5 +238,9 @@ result.uniq end + + def target_map + @target_map ||= Yast::Storage.GetTargetMap + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/lib/bootloader/stage1_proposal.rb new/yast2-bootloader-3.1.203/src/lib/bootloader/stage1_proposal.rb --- old/yast2-bootloader-3.1.199/src/lib/bootloader/stage1_proposal.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/lib/bootloader/stage1_proposal.rb 2016-08-30 15:58:39.000000000 +0200 @@ -20,7 +20,7 @@ proposal.new(stage1).propose - log.info "proposed stage1 configuratopn #{stage1.inspect}" + log.info "proposed stage1 configuration #{stage1.inspect}" end protected @@ -119,6 +119,8 @@ end assign_bootloader_device(selected_location) + + selected_location end def separated_boot? diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/src/modules/BootStorage.rb new/yast2-bootloader-3.1.203/src/modules/BootStorage.rb --- old/yast2-bootloader-3.1.199/src/modules/BootStorage.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/src/modules/BootStorage.rb 2016-08-30 15:58:39.000000000 +0200 @@ -325,7 +325,6 @@ publish :variable => :BootPartitionDevice, :type => "string" publish :variable => :RootPartitionDevice, :type => "string" publish :variable => :ExtendedPartitionDevice, :type => "string" - publish :function => :Md2Partitions, :type => "map <string, integer> (string)" end BootStorage = BootStorageClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/test/autoyast_converter_test.rb new/yast2-bootloader-3.1.203/test/autoyast_converter_test.rb --- old/yast2-bootloader-3.1.199/test/autoyast_converter_test.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/test/autoyast_converter_test.rb 2016-08-30 15:58:39.000000000 +0200 @@ -3,6 +3,8 @@ require "bootloader/autoyast_converter" require "bootloader/grub2" +Yast.import "Arch" + describe Bootloader::AutoyastConverter do subject { described_class } @@ -63,6 +65,21 @@ expect(bootloader.trusted_boot).to eq true end + it "imports device map for grub2 on intel architecture" do + allow(Yast::Arch).to receive(:architecture).and_return("x86_64") + data = { + "loader_type" => "grub2", + "device_map" => [ + { "firmware" => "hd0", "linux" => "/dev/vda" }, + { "firmware" => "hd1", "linux" => "/dev/vdb" } + ] + } + + bootloader = subject.import(data) + expect(bootloader.device_map.system_device_for("hd0")).to eq "/dev/vda" + expect(bootloader.device_map.system_device_for("hd1")).to eq "/dev/vdb" + end + it "supports SLE9 format" do data = { "activate" => "true", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/test/mbr_update_test.rb new/yast2-bootloader-3.1.203/test/mbr_update_test.rb --- old/yast2-bootloader-3.1.199/test/mbr_update_test.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/test/mbr_update_test.rb 2016-08-30 15:58:39.000000000 +0200 @@ -119,6 +119,20 @@ subject.run(stage1(generic_mbr: true)) end + it "always uses real devices" do + allow(Yast::BootStorage).to receive(:mbr_disk) + .and_return("/dev/md0") + + allow(::Bootloader::Stage1Device).to receive(:new).with("/dev/md0") + .and_return(double(real_devices: ["/dev/sda1", "/dev/sdb1"])) + expect(Yast::Execute).to receive(:on_target).at_least(:twice) do |*args| + next nil unless args.first =~ /dd/ + next nil unless args.include?("of=/dev/sdb") + expect(args).to be_include("of=/dev/sda") + end + subject.run(stage1(generic_mbr: true)) + end + it "install syslinux if non on initial stage" do allow(Yast::Stage).to receive(:initial).and_return(false) expect(Yast::PackageSystem).to receive(:Install).with("syslinux") @@ -188,6 +202,20 @@ subject.run(stage1(activate: true, devices: ["/dev/sda1", "/dev/sdb1"])) end + + it "sets boot flag on boot device with the lowest bios id when stage1 partition is on md" do + allow(Yast::Storage).to receive(:GetTargetMap).and_return( + "/dev/sda" => { "label" => "msdos", "bios_id" => "0x81" }, + "/dev/sdb" => { "label" => "msdos", "bios_id" => "0x80" } + ) + + allow(::Bootloader::Stage1Device).to receive(:new).with("/dev/md1") + .and_return(double(real_devices: ["/dev/sda1", "/dev/sdb1"])) + expect(Yast::Execute).to receive(:locally) + .with(/parted/, "-s", "/dev/sdb", "set", 1, "boot", "on") + + subject.run(stage1(activate: true, devices: ["/dev/md1"])) + end end context "disk label is GPT" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.199/test/stage1_test.rb new/yast2-bootloader-3.1.203/test/stage1_test.rb --- old/yast2-bootloader-3.1.199/test/stage1_test.rb 2016-07-18 17:25:07.000000000 +0200 +++ new/yast2-bootloader-3.1.203/test/stage1_test.rb 2016-08-30 15:58:39.000000000 +0200 @@ -50,6 +50,20 @@ expect(subject.mbr?).to eq true end + it "do not set generic_mbr if proposed boot from mbr" do + allow(Bootloader::Stage1Device).to receive(:new).and_call_original + target_map_stub("storage_mdraid.yaml") + + allow(Yast::BootStorage).to receive(:mbr_disk) + .and_return("/dev/md") + allow(Yast::BootStorage).to receive(:BootPartitionDevice) + .and_return("/dev/md1") + + subject.propose + + expect(subject.generic_mbr?).to eq false + end + context "on ppc64" do before do allow(Yast::Arch).to receive(:architecture).and_return("ppc64")
