Skip to content

Commit

Permalink
Merge pull request #421 from yast/adapt_new_wrapper
Browse files Browse the repository at this point in the history
Adapt new wrapper
  • Loading branch information
jreidinger committed Apr 24, 2017
2 parents 1ebf1d8 + f66860a commit 3d39fb4
Show file tree
Hide file tree
Showing 36 changed files with 444 additions and 229 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -9,3 +9,4 @@ script:
# the "storage-ng-travis-ruby" script is included in the base yastdevel/storage-ng image
# see https://github.com/yast/docker-storage-ng/blob/master/storage-ng-travis-ruby
- docker run -it -e TRAVIS=1 -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" yast-bootloader-image storage-ng-travis-ruby
- docker run -it yast-bootloader-image rake check:doc
1 change: 0 additions & 1 deletion Dockerfile
@@ -1,3 +1,2 @@
FROM yastdevel/storage-ng
COPY . /usr/src/app

3 changes: 3 additions & 0 deletions Rakefile
Expand Up @@ -8,4 +8,7 @@ Yast::Tasks.configuration do |conf|
conf.obs_project = "YaST:storage-ng"
# Make sure 'rake osc:sr' fails
conf.obs_sr_project = nil
# TODO: improve it, at least do not get worse
# TODO: remove condition when new packaging tasks are accepted to factory
conf.documentation_minimal = 50 if conf.respond_to?(:documentation_minimal=)
end
31 changes: 31 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,16 +1,47 @@
-------------------------------------------------------------------
Fri Apr 21 11:28:29 UTC 2017 - jreidinger@suse.com

- storage-ng: use new wrapper API
- 3.3.7

-------------------------------------------------------------------
Thu Apr 13 13:34:12 UTC 2017 - jreidinger@suse.com

- Add possibility to use trusted boot for EFI (FATE#315831)

-------------------------------------------------------------------
Tue Mar 28 13:32:23 UTC 2017 - jreidinger@suse.com

- storage-ng: fixed proposal to not try to install to LVM
partition
- 3.3.6

-------------------------------------------------------------------
Fri Mar 24 14:17:00 UTC 2017 - jreidinger@suse.com

- Report user friendly message when no root partition is detected
instead of internal error. (bsc#1029293)

-------------------------------------------------------------------
Fri Mar 3 15:33:11 CET 2017 - snwint@suse.de

- storage-ng: avoid call to old libstorage
- 3.3.5

-------------------------------------------------------------------
Wed Mar 1 17:42:18 UTC 2017 - jreidinger@suse.com

- provide more helpful error message when invalid arguments for
serial console are provided (bsc#1012383)

-------------------------------------------------------------------
Wed Mar 1 16:42:18 UTC 2017 - jreidinger@suse.com

- propose for xen hypervisor vga parameter if framebuffer is used
( should fix issue with text only environment when fbdev driver
is used )
(FATE#322200)

-------------------------------------------------------------------
Thu Feb 16 14:47:03 UTC 2017 - ancor@suse.com

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


Name: yast2-bootloader
Version: 3.3.6
Version: 3.3.7
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
10 changes: 5 additions & 5 deletions src/lib/bootloader/autoyast_converter.rb
Expand Up @@ -125,10 +125,10 @@ def import_device_map(data, bootloader)
end

STAGE1_DEVICES_MAPPING = {
"boot_root" => :RootPartitionDevice,
"boot_boot" => :BootPartitionDevice,
"boot_root" => :root_partition,
"boot_boot" => :boot_partition,
"boot_mbr" => :mbr_disk,
"boot_extended" => :ExtendedPartitionDevice
"boot_extended" => :extended_partition
}.freeze
def import_stage1(data, bootloader)
return unless bootloader.name == "grub2"
Expand All @@ -153,13 +153,13 @@ def import_stage1_devices(data, stage1)
# extended partion maybe do not exists, so report it to user
if (data["global"]["boot_extended"] == "true" ||
data["location"] == "extended") &&
Yast::BootStorage.ExtendedPartitionDevice.nil?
Yast::BootStorage.extended_partition.nil?
raise "boot_extended used in autoyast profile, but there is no extended partition"
end

STAGE1_DEVICES_MAPPING.each do |key, device|
if data["global"][key] == "true" || data["boot_#{key}"]
stage1.add_udev_device(Yast::BootStorage.public_send(device))
stage1.add_udev_device(Yast::BootStorage.public_send(device).name)
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/boot_record_backup.rb
Expand Up @@ -50,7 +50,7 @@ def write

# special backup only if device is mbr disk
Yast.import "BootStorage"
return if device != Yast::BootStorage.mbr_disk
return if device != Yast::BootStorage.mbr_disk.name

copy_br(device, "/boot/backup_mbr")
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/config_dialog.rb
Expand Up @@ -44,7 +44,7 @@ def guarded_run

# F#300779 - Install diskless client (NFS-root)
# additional warning that root partition is nfs type -> bootloader will not be installed
device = Yast::BootStorage.disk_with_boot_partition
device = Yast::BootStorage.disk_with_boot_partition.name

if device == "/dev/nfs" && Yast::Mode.installation
Yast::Popup.Message(
Expand Down
5 changes: 2 additions & 3 deletions src/lib/bootloader/device_map.rb
Expand Up @@ -13,7 +13,6 @@ module Bootloader
class DeviceMap
extend Forwardable
include Yast::Logger
using Y2Storage::Refinements::DevicegraphLists

def_delegators :@model, :grub_device_for, :system_device_for, :grub_devices,
:add_mapping, :remove_mapping
Expand Down Expand Up @@ -120,7 +119,7 @@ def order_boot_device
# want to modify its MBR. So we get disk of such partition and change order to add it
# to top of device map. For details see bnc#887808,bnc#880439
boot_disk = Yast::BootStorage.disk_with_boot_partition
priority_disks = ::Bootloader::Stage1Device.new(boot_disk).real_devices
priority_disks = ::Bootloader::Stage1Device.new(boot_disk.name).real_devices
# if none of priority disk is hd0, then choose one and assign it
return if any_first_device?(priority_disks)

Expand All @@ -132,7 +131,7 @@ def fill_mapping
# BIOS-ID is not supported in libstorage-ng, so let's simply create a
# mapping entry per disk for the time being (see commented code for the
# real expected behavior)
staging = Y2Storage::StorageManager.instance.staging
staging = Y2Storage::StorageManager.instance.y2storage_staging
staging.disks.each_with_index do |disk, index|
add_mapping("hd#{index}", disk.name)
end
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/device_map_dialog.rb
Expand Up @@ -142,7 +142,7 @@ def refresh_disks
end

def store_order
Yast::BootStorage.mbr_disk = disks.first
Yast::BootStorage.assign_mbr_disk_by_name(disks.first)

@device_map.clear_mapping
disks.each_with_index do |disk, index|
Expand Down
11 changes: 11 additions & 0 deletions src/lib/bootloader/exceptions.rb
Expand Up @@ -25,4 +25,15 @@ def initialize(msg)
"Please use YaST2 bootloader to fix it. Details: %s") % msg
end
end

# Represents error when serial console arguments are not valid
class InvalidSerialConsoleArguments < BrokenConfiguration
MESSAGE = "Invalid serial console arguments".freeze
def initialize(msg = MESSAGE)
super
end
end

class NoRoot < RuntimeError
end
end
30 changes: 11 additions & 19 deletions src/lib/bootloader/grub2.rb
Expand Up @@ -17,11 +17,6 @@ module Bootloader
class Grub2 < Grub2Base
attr_reader :stage1
attr_reader :device_map
# @return [Boolean]
attr_accessor :trusted_boot

using Y2Storage::Refinements::DevicegraphLists
using Y2Storage::Refinements::Disk

def initialize
super
Expand All @@ -30,7 +25,6 @@ def initialize
@stage1 = Stage1.new
@grub_install = GrubInstall.new(efi: false)
@device_map = DeviceMap.new
@trusted_boot = false
end

# Read settings from disk, overwritting already set values
Expand All @@ -55,8 +49,6 @@ def read
log.info "grub2/device.map does not exist. Using empty one."
@device_map = DeviceMap.new
end

@trusted_boot = Sysconfig.from_system.trusted_boot
end

# Write bootloader settings to disk
Expand Down Expand Up @@ -89,14 +81,12 @@ def propose
# boot, safer option for legacy booting (bnc#872054)
self.pmbr_action = :add if Yast::BootStorage.gpt_boot_disk?
device_map.propose if Yast::Arch.x86_64 || Yast::Arch.i386
@trusted_boot = false
end

def merge(other)
super

@device_map = other.device_map if !other.device_map.empty?
@trusted_boot = other.trusted_boot unless other.trusted_boot.nil?

stage1.merge(other.stage1)
end
Expand All @@ -111,7 +101,7 @@ def summary(simple_mode: false)
),
Yast::Builtins.sformat(
_("Enable Trusted Boot: %1"),
@trusted_boot ? _("yes") : _("no")
trusted_boot ? _("yes") : _("no")
)
]
locations_val = locations
Expand Down Expand Up @@ -151,7 +141,7 @@ def packages
end

if Yast::Arch.x86_64 || Yast::Arch.i386
res << "trustedgrub2" << "trustedgrub2-i386-pc" if @trusted_boot
res << "trustedgrub2" << "trustedgrub2-i386-pc" if trusted_boot
end

res
Expand All @@ -160,19 +150,21 @@ def packages
# FIXME: refactor with injection like super(prewrite: prewrite, sysconfig = ...)
# overwrite BootloaderBase version to save trusted boot
def write_sysconfig(prewrite: false)
sysconfig = Bootloader::Sysconfig.new(bootloader: name, trusted_boot: @trusted_boot)
sysconfig = Bootloader::Sysconfig.new(bootloader: name, trusted_boot: trusted_boot)
prewrite ? sysconfig.pre_write : sysconfig.write
end

private

def devicegraph
Y2Storage::StorageManager.instance.staging
Y2Storage::StorageManager.instance.y2storage_staging
end

def gpt_disks_devices
boot_devices = stage1.devices
boot_discs = devicegraph.disks.with_name_or_partition(boot_devices)
boot_discs = devicegraph.disks.select do |disk|
boot_devices.any? { |bd| disk.name_or_partition?(bd) }
end
gpt_disks = boot_discs.select { |d| d.gpt? }
gpt_disks.map { |d| d.name }
end
Expand All @@ -196,12 +188,12 @@ def locations
locations << partition_location unless partition_location.empty?
if stage1.extended_partition?
# TRANSLATORS: extended is here for extended partition. Keep translation short.
locations << Yast::BootStorage.ExtendedPartitionDevice + _(" (extended)")
locations << Yast::BootStorage.extended_partition.name + _(" (extended)")
end
if stage1.mbr?
# TRANSLATORS: MBR is acronym for Master Boot Record, if nothing locally specific
# is used in your language, then keep it as it is.
locations << Yast::BootStorage.mbr_disk + _(" (MBR)")
locations << Yast::BootStorage.mbr_disk.name + _(" (MBR)")
end
locations << stage1.custom_devices if !stage1.custom_devices.empty?

Expand All @@ -211,10 +203,10 @@ def locations
def boot_partition_location
if Yast::BootStorage.separated_boot?
if stage1.boot_partition?
return Yast::BootStorage.BootPartitionDevice + " (\"/boot\")"
return Yast::BootStorage.boot_partition.name + " (\"/boot\")"
end
elsif stage1.root_partition?
return Yast::BootStorage.RootPartitionDevice + " (\"/\")"
return Yast::BootStorage.root_partition.name + " (\"/\")"
end

""
Expand Down

0 comments on commit 3d39fb4

Please sign in to comment.