Skip to content

Commit

Permalink
Merge pull request #34 from ancorgs/wip
Browse files Browse the repository at this point in the history
First prototype for UEFI strategy for boot requirements
  • Loading branch information
ancorgs committed Mar 23, 2016
2 parents 45ae62d + 2a28b50 commit ef1ac19
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 51 deletions.
1 change: 1 addition & 0 deletions src/lib/storage/boot_requirements_strategies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@

# Let's add here all the strategies
require "storage/boot_requirements_strategies/default"
require "storage/boot_requirements_strategies/uefi"
17 changes: 16 additions & 1 deletion src/lib/storage/boot_requirements_strategies/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 0 additions & 50 deletions src/lib/storage/boot_requirements_strategies/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 58 additions & 0 deletions src/lib/storage/boot_requirements_strategies/uefi.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ef1ac19

Please sign in to comment.