Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2018-11-01 19:04:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-bootloader" Thu Nov 1 19:04:11 2018 rev:268 rq:644198 version:4.1.11 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2018-09-04 22:50:09.647765952 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new/yast2-bootloader.changes 2018-11-01 19:04:13.882013738 +0100 @@ -1,0 +2,19 @@ +Tue Oct 23 14:54:29 UTC 2018 - jreidinger@suse.com + +- Do not crash if an unknown device is found in a cloned configuration + (bsc#1111236) +- 4.1.11 + +------------------------------------------------------------------- +Tue Oct 16 13:56:04 CEST 2018 - schubi@suse.de + +- Fixed path to license file. . Build error in bsc#1089829. +- 4.1.10 + +------------------------------------------------------------------- +Wed Aug 29 08:14:54 UTC 2018 - dgonzalez@suse.com + +- Do not crash when required package is not installed (bsc#1089829) +- 4.1.9 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-4.1.8.tar.bz2 New: ---- yast2-bootloader-4.1.11.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.4doC2c/_old 2018-11-01 19:04:14.414013776 +0100 +++ /var/tmp/diff_new_pack.4doC2c/_new 2018-11-01 19:04:14.418013776 +0100 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 4.1.8 +Version: 4.1.11 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -103,7 +103,7 @@ %{yast_libdir}/bootloader %dir %{yast_docdir} -%license %{yast_docdir}/COPYING +%license COPYING %doc %{yast_docdir}/README.md %doc %{yast_docdir}/CONTRIBUTING.md ++++++ yast2-bootloader-4.1.8.tar.bz2 -> yast2-bootloader-4.1.11.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/package/yast2-bootloader.changes new/yast2-bootloader-4.1.11/package/yast2-bootloader.changes --- old/yast2-bootloader-4.1.8/package/yast2-bootloader.changes 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/package/yast2-bootloader.changes 2018-10-24 10:51:22.000000000 +0200 @@ -1,4 +1,23 @@ ------------------------------------------------------------------- +Tue Oct 23 14:54:29 UTC 2018 - jreidinger@suse.com + +- Do not crash if an unknown device is found in a cloned configuration + (bsc#1111236) +- 4.1.11 + +------------------------------------------------------------------- +Tue Oct 16 13:56:04 CEST 2018 - schubi@suse.de + +- Fixed path to license file. . Build error in bsc#1089829. +- 4.1.10 + +------------------------------------------------------------------- +Wed Aug 29 08:14:54 UTC 2018 - dgonzalez@suse.com + +- Do not crash when required package is not installed (bsc#1089829) +- 4.1.9 + +------------------------------------------------------------------- Wed Aug 22 16:33:37 CEST 2018 - schubi@suse.de - Switched license in spec file from SPDX2 to SPDX3 format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/package/yast2-bootloader.spec new/yast2-bootloader-4.1.11/package/yast2-bootloader.spec --- old/yast2-bootloader-4.1.8/package/yast2-bootloader.spec 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/package/yast2-bootloader.spec 2018-10-24 10:51:22.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 4.1.8 +Version: 4.1.11 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -103,7 +103,7 @@ %{yast_libdir}/bootloader %dir %{yast_docdir} -%license %{yast_docdir}/COPYING +%license COPYING %doc %{yast_docdir}/README.md %doc %{yast_docdir}/CONTRIBUTING.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/src/lib/bootloader/bootloader_base.rb new/yast2-bootloader-4.1.11/src/lib/bootloader/bootloader_base.rb --- old/yast2-bootloader-4.1.8/src/lib/bootloader/bootloader_base.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/src/lib/bootloader/bootloader_base.rb 2018-10-24 10:51:22.000000000 +0200 @@ -12,13 +12,29 @@ def initialize @read = false @proposed = false + @initial_sysconfig = Sysconfig.from_system + end + + # Prepares the system to (before write the configuration) + # + # Writes the new sysconfig and, when the Mode.normal is set, tries to install the required + # packages. If user decides to cancel the installation, it restores the previous sysconfig. + # + # @return [Boolean] true whether the system could be prepared as expected; + # false when user cancel the installation of needed packages + def prepare + write_sysconfig + + return true unless Yast::Mode.normal + return true if Yast::PackageSystem.InstallAll(packages) + + restore_initial_sysconfig + + false end # writes configuration to target disk def write - write_sysconfig - # in running system install package, for other modes, it need specific handling - Yast::PackageSystem.InstallAll(packages) if Yast::Mode.normal end # reads configuration from target disk @@ -50,11 +66,8 @@ def packages res = [] - # added kexec-tools fate# 303395 - if !Yast::Mode.live_installation && - Yast::Linuxrc.InstallInf("kexec_reboot") != "0" - res << "kexec-tools" - end + # added kexec-tools fate#303395 + res << "kexec-tools" if include_kexec_tools_package? res end @@ -74,5 +87,22 @@ @read ||= other.read? @proposed ||= other.proposed? end + + private + + # @return [Boolean] true when kexec-tools package should be included; false otherwise + def include_kexec_tools_package? + return false if Yast::Mode.live_installation + + Yast::Linuxrc.InstallInf("kexec_reboot") != "0" + end + + # Writes the sysconfig readed in the initialization + # + # Useful to "rollback" sysconfig changes if something fails before finish writing the + # configuration + def restore_initial_sysconfig + @initial_sysconfig.write + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/src/lib/bootloader/grub2.rb new/yast2-bootloader-4.1.11/src/lib/bootloader/grub2.rb --- old/yast2-bootloader-4.1.8/src/lib/bootloader/grub2.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/src/lib/bootloader/grub2.rb 2018-10-24 10:51:22.000000000 +0200 @@ -132,19 +132,9 @@ def packages res = super - res << "grub2" - - # do not require it in insts-sys as insts-sys have it itself (bsc#1004229) - if stage1.generic_mbr? && !Yast::Stage.initial - # needed for generic _mbr binary files - res << "syslinux" - end - - if Yast::Arch.x86_64 || Yast::Arch.i386 - res << "trustedgrub2" << "trustedgrub2-i386-pc" if trusted_boot - end - + res << "syslinux" if include_syslinux_package? + res << "trustedgrub2" << "trustedgrub2-i386-pc" if include_trustedgrub2_packages? res end @@ -157,6 +147,25 @@ private + # Checks if syslinux package should be included + # + # Needed for generic_mbr binary files, but it must not be required in inst-sys as inst-sys have + # it itself (bsc#1004229). + # + # @return [Boolean] true if syslinux package should be included; false otherwise + def include_syslinux_package? + return false if Yast::Stage.initial + + stage1.generic_mbr? + end + + # @return [Boolean] true when trustedgrub2 packages should be included; false otherwise + def include_trustedgrub2_packages? + return false unless trusted_boot + + Yast::Arch.x86_64 || Yast::Arch.i386 + end + def devicegraph Y2Storage::StorageManager.instance.staging end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/src/lib/bootloader/write_dialog.rb new/yast2-bootloader-4.1.11/src/lib/bootloader/write_dialog.rb --- old/yast2-bootloader-4.1.8/src/lib/bootloader/write_dialog.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/src/lib/bootloader/write_dialog.rb 2018-10-24 10:51:22.000000000 +0200 @@ -9,11 +9,13 @@ include Yast::I18n # Write settings dialog - # @return `:abort` if aborted and `:next` otherwise + # + # @return [Symbol] :abort if aborted + # :next otherwise def run Yast::Wizard.RestoreHelp(help_text) - ret = Yast::Bootloader.Write - ret ? :next : :abort + + Yast::Bootloader.Write ? :next : :abort end private diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/src/modules/BootStorage.rb new/yast2-bootloader-4.1.11/src/modules/BootStorage.rb --- old/yast2-bootloader-4.1.8/src/modules/BootStorage.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/src/modules/BootStorage.rb 2018-10-24 10:51:22.000000000 +0200 @@ -71,8 +71,11 @@ # @param devices[Array<String>] devices to inspect, can be disk, partition or its udev links # @return [Array<String>] gpt disks only def gpt_disks(devices) - targets = devices.map { |dev_name| staging.find_by_any_name(dev_name) } - boot_disks = targets.compact.each_with_object([]) { |t, r| r.concat(stage1_disks_for(t)) } + targets = devices.map do |dev_name| + staging.find_by_any_name(dev_name) or + raise ::Bootloader::BrokenConfiguration, "Unknown device #{dev_name}" + end + boot_disks = targets.each_with_object([]) { |t, r| r.concat(stage1_disks_for(t)) } result = boot_disks.select { |disk| disk.gpt? } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/src/modules/Bootloader.rb new/yast2-bootloader-4.1.11/src/modules/Bootloader.rb --- old/yast2-bootloader-4.1.8/src/modules/Bootloader.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/src/modules/Bootloader.rb 2018-10-24 10:51:22.000000000 +0200 @@ -16,6 +16,7 @@ # $Id$ # require "yast" +require "yast2/popup" require "bootloader/exceptions" require "bootloader/sysconfig" require "bootloader/bootloader_factory" @@ -226,42 +227,42 @@ log.info "Writing bootloader configuration" - # run Progress bar stages = [ - # progress stage, text in dialog (short) + _("Prepare system"), _("Create initrd"), - # progress stage, text in dialog (short) _("Save boot loader configuration") ] titles = [ - # progress step, text in dialog (short) + _("Preparing system..."), _("Creating initrd..."), - # progress step, text in dialog (short) _("Saving boot loader configuration...") ] - # progress bar caption + if Mode.normal - # progress line - Progress.New( - _("Saving Boot Loader Configuration"), - " ", - stages.size, - stages, - titles, - "" - ) + Progress.New(_("Saving Boot Loader Configuration"), " ", stages.size, stages, titles, "") Progress.NextStage else Progress.Title(titles[0]) end - ret = write_initrd - - log.error "Error occurred while creating initrd" unless ret + # Prepare system + progress_state = Progress.set(false) + if !::Bootloader::BootloaderFactory.current.prepare + log.error("System could not be prepared successfully, required packages were not installed") + Yast2::Popup.show(_("Cannot continue without install required packages")) + return false + end + Progress.set(progress_state) - Progress.NextStep + # Create initrd + Progress.NextStage Progress.Title(titles[1]) unless Mode.normal + write_initrd || log.error("Error occurred while creating initrd") + + # Save boot loader configuration + Progress.NextStage + Progress.Title(titles[2]) unless Mode.normal ::Bootloader::BootloaderFactory.current.write true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/boot_storage_test.rb new/yast2-bootloader-4.1.11/test/boot_storage_test.rb --- old/yast2-bootloader-4.1.8/test/boot_storage_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/boot_storage_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -106,4 +106,14 @@ expect(subject.gpt_boot_disk?).to eq false end end + + describe ".gpt_disk" do + it "raise Broken Configuration if any of device is not found" do + allow(subject.staging).to receive(:find_by_any_name).and_return(nil) + + expect { subject.gpt_disks(["/dev/non-existing"]) }.to( + raise_error(::Bootloader::BrokenConfiguration) + ) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/bootloader_base_test.rb new/yast2-bootloader-4.1.11/test/bootloader_base_test.rb --- old/yast2-bootloader-4.1.8/test/bootloader_base_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/bootloader_base_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -3,28 +3,76 @@ require "bootloader/bootloader_base" describe Bootloader::BootloaderBase do - describe "#write" do + describe "#prepare" do + let(:initial_sysconfig) { double(Bootloader::Sysconfig, write: nil) } + let(:new_sysconfig) { double(Bootloader::Sysconfig, write: nil) } + let(:bootloader) { "funny_bootloader" } + let(:normal_mode) { false } + before do - allow(Bootloader::Sysconfig).to receive(:new).and_return(double(write: nil)) + allow(Yast::Mode).to receive(:normal).and_return(normal_mode) + + allow(Bootloader::Sysconfig).to receive(:new).and_return(new_sysconfig) + allow(Bootloader::Sysconfig).to receive(:from_system).and_return(initial_sysconfig) + allow(Yast::PackageSystem).to receive(:InstallAll) + allow(Yast2::Popup).to receive(:show).and_return(true) + subject.define_singleton_method(:name) { "funny_bootloader" } end it "writes to sysconfig name of its child" do - sysconfig = double(Bootloader::Sysconfig, write: nil) expect(Bootloader::Sysconfig).to receive(:new) .with(bootloader: "funny_bootloader") - .and_return(sysconfig) + .and_return(new_sysconfig) + + subject.prepare + end - subject.write + context "when is not Mode.normal" do + it "returns true" do + expect(subject.prepare).to eq(true) + end end - context "Mode.normal is set" do - it "install packages required by bootloader" do + context "when is Mode.normal" do + let(:normal_mode) { true } + + it "tries to install required packages" do expect(Yast::PackageSystem).to receive(:InstallAll).with(["kexec-tools"]) - subject.write + subject.prepare + end + + context "and the user accepts the installation" do + before do + allow(Yast::PackageSystem).to receive(:InstallAll).with(["kexec-tools"]).and_return(true) + end + + it "returns true" do + expect(subject.prepare).to eq(true) + end + + it "does not rollback the sysconfig" do + expect(initial_sysconfig).to_not receive(:write) + end + end + + context "and the user does not accept the installation" do + before do + allow(Yast::PackageSystem).to receive(:InstallAll).with(["kexec-tools"]).and_return(false) + end + + it "restores the initial sysconfig" do + expect(initial_sysconfig).to receive(:write) + + subject.prepare + end + + it "returns false" do + expect(subject.prepare).to eq(false) + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/bootloader_test.rb new/yast2-bootloader-4.1.11/test/bootloader_test.rb --- old/yast2-bootloader-4.1.8/test/bootloader_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/bootloader_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -22,6 +22,31 @@ allow(::Bootloader::BootloaderFactory.current).to receive(:read) end + describe ".Write" do + context "when user cancels the installation of required packages" do + before do + allow(Yast::PackageSystem).to receive(:InstallAll).and_return(false) + allow(Yast2::Popup).to receive(:show) + end + + it "shows an information message" do + expect(Yast2::Popup).to receive(:show) + + subject.Write + end + + it "returns false" do + expect(subject.Write).to eq(false) + end + + it "logs an error" do + expect(subject.log).to receive(:error).with(/could not be prepared/) + + subject.Write + end + end + end + describe ".Import" do before do end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/grub2_efi_test.rb new/yast2-bootloader-4.1.11/test/grub2_efi_test.rb --- old/yast2-bootloader-4.1.8/test/grub2_efi_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/grub2_efi_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -22,7 +22,7 @@ end end - describe "write" do + describe "#write" do it "setups protective mbr to real disks containing /boot/efi" do subject.pmbr_action = :add allow(Yast::BootStorage).to receive(:gpt_boot_disk?).and_return(true) @@ -45,19 +45,28 @@ subject.write end + end + + describe "#prepare" do + let(:sysconfig) { double(Bootloader::Sysconfig) } + + before do + allow(Bootloader::Sysconfig).to receive(:from_system) + allow(Yast::PackageSystem).to receive(:InstallAll).and_return(true) + end + it "writes secure boot and trusted boot configuration to bootloader sysconfig" do # This test fails (only!) in Travis with # Failure/Error: subject.write Storage::Exception: Storage::Exception - sysconfig = double(Bootloader::Sysconfig) - expect(sysconfig).to receive(:write) expect(Bootloader::Sysconfig).to receive(:new) .with(bootloader: "grub2-efi", secure_boot: true, trusted_boot: true) .and_return(sysconfig) + expect(sysconfig).to receive(:write) subject.secure_boot = true subject.trusted_boot = true - subject.write + subject.prepare end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/grub2_test.rb new/yast2-bootloader-4.1.11/test/grub2_test.rb --- old/yast2-bootloader-4.1.8/test/grub2_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/grub2_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -37,8 +37,9 @@ end describe "write" do + let(:stage1) { double(Bootloader::Stage1, devices: [], generic_mbr?: false, write: nil) } + before do - stage1 = double(Bootloader::Stage1, devices: [], generic_mbr?: false, write: nil) allow(Bootloader::Stage1).to receive(:new).and_return(stage1) allow(Bootloader::MBRUpdate).to receive(:new).and_return(double(run: nil)) allow(Bootloader::GrubInstall).to receive(:new).and_return(double.as_null_object) @@ -135,24 +136,81 @@ end describe "#packages" do - it "return list containing grub2 package" do + let(:initial_stage) { true } + let(:generic_mbr) { true } + let(:stage1) { double(generic_mbr?: generic_mbr) } + + before do + allow(Yast::Stage).to receive(:initial).and_return(initial_stage) + allow(Bootloader::Stage1).to receive(:new).and_return(stage1) + end + + it "contains grub2 package" do expect(subject.packages).to include("grub2") end - it "returns list containing syslinux package if generic_mbr is used" do - stage1 = double(generic_mbr?: true) - allow(Bootloader::Stage1).to receive(:new).and_return(stage1) + context "when is in initial stage" do + it "does not include syslinux" do + expect(subject.packages).to_not include("syslinux") + end + end + + context "when is not in initial stage" do + let(:initial_stage) { false } + + context "and generic_mbr is used" do + it "contains syslinux package" do + expect(subject.packages).to include("syslinux") + end + end + + context "and generic_mbr is not used" do + let(:generic_mbr) { false } - expect(subject.packages).to include("syslinux") + it "contains syslinux package" do + expect(subject.packages).to_not include("syslinux") + end + end end - it "returns list without syslinux package if generic_mbr is not used" do - stage1 = double(generic_mbr?: false) - allow(Bootloader::Stage1).to receive(:new).and_return(stage1) + context "when trusted boot is required" do + before do + allow(subject).to receive(:trusted_boot).and_return(true) + end + + context "and is x86_64 architecture" do + before do + allow(Yast::Arch).to receive(:x86_64).and_return(true) + end + + it "contains trustedgrub2 packages" do + expect(subject.packages).to include("trustedgrub2") + expect(subject.packages).to include("trustedgrub2-i386-pc") + end + end - expect(subject.packages).to_not include("syslinux") + context "and is i386 architecture" do + before do + allow(Yast::Arch).to receive(:x86_64).and_return(true) + end + + it "contains trustedgrub2 packages" do + expect(subject.packages).to include("trustedgrub2") + expect(subject.packages).to include("trustedgrub2-i386-pc") + end + end end + context "when trusted boot is not required" do + before do + allow(subject).to receive(:trusted_boot).and_return(false) + end + + it "does not contain the trusged grub packages" do + expect(subject.packages).to_not include("trustedgrub2") + expect(subject.packages).to_not include("trustedgrub2-i386-pc") + end + end end describe "#summary" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-4.1.8/test/grub2base_test.rb new/yast2-bootloader-4.1.11/test/grub2base_test.rb --- old/yast2-bootloader-4.1.8/test/grub2base_test.rb 2018-08-23 09:39:13.000000000 +0200 +++ new/yast2-bootloader-4.1.11/test/grub2base_test.rb 2018-10-24 10:51:22.000000000 +0200 @@ -30,14 +30,14 @@ it "reads trusted boot configuration from sysconfig" do mocked_sysconfig = ::Bootloader::Sysconfig.new(trusted_boot: true) - expect(::Bootloader::Sysconfig).to receive(:from_system).and_return(mocked_sysconfig) + allow(::Bootloader::Sysconfig).to receive(:from_system).and_return(mocked_sysconfig) subject.read expect(subject.trusted_boot).to eq true mocked_sysconfig = ::Bootloader::Sysconfig.new(trusted_boot: false) - expect(::Bootloader::Sysconfig).to receive(:from_system).and_return(mocked_sysconfig) + allow(::Bootloader::Sysconfig).to receive(:from_system).and_return(mocked_sysconfig) subject.read