Skip to content

Commit

Permalink
Merge pull request #606 from yast/master-issue-report
Browse files Browse the repository at this point in the history
Cleanup issue handling
  • Loading branch information
imobachgs committed Jun 10, 2020
2 parents 038d3ee + 8087b6f commit 842f5c9
Show file tree
Hide file tree
Showing 15 changed files with 582 additions and 60 deletions.
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jun 10 08:57:22 UTC 2020 - Stefan Schubert <schubi@suse.com>

- AutoYaST: Cleanup/improve issue handling (bsc#1171335).
- 4.3.4

-------------------------------------------------------------------
Wed Jun 3 08:54:07 UTC 2020 - Steffen Winterfeldt <snwint@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.3.3
Version: 4.3.4
Release: 0
Summary: YaST2 - Bootloader Configuration
License: GPL-2.0-or-later
Expand Down
15 changes: 2 additions & 13 deletions src/lib/bootloader/auto_client.rb
Expand Up @@ -7,6 +7,7 @@
require "bootloader/autoyast_converter"
require "bootloader/exceptions"
require "bootloader/main_dialog"
require "bootloader/autoinst_profile/bootloader_section"

Yast.import "AutoInstall"
Yast.import "Bootloader"
Expand All @@ -33,19 +34,7 @@ def run
end

def import(data)
begin
Yast::Bootloader.Import(data)
rescue ::Bootloader::UnsupportedBootloader => e
textdomain "bootloader"
possible_values = BootloaderFactory.supported_names + [BootloaderFactory::DEFAULT_KEYWORD]
Yast::AutoInstall.issues_list.add(:invalid_value, "bootloader", "loader_type",
e.bootloader_name,
_("The selected bootloader is not supported on this architecture. Possible values: ") +
possible_values.join(", "),
:fatal)
# AutoInstall issues itself will abort import, so do not stop here prematurely.
return true
end
return true unless Yast::Bootloader.Import(data)

Yast::PackagesProposal.AddResolvables("yast2-bootloader",
:package, BootloaderFactory.current.packages)
Expand Down
89 changes: 89 additions & 0 deletions src/lib/bootloader/autoinst_profile/bootloader_section.rb
@@ -0,0 +1,89 @@
# frozen_string_literal: true

# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "installation/autoinst_profile/section_with_attributes"
require "bootloader/autoinst_profile/global_section"
require "bootloader/autoinst_profile/device_map_entry_section"

module Bootloader
module AutoinstProfile
# This class represents an AutoYaST `<bootloader>` section
#
class BootloaderSection < ::Installation::AutoinstProfile::SectionWithAttributes
def self.attributes
[
{ name: :loader_type },
{ name: :loader_device }, # deprecated
{ name: :activate }, # deprecated
{ name: :sections } # deprecated
]
end

define_attr_accessors

# @!attribute loader_type
# @return [String] which boot loader to use (default, grub2, grub2-efi and none)
# @see Bootloader::BootloaderFactory::SUPPORTED_BOOTLOADERS

# @!attribute loader_device
# @deprecated Replaced by `<boot_*>` elements in the `<global>` section.

# @!attribute activate
# @see GlobalSection#activate
# @deprecated

# @!attribute sections
# @deprecated It still exists just to log a warning in AutoyastConverter.

# @return [GlobalSection] 'global' section
attr_accessor :global
# @return [Array<DeviceMapEntrySection>] 'device_map' list
attr_accessor :device_map

# Creates an instance based on the profile representation used by the AutoYaST modules
# (hash with nested hashes and arrays).
#
# @param hash [Hash] Bootloader section from an AutoYaST profile
# @return [Bootloader]
def self.new_from_hashes(hash)
result = new
result.init_from_hashes(hash)
result
end

# Constructor
def initialize
@device_map = []
end

# Method used by {.new_from_hashes} to populate the attributes.
#
# @param hash [Hash] see {.new_from_hashes}
def init_from_hashes(hash)
super
@device_map = hash.fetch("device_map", []).map do |entry|
DeviceMapEntrySection.new_from_hashes(entry, self)
end
@global = GlobalSection.new_from_hashes(hash["global"] || {}, self)
end
end
end
end
38 changes: 38 additions & 0 deletions src/lib/bootloader/autoinst_profile/device_map_entry_section.rb
@@ -0,0 +1,38 @@
# frozen_string_literal: true

# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "installation/autoinst_profile/section_with_attributes"

module Bootloader
module AutoinstProfile
# This class represents an AutoYaST <global> section within a <bootloader> one
class DeviceMapEntrySection < ::Installation::AutoinstProfile::SectionWithAttributes
def self.attributes
[
{ name: :firmware },
{ name: :linux }
]
end

define_attr_accessors
end
end
end
126 changes: 126 additions & 0 deletions src/lib/bootloader/autoinst_profile/global_section.rb
@@ -0,0 +1,126 @@
# frozen_string_literal: true

# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "installation/autoinst_profile/section_with_attributes"

module Bootloader
module AutoinstProfile
# This class represents an AutoYaST <global> section within a <bootloader> one
class GlobalSection < ::Installation::AutoinstProfile::SectionWithAttributes
def self.attributes
[
{ name: :activate },
{ name: :append },
{ name: :boot_boot },
{ name: :boot_custom },
{ name: :boot_extended },
{ name: :boot_mbr },
{ name: :boot_root },
{ name: :cpu_mitigations },
{ name: :generic_mbr },
{ name: :gfxmode },
{ name: :hiddenmenu },
{ name: :os_prober },
{ name: :secure_boot },
{ name: :serial },
{ name: :terminal },
{ name: :timeout },
{ name: :trusted_boot },
{ name: :trusted_grub },
{ name: :vgamode },
{ name: :xen_append },
{ name: :xen_kernel_append }
]
end

define_attr_accessors

# @!attribute activate
# @return [Boolean,nil] whether to set the _boot_ flag on the boot partition.

# @!attribute append
# @return [String,nil] kernel parameters to add at the end of the boot entries.

# @!attribute boot_boot
# @return [String,nil] write GRUB 2 to a separate `/boot` partition if it exists.
# If it is not given, the bootloader is written to `/`. Valid values are
# "true" and "false".

# @!attribute boot_custom
# @return [String,nil] name of device to write GRUB 2 to (e.g., "/dev/sda3").

# @!attribute boot_extended
# @return [String,nil] write GRUB 2 to the extended partition ("true" or "false").

# @!attribute boot_mbr
# @return [String,nil] write GRUB 2 to the MBR of the disk which contains
# the `/boot` file system. Valid values are "true" and "false".

# @!attribute boot_root
# @return [String,nil] write GRUB 2 to root (`/`) partition ("true" or "false").

# @!attribute generic_mbr
# @return [Boolean,nil] write generic boot code to the MBR (ignored is `boot_mbr` is
# set to "true").

# @!attribute gfxmode
# @return [String,nil] graphical resolution of the GRUB 2 screen.

# @!attribute hiddenmenu
# @return [String,nil] whether to hide the bootloder menu.

# @!attribute os_prober
# @return [Boolean,nil] whether to search for already installed operating systems

# @!attribute cpu_mitigations
# @return [String,nil] set of kernel boot command lines parameters for CPU mitigations
# ("auto", "nosmt", "off" and "manual").

# @!attribute serial
# @return [String,nil] command to execute if the GRUB 2 terminal mode is set to "serial".

# @!attribute secure_boot
# @return [String,nil] whether to enable/disable UEFI secure boot (only for `grub2-efi`
# loader). It is set to "false", it disables the secure boot ("true" or "false").

# @!attribute terminal
# @return [String,nil] GRUB 2 terminal mode to use ("console", "gfxterm" and "serial").

# @!attribute timeout
# @return [Integer,nil] timeout in seconds until automatic boot.

# @!attribute trusted_boot
# @return [String,nil] use Trusted GRUB (only for `grub2` loader type). Valid values
# are "true" and "false".

# @!attribute vgamode
# @return [String,nil] `vga` kernel parameter (e.g., "0x317").

# @!attribute xen_append
# @return [String,nil] kernel parameters to add at the end of boot entries for Xen
# guests (e.g., "nomodeset vga=0317")

# @!attribute xen_kernel_append
# @return [String,nil] kernel parameters to add at the end of boot entries for Xen
# kernels on the VM host server (e.g., "dom0_mem=768").
end
end
end

0 comments on commit 842f5c9

Please sign in to comment.