From 2a28b503f6633ff38f315445585ef68be69bc38a Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Wed, 23 Mar 2016 16:48:42 +0100 Subject: [PATCH] First prototype for UEFI strategy for boot requirements --- .../storage/boot_requirements_strategies.rb | 1 + .../boot_requirements_strategies/base.rb | 17 +++++- .../boot_requirements_strategies/default.rb | 50 ---------------- .../boot_requirements_strategies/uefi.rb | 58 +++++++++++++++++++ 4 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 src/lib/storage/boot_requirements_strategies/uefi.rb diff --git a/src/lib/storage/boot_requirements_strategies.rb b/src/lib/storage/boot_requirements_strategies.rb index a6de96d934..b3e6f24057 100644 --- a/src/lib/storage/boot_requirements_strategies.rb +++ b/src/lib/storage/boot_requirements_strategies.rb @@ -21,3 +21,4 @@ # Let's add here all the strategies require "storage/boot_requirements_strategies/default" +require "storage/boot_requirements_strategies/uefi" diff --git a/src/lib/storage/boot_requirements_strategies/base.rb b/src/lib/storage/boot_requirements_strategies/base.rb index ecf05d8194..b6e929ad3e 100644 --- a/src/lib/storage/boot_requirements_strategies/base.rb +++ b/src/lib/storage/boot_requirements_strategies/base.rb @@ -35,13 +35,28 @@ def initialize(settings, disk_analyzer) end def needed_partitions - raise NotImplementedError + volumes = PlannedVolumesList.new + volumes << boot_volume if boot_partition_needed? + volumes end protected attr_reader :settings attr_reader :disk_analyzer + + def boot_partition_needed? + settings.use_lvm # || settings.encrypted + end + + def boot_volume + vol = PlannedVolume.new("/boot", ::Storage::EXT4) + vol.min_size = DiskSize.MiB(100) + vol.max_size = DiskSize.MiB(500) + vol.desired_size = DiskSize.MiB(200) + vol.can_live_on_logical_volume = false + vol + end end end end diff --git a/src/lib/storage/boot_requirements_strategies/default.rb b/src/lib/storage/boot_requirements_strategies/default.rb index 3ffce22479..937283a42d 100644 --- a/src/lib/storage/boot_requirements_strategies/default.rb +++ b/src/lib/storage/boot_requirements_strategies/default.rb @@ -30,57 +30,7 @@ module Yast module Storage module BootRequirementsStrategies - # FIXME: for the time being, this is the original BootRequirementsChecker - # code, it should change to something very simple in the future, just to - # provide a fallback if no proper strategy was found. class Default < Base - def needed_partitions - boot_volumes = [] - boot_volumes << efi_boot_partition if efi_boot_partition_needed? - boot_volumes << boot_partition if boot_partition_needed? - boot_volumes << prep_partition if prep_partition_needed? - PlannedVolumesList.new(boot_volumes) - end - - def boot_partition_needed? - return true if settings.use_lvm && settings.encrypt_volume_group - false - end - - def efi_boot_partition_needed? - # TO DO - false - end - - def prep_partition_needed? - # TO DO - Arch.ppc - end - - private - - def boot_partition - vol = PlannedVolume.new("/boot", ::Storage::EXT4) - vol.min_size = DiskSize.MiB(512) # TO DO - vol.max_size = DiskSize.MiB(512) # TO DO - vol.desired_size = vol.min_size - vol.can_live_on_logical_volume = false - vol - end - - def efi_boot_partition - vol = PlannedVolume.new("/boot/efi", ::Storage::VFAT) - vol.can_live_on_logical_volume = false - # TO DO - vol - end - - def make_prep_partition - vol = PlannedVolume.new("PReP", ::Storage::VFAT) - vol.can_live_on_logical_volume = false - # TO DO - vol - end end end end diff --git a/src/lib/storage/boot_requirements_strategies/uefi.rb b/src/lib/storage/boot_requirements_strategies/uefi.rb new file mode 100644 index 0000000000..dc9a0245eb --- /dev/null +++ b/src/lib/storage/boot_requirements_strategies/uefi.rb @@ -0,0 +1,58 @@ +#!/usr/bin/env ruby +# +# encoding: utf-8 + +# Copyright (c) [2015] 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 "yast" +require "storage/boot_requirements_strategies/base" +require "storage/planned_volume" +require "storage/planned_volumes_list" +require "storage/disk_size" + +module Yast + module Storage + module BootRequirementsStrategies + class UEFI < Base + def needed_partitions + volumes = super + volumes << efi_volume if efi_partition_missing? + volumes + end + + protected + + def efi_partition_missing? + disk_analyzer.efi_partitions.empty? # #efi_partitions not implemented yet + end + + def efi_volume + vol = PlannedVolume.new("/boot/efi", ::Storage::VFAT) + vol.min_size = DiskSize.MiB(33) + vol.max_size = DiskSize.unlimited + vol.desired_size = DiskSize.MiB(500) + vol.can_live_on_logical_volume = false + # TODO: additional requirement - position below 2TB + vol + end + end + end + end +end