Skip to content

Commit

Permalink
dry loading devices in BootStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 14, 2014
1 parent 573a21a commit bd61305
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 78 deletions.
41 changes: 1 addition & 40 deletions src/include/bootloader/grub2/misc.rb
Expand Up @@ -263,48 +263,9 @@ def gpt_boot_disk?
# globals["activate"] and globals["generic_mbr"] flags if needed
# all these settings are stored in internal variables
def grub_DetectDisks
mp = Storage.GetMountPoints

mountdata_boot = mp["/boot"] || mp["/"]
mountdata_root = mp["/"]

log.info "mountPoints #{mp}"
log.info "mountdata_boot #{mountdata_boot}"

BootStorage.RootPartitionDevice = mountdata_root.first || ""
raise "No mountpoint for / !!" if BootStorage.RootPartitionDevice.empty?

# if /boot changed, re-configure location
BootStorage.BootPartitionDevice = mountdata_boot.first

# get extended partition device (if exists)
BootStorage.ExtendedPartitionDevice = BootStorage.extended_partition_for(BootStorage.BootPartitionDevice)

if BootCommon.mbrDisk == "" || BootCommon.mbrDisk == nil
# mbr detection.
BootCommon.mbrDisk = BootCommon.FindMBRDisk
end

# if no bootloader devices have been set up, or any of the set up
# bootloader devices have become unavailable, then re-propose the
# bootloader location.
all_boot_partitions = BootStorage.possible_locations_for_stage1
bldevs = BootCommon.GetBootloaderDevices
need_location_reconfigure = false

if bldevs.empty?
need_location_reconfigure = true
else
Builtins.foreach(bldevs) do |dev|
if !all_boot_partitions.include?(dev)
need_location_reconfigure = true
end
end
end
need_location_reconfigure = BootStorage.detect_disks

grub_ConfigureLocation if need_location_reconfigure

nil
end

# Propose the boot loader location for grub
Expand Down
40 changes: 2 additions & 38 deletions src/include/bootloader/routines/lilolike.rb
Expand Up @@ -148,44 +148,8 @@ def ConfigureLocation
# selected_location and set the activate flag if needed
# all these settings are stored in internal variables
def DetectDisks
# #151501: AutoYaST needs to know the activate flag and the
# loader_device; jsrain also said this code is probably a bug:
# commenting out, but this may need to be changed and made dependent
# on a "clone" flag (i.e. make the choice to provide minimal (i.e. let
# YaST do partial proposals on the target system) or maximal (i.e.
# stay as closely as possible to this system) info in the AutoYaST XML
# file)
mp = Storage.GetMountPoints

mountdata_boot = Ops.get_list(mp, "/boot", Ops.get_list(mp, "/", []))
mountdata_root = Ops.get_list(mp, "/", [])

Builtins.y2milestone("mountPoints %1", mp)
Builtins.y2milestone("mountdata_boot %1", mountdata_boot)

BootStorage.RootPartitionDevice = Ops.get_string(mp, ["/", 0], "")

if BootStorage.RootPartitionDevice == ""
Builtins.y2error("No mountpoint for / !!")
end

# if /boot changed, re-configure location
BootStorage.BootPartitionDevice = Ops.get_string(
mountdata_boot,
0,
BootStorage.RootPartitionDevice
)

if @mbrDisk == "" || @mbrDisk == nil
# mbr detection.
@mbrDisk = FindMBRDisk()
end

if !BootStorage.possible_locations_for_stage1.include?(@loader_device)
ConfigureLocation()
end

nil
need_location_reconfigure = BootStorage.detect_disks
ConfigureLocation() if need_location_reconfigure
end

# Update global options of bootloader
Expand Down
38 changes: 38 additions & 0 deletions src/modules/BootStorage.rb
Expand Up @@ -436,6 +436,44 @@ def real_disks_for_partition(partition)
res.uniq
end

# Sets properly boot, root and mbr disk.
# @return true if proposal need to be reconfigured
def detect_disks
mp = Storage.GetMountPoints

mountdata_boot = mp["/boot"] || mp["/"]
mountdata_root = mp["/"]

log.info "mountPoints #{mp}"
log.info "mountdata_boot #{mountdata_boot}"

self.RootPartitionDevice = mountdata_root.first || ""
raise "No mountpoint for / !!" if BootStorage.RootPartitionDevice.empty?

# if /boot changed, re-configure location
self.BootPartitionDevice = mountdata_boot.first

# get extended partition device (if exists)
self.ExtendedPartitionDevice = extended_partition_for(BootPartitionDevice())

if BootCommon.mbrDisk == "" || BootCommon.mbrDisk == nil
# mbr detection.
BootCommon.mbrDisk = BootCommon.FindMBRDisk
end

# if no bootloader devices have been set up, or any of the set up
# bootloader devices have become unavailable, then re-propose the
# bootloader location.
bldevs = BootCommon.GetBootloaderDevices

return true if bldevs.empty?

all_boot_partitions = BootStorage.possible_locations_for_stage1
bldevs.any? do |dev|
!all_boot_partitions.include?(dev)
end
end

publish :variable => :multipath_mapping, :type => "map <string, string>"
publish :variable => :mountpoints, :type => "map <string, any>"
publish :variable => :partinfo, :type => "list <list>"
Expand Down

0 comments on commit bd61305

Please sign in to comment.