Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Mar 21, 2016
1 parent c6dd380 commit e02a185
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Metrics/LineLength:

# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 110 # TODO this should be lower for new code
Max: 100 # TODO this should be lower for new code
Include:
- 'src/lib/**/*.rb' # be more strict for new code in lib

Expand All @@ -75,7 +75,7 @@ Metrics/MethodLength:

# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 40 # TODO this should be lower for new code
Max: 30 # TODO this should be lower for new code
Include:
- 'src/lib/**/*.rb' # be more strict for new code in lib

Expand Down
3 changes: 2 additions & 1 deletion src/lib/bootloader/bootloader_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def supported_names
end

def bootloader_by_name(name)
@cached_bootloaders ||= {} # needed to be able to store settings if moving between bootloaders
# needed to be able to store settings when moving between bootloaders
@cached_bootloaders ||= {}
case name
when "grub2"
@cached_bootloaders["grub2"] ||= Grub2.new
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/config_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run
log.info "Running Main Dialog"

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

if device == "/dev/nfs" && Yast::Mode.installation
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bootloader/device_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def filtered_target_map

def propose_s390_device_map
# s390 have some special requirements for device map. Keep it short and simple (bnc#884798)
# TODO: device map is not needed at all for s390, so if we get rid of perl-Bootloader translations
# we can keep it empty
# TODO: device map is not needed at all for s390, so if we get rid of
# perl-Bootloader translations we can keep it empty
boot_part = Yast::Storage.GetEntryForMountpoint("/boot/zipl")
boot_part = Yast::Storage.GetEntryForMountpoint("/boot") if boot_part.empty?
boot_part = Yast::Storage.GetEntryForMountpoint("/") if boot_part.empty?
Expand Down
12 changes: 8 additions & 4 deletions src/lib/bootloader/grub2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,25 @@ def partition_line
if Yast::BootStorage.BootPartitionDevice != Yast::BootStorage.RootPartitionDevice
if @stage1.boot_partition?
_(
"Install bootcode into /boot partition (<a href=\"disable_boot_boot\">do not install</a>)"
"Install bootcode into /boot partition " \
"(<a href=\"disable_boot_boot\">do not install</a>)"
)
else
_(
"Do not install bootcode into /boot partition (<a href=\"enable_boot_boot\">install</a>)"
"Do not install bootcode into /boot partition " \
"(<a href=\"enable_boot_boot\">install</a>)"
)
end
else
if @stage1.root_partition?
_(
"Install bootcode into \"/\" partition (<a href=\"disable_boot_root\">do not install</a>)"
"Install bootcode into \"/\" partition " \
"(<a href=\"disable_boot_root\">do not install</a>)"
)
else
_(
"Do not install bootcode into \"/\" partition (<a href=\"enable_boot_root\">install</a>)"
"Do not install bootcode into \"/\" partition " \
"(<a href=\"enable_boot_root\">install</a>)"
)
end
end
Expand Down
3 changes: 2 additions & 1 deletion src/lib/bootloader/grub2_widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def label
def help
_(
"<p><b>Set active Flag in Partition Table for Boot Partition</b><br>\n" \
"To activate the partition which contains the boot loader. The generic MBR code will then\n" \
"To activate the partition which contains the boot loader." \
" The generic MBR code will then\n" \
"boot the active partition. Older BIOSes require one partition to be active even\n" \
"if the boot loader is installed in the MBR.</p>"
)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/bootloader/grub2base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def merge_grub_default(other)
other = other.grub_default

unless other.kernel_params.serialize.empty?
default.kernel_params.replace(other.kernel_params.serialize + " " + default.kernel_params.serialize)
new_kernel_params = default.kernel_params.serialize + " " + other.kernel_params.serialize
default.kernel_params.replace(new_kernel_params)
end

# string attributes
Expand Down
10 changes: 6 additions & 4 deletions src/lib/bootloader/grub2pwd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class GRUB2Pwd
# @return [Boolean] specifies if password protection enabled
#
# @!attribute unrestricted
# @return [Boolean] specifies if unrestricted password protection should be used (see fate#318574)
# @return [Boolean] specifies if unrestricted password protection should
# be used (see fate#318574)
attr_accessor :used, :unrestricted
alias_method :used?, :used
alias_method :unrestricted?, :unrestricted
Expand Down Expand Up @@ -75,7 +76,8 @@ def read
pwd_line = content.lines.grep(/password_pbkdf2 root/).first

if !pwd_line
raise "Cannot find encrypted password, YaST2 password generator in /etc/grub.d is probably modified."
raise "Cannot find encrypted password. " \
"YaST2 password generator in /etc/grub.d is probably modified."
end

@encrypted_password = pwd_line[/password_pbkdf2 root (\S+)/, 1]
Expand Down Expand Up @@ -132,12 +134,12 @@ def encrypt(password)

pwd_line = result["stdout"].split("\n").grep(/password is/).first
if !pwd_line
raise "INTERNAL ERROR: output do not contain encrypted password. Output: #{result["stdout"]}"
raise "grub2-mkpasswd output do not contain encrypted password. Output: #{result["stdout"]}"
end

ret = pwd_line[/^.*password is\s*(\S+)/, 1]
if !ret
raise "INTERNAL ERROR: output do not contain encrypted password. Output: #{result["stdout"]}"
raise "grub2-mkpasswd output do not contain encrypted password. Output: #{result["stdout"]}"
end

ret
Expand Down
8 changes: 6 additions & 2 deletions src/lib/bootloader/mbr_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def activate_partitions
partitions_to_activate.each do |m_activate|
num = m_activate["num"]
mbr_dev = m_activate["mbr"]
raise "INTERNAL ERROR: Data for partition to activate is invalid." if num.nil? || mbr_dev.nil?
if num.nil? || mbr_dev.nil?
raise "INTERNAL ERROR: Data for partition to activate is invalid."
end

next unless can_activate_partition?(num)

Expand Down Expand Up @@ -181,7 +183,9 @@ def activatable_partitions(disk)
partitions = tm.fetch(disk, {}).fetch("partitions", [])
# do not select swap and do not select BIOS grub partition
# as it clear its special flags (bnc#894040)
partitions.select { |p| p["used_fs"] != :swap && p["fsid"] != Yast::Partitions.fsid_bios_grub }
partitions.select do |p|
p["used_fs"] != :swap && p["fsid"] != Yast::Partitions.fsid_bios_grub
end
end

def extended_partition_num(disk)
Expand Down
21 changes: 15 additions & 6 deletions src/lib/bootloader/udev_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class << self
:to_mountby_device
end

# Returns hash where keys are udev links for disks and partitions and value their kernel devices.
# Returns hash where keys are udev links for disks and partitions and value
# their kernel devices.
# TODO: remove when remove pbl support
# @example of output
# {
Expand Down Expand Up @@ -71,7 +72,11 @@ def to_mountby_device(dev)

udev_data_key = MOUNT_BY_MAPPING_TO_UDEV[mount_by]
raise "Internal error unknown mountby #{mount_by}" unless udev_data_key
udev_pair = map_device_to_udev_devices(storage_data[udev_data_key], udev_data_key, kernel_dev).first
udev_pair = map_device_to_udev_devices(
storage_data[udev_data_key],
udev_data_key,
kernel_dev
).first
if !udev_pair
log.warn "Cannot find udev link to satisfy mount by for #{kernel_dev}"
return kernel_dev
Expand Down Expand Up @@ -112,7 +117,9 @@ def used_mount_by(storage_data)

# reader of all devices that ensure that it contain valid data
#
# @return hash where keys are udev links for disks and partitions and value their kernel devices.
# @return hash where keys are udev links for disks and partitions and value
# their kernel devices.
#
# @example of output
# {
# "/dev/disk/by-id/abcd" => "/dev/sda",
Expand Down Expand Up @@ -160,8 +167,10 @@ def fill_all_devices(keys, data, device)
end
end

# Returns array of pairs where each pair contain full udev name as first and kernel device as second
# @param names [Array<String>] udev names for device e.g. "aaaa-bbbb-cccc-dddd" for uuid device name
# Returns array of pairs where each pair contain full udev name as first and kernel
# device as second
# @param names [Array<String>] udev names for device e.g. "aaaa-bbbb-cccc-dddd"
# for uuid device name
# @param key [String] storage key for given udev mapping see UDEV_MAPPING
# @param device [String] kernel name e.g. "/dev/sda"
# @example
Expand Down Expand Up @@ -204,7 +213,7 @@ def map_devices
def cache_valid?
return false unless @all_devices

# bnc#594482 - check if cache do not contain final uuids and recreate it when no new one can appear
# bnc#594482 - check if cache do not contain final uuids and recreate it when it is stable
if Yast::Mode.installation && !@uuids_stable
# recreate cache if uuids are stable now
return false unless uuid_may_appear?
Expand Down

0 comments on commit e02a185

Please sign in to comment.