Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2014-10-14 07:09:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2014-10-05 20:27:28.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new/yast2-bootloader.changes 2014-10-14 07:09:14.000000000 +0200 @@ -1,0 +2,7 @@ +Tue Oct 7 09:08:07 UTC 2014 - [email protected] + +- keep user selection for password (bnc#900026) +- fix build on ppc +- 3.1.101 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-3.1.100.tar.bz2 New: ---- yast2-bootloader-3.1.101.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.gyJnLa/_old 2014-10-14 07:09:15.000000000 +0200 +++ /var/tmp/diff_new_pack.gyJnLa/_new 2014-10-14 07:09:15.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.100 +Version: 3.1.101 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-bootloader-3.1.100.tar.bz2 -> yast2-bootloader-3.1.101.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/package/yast2-bootloader.changes new/yast2-bootloader-3.1.101/package/yast2-bootloader.changes --- old/yast2-bootloader-3.1.100/package/yast2-bootloader.changes 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/package/yast2-bootloader.changes 2014-10-13 11:02:12.000000000 +0200 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Oct 7 09:08:07 UTC 2014 - [email protected] + +- keep user selection for password (bnc#900026) +- fix build on ppc +- 3.1.101 + +------------------------------------------------------------------- Tue Sep 30 09:30:52 UTC 2014 - [email protected] - use short product name to avoid truncated text on small diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/package/yast2-bootloader.spec new/yast2-bootloader-3.1.101/package/yast2-bootloader.spec --- old/yast2-bootloader-3.1.100/package/yast2-bootloader.spec 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/package/yast2-bootloader.spec 2014-10-13 11:02:12.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.100 +Version: 3.1.101 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/clients/bootloader_finish.rb new/yast2-bootloader-3.1.101/src/clients/bootloader_finish.rb --- old/yast2-bootloader-3.1.100/src/clients/bootloader_finish.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/clients/bootloader_finish.rb 2014-10-13 11:02:12.000000000 +0200 @@ -150,10 +150,6 @@ # Install bootloader (always, see #23018) # should also set Misc::boot_msg appropriate - # FIXME: this is the plan B solution, try to solve plan A in - # BootCommon.ycp:CreateLinuxSection() (line 435) - # resolve symlinks in kernel and initrd paths - # In Mode::update(), the configuration is not yet read (for some # unresearched reason). Therefore, for Mode::update(), there is another # call of ResolveSymlinksInSections() after a Read() in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/include/bootloader/grub2/misc.rb new/yast2-bootloader-3.1.101/src/include/bootloader/grub2/misc.rb --- old/yast2-bootloader-3.1.100/src/include/bootloader/grub2/misc.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/include/bootloader/grub2/misc.rb 2014-10-13 11:02:12.000000000 +0200 @@ -267,9 +267,10 @@ "Creating backup of boot sectors of %1", disks_to_rewrite ) - Builtins.foreach(disks_to_rewrite) do |device| - ::Bootloader::BootRecordBackup.create_for(device) + backups = disks_to_rewrite.map do |d| + ::Bootloader::BootRecordBackup.new(d) end + backups.each(&:write) end ret = true # if the bootloader stage 1 is not installed in the MBR, but @@ -895,7 +896,6 @@ !# ! haskey( BootCommon::globals, "boot_mbr_md" ) && Builtins.haskey(BootCommon.globals, "boot_custom") grub_DetectDisks - BootCommon.del_parts = BootStorage.getPartitionList(:deleted, "grub") # check whether edd is loaded; if not: load it lsmod_command = "lsmod | grep edd" Builtins.y2milestone("Running command %1", lsmod_command) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/include/bootloader/grub2/options.rb new/yast2-bootloader-3.1.101/src/include/bootloader/grub2/options.rb --- old/yast2-bootloader-3.1.100/src/include/bootloader/grub2/options.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/include/bootloader/grub2/options.rb 2014-10-13 11:02:12.000000000 +0200 @@ -327,20 +327,14 @@ end def grub2_pwd_init(widget) - passwd = GRUB2Pwd.new.used? - if passwd - UI.ChangeWidget(Id(:use_pas), :Value, true) - UI.ChangeWidget(Id(:pw1), :Enabled, true) - UI.ChangeWidget(Id(:pw1), :Value, MASKED_PASSWORD) - UI.ChangeWidget(Id(:pw2), :Enabled, true) - UI.ChangeWidget(Id(:pw2), :Value, MASKED_PASSWORD) - else - UI.ChangeWidget(Id(:use_pas), :Value, false) - UI.ChangeWidget(Id(:pw1), :Enabled, false) - UI.ChangeWidget(Id(:pw1), :Value, "") - UI.ChangeWidget(Id(:pw2), :Enabled, false) - UI.ChangeWidget(Id(:pw2), :Value, "") - end + # read state on disk only if not already set by user (bnc#900026) + password_used = password == "" ? GRUB2Pwd.new.used? : password + value = password_used ? MASKED_PASSWORD : "" + UI.ChangeWidget(Id(:use_pas), :Value, password_used) + UI.ChangeWidget(Id(:pw1), :Enabled, password_used) + UI.ChangeWidget(Id(:pw1), :Value, value) + UI.ChangeWidget(Id(:pw2), :Enabled, password_used) + UI.ChangeWidget(Id(:pw2), :Value, value) end def Grub2Options diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/include/bootloader/routines/global_widgets.rb new/yast2-bootloader-3.1.101/src/include/bootloader/routines/global_widgets.rb --- old/yast2-bootloader-3.1.100/src/include/bootloader/routines/global_widgets.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/include/bootloader/routines/global_widgets.rb 2014-10-13 11:02:12.000000000 +0200 @@ -149,7 +149,6 @@ "Proceed?\n" ) ) - Ops.set(BootCommon.other_bl, old_bl, Bootloader.Export) BootCommon.setLoaderType("none") BootCommon.location_changed = true end @@ -157,7 +156,6 @@ end if ["grub2", "grub2-efi"].include? (new_bl) - Ops.set(BootCommon.other_bl, old_bl, Bootloader.Export) BootCommon.setLoaderType(new_bl) Bootloader.Propose BootCommon.location_changed = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/include/bootloader/routines/misc.rb new/yast2-bootloader-3.1.101/src/include/bootloader/routines/misc.rb --- old/yast2-bootloader-3.1.100/src/include/bootloader/routines/misc.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/include/bootloader/routines/misc.rb 2014-10-13 11:02:12.000000000 +0200 @@ -130,79 +130,26 @@ # @return [Array] device names def GetBootloaderDevices ret = [] - if Ops.get(@globals, "boot_boot", "false") == "true" - ret = Builtins.add(ret, BootStorage.BootPartitionDevice) + if @globals["boot_boot"] == "true" + ret << BootStorage.BootPartitionDevice end - if Ops.get(@globals, "boot_root", "false") == "true" - ret = Builtins.add(ret, BootStorage.RootPartitionDevice) + if @globals["boot_root"] == "true" + ret << BootStorage.RootPartitionDevice end - if Ops.get(@globals, "boot_mbr", "false") == "true" - ret = Builtins.add(ret, @mbrDisk) + if @globals["boot_mbr"] == "true" + ret << @mbrDisk end - if Builtins.haskey(@globals, "boot_extended") && - Ops.get(@globals, "boot_extended", "false") == "true" - ret = Builtins.add(ret, BootStorage.ExtendedPartitionDevice) + if @globals["boot_extended"] == "true" + ret << BootStorage.ExtendedPartitionDevice end - if Builtins.haskey(@globals, "boot_custom") - ret = Builtins.add(ret, Ops.get(@globals, "boot_custom", "")) + if @globals["boot_custom"] + ret << @globals["boot_custom"] end - return deep_copy(ret) if Ops.greater_than(Builtins.size(ret), 0) + return ret unless ret.empty? # FIXME: find out what the best value is here: nil, [] or ["/dev/null"] ["/dev/null"] end - # Check if the PBR of the given partition seems to contain a known boot block - # @param [String] device string partition device to check - # @return true if the PBR seems to contain a known boot block - def IsPartitionBootable(device) - #FIXME this is only for grub and should go to BootGRUB - # use examineMBR to analyze PBR (partition boot record): - # examineMBR returns "* stage1" when it finds the signature - # of some stage1 bootloader - result = examineMBR(device) - if result == "grub" - return true - else - return false - end - end - - # Get the list of particular kernel parameters - # @param [String] line string the whole kernel command line - # @return a list of the kernel parameters split each separaterlly - def ListKernelParamsInLine(line) - # FIXME this function is really similar to code in Kernel.ycp - cmdlist = [] - parse_index = 0 - in_quotes = false - after_backslash = false - current_param = "" - while Ops.less_than(parse_index, Builtins.size(line)) - current_char = Builtins.substring(line, parse_index, 1) - in_quotes = !in_quotes if current_char == "\"" && !after_backslash - if current_char == " " && !in_quotes - cmdlist = Builtins.add(cmdlist, current_param) - current_param = "" - else - current_param = Ops.add(current_param, current_char) - end - if current_char == "\\" - after_backslash = true - else - after_backslash = false - end - parse_index = Ops.add(parse_index, 1) - end - cmdlist = Builtins.add(cmdlist, current_param) - cmdlist = Builtins.maplist(cmdlist) do |c| - if Builtins.regexpmatch(c, "^[^=]+=") - c = Builtins.regexpsub(c, "^([^=]+)=", "\\1") - end - c - end - deep_copy(cmdlist) - end - # get kernel parameter from kernel command line # @param [String] line string original line # @param [String] key string parameter key @@ -211,13 +158,10 @@ def getKernelParamFromLine(line, key) # FIXME this doesn't work with quotes and spaces res = "false" - params = Builtins.splitstring(line, " ") - params = Builtins.filter(params) { |p| p != "" } - Builtins.foreach(params) do |p| - l = Builtins.filter(Builtins.splitstring(p, "=")) do |e| - e != " " && e != "" - end - res = Ops.get(l, 1, "true") if Ops.get(l, 0, "") == key + params = line.split(" ").reject(&:empty?) + params.each do |p| + l = p.split("=") + res = l[1] || "true" if l[0] == key end res end @@ -408,66 +352,39 @@ # @param [String] device string device to rewrite MBR to # @return [Boolean] true on success def restoreMBR(device) - device_file = Builtins.mergestring(Builtins.splitstring(device, "/"), "_") - if Ops.less_or_equal( - SCR.Read( - path(".target.size"), - Builtins.sformat( - "/var/lib/YaST2/backup_boot_sectors/%1", - device_file - ) - ), - 0 - ) + backup = ::Bootloader::BootRecordBackup.new(device) + begin + backup.restore + rescue ::Bootloader::BootRecordBackup::Missing Report.Error("Can't restore MBR. No saved MBR found") return false end - # added fix 446 -> 440 for Vista booting problem bnc #396444 - ret = Convert.to_integer( - SCR.Execute( - path(".target.bash"), - Builtins.sformat( - "/bin/dd of=%1 if=/var/lib/YaST2/backup_boot_sectors/%2 bs=440 count=1", - device, - device_file - ) - ) - ) - ret == 0 end # Get map of swap partitions # @return a map where key is partition name and value its size def getSwapPartitions - #FIXME use cache of storage map + # FIXME move to boot storage tm = Storage.GetTargetMap - installation = Mode.installation ret = {} - Builtins.foreach(tm) do |k, v| - cyl_size = Ops.get_integer(v, "cyl_size", 0) - partitions = Ops.get_list(v, "partitions", []) - partitions = Builtins.filter(partitions) do |p| - Ops.get_string(p, "mount", "") == "swap" && - !Ops.get_boolean(p, "delete", false) + tm.each do |k, v| + cyl_size = v["cyl_size"] || 0 + partitions = v["partitions"] || [] + partitions = partitions.select do |p| + p["mount"] == "swap" && !p["delete"] end - Builtins.foreach(partitions) do |s| + partitions.each do |s| # bnc#577127 - Encrypted swap is not properly set up as resume device - dev = "" - if Ops.get_string(s, "crypt_device", "") != nil && - Ops.get_string(s, "crypt_device", "") != "" - dev = Ops.get_string(s, "crypt_device", "") + if s["crypt_device"] && !s["crypt_device"].empty? + dev = s["crypt_device"] else - dev = Ops.get_string(s, "device", "") + dev = s["device"] end - Ops.set( - ret, - dev, - Ops.multiply(Ops.get_integer(s, ["region", 1], 0), cyl_size) - ) + ret[dev] = Ops.get_integer(s, ["region", 1], 0) * cyl_size end end Builtins.y2milestone("Available swap partitions: %1", ret) - deep_copy(ret) + ret end @@ -559,32 +476,6 @@ elsif Builtins.search(getBootPartition, "/dev/evms/") == 0 Builtins.y2milestone("Cannot install bootloader on EVMS") return false - # LVM - elsif !Ops.is_integer?(Ops.get(dev, "nr", 0)) - lt = getLoaderType(false) - if lt != "grub2" && lt != "grub2-efi" - Builtins.y2milestone("Cannot install bootloader %1 on LVM", lt) - return false - end - else - tm = Storage.GetTargetMap - dm = Ops.get_map(tm, Ops.get_string(dev, "disk", ""), {}) - parts = Ops.get_list(dm, "partitions", []) - info = {} - Builtins.foreach(parts) do |p| - if Ops.get_string(p, "device", "") == - BootStorage.BootPartitionDevice - info = deep_copy(p) - end - end - - if Ops.get(info, "used_fs") == :btrfs - lt = getLoaderType(false) - if lt != "grub2" && lt != "grub2-efi" - Builtins.y2milestone("Cannot install bootloader %1 on btrfs", lt) - return false - end - end end return true @@ -789,12 +680,6 @@ "" end - # FATE #303548 - Grub: limit device.map to devices detected by BIOS Int 13 - # Function select boot device - disk - # - # @return [String] name of boot device - disk - - # FATE #110038: Serial console # Function build value for console from: # @param [String] unit no of console diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/lib/bootloader/boot_record_backup.rb new/yast2-bootloader-3.1.101/src/lib/bootloader/boot_record_backup.rb --- old/yast2-bootloader-3.1.100/src/lib/bootloader/boot_record_backup.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/lib/bootloader/boot_record_backup.rb 2014-10-13 11:02:12.000000000 +0200 @@ -3,92 +3,136 @@ Yast.import "BootCommon" module Bootloader - # Responsibility of class is to manage backups of MBR, respective PBR of disk, + # Responsibility of class is to manage backup of MBR, respective PBR of disk, # respective partition. class BootRecordBackup - class << self - include Yast::Logger - BASH_PATH = Yast::Path.new(".target.bash") - BASH_OUTPUT_PATH = Yast::Path.new(".target.bash_output") - MAIN_BACKUP_DIR = "/var/lib/YaST2/backup_boot_sectors/" - KEPT_BACKUPS = 10 - - # Creates backup of MBR or PBR of given device. - # Backup is stored in /var/lib/YaST2/backup_boot_sectors, in logs - # directory and if it is MBR of primary disk, then also in /boot/backup_mbr - def create_for(device) - device_file = device.tr("/", "_") - device_file_path = MAIN_BACKUP_DIR + device_file - - Yast::SCR.Execute(BASH_PATH, "mkdir -p #{MAIN_BACKUP_DIR}") - - # check if file exists - if Yast::SCR.Read(Yast::Path.new(".target.size"), device_file_path) > 0 - # move it so we do not overwrite it - change_date = formated_file_ctime(device_file_path) + include Yast::Logger + BASH_PATH = Yast::Path.new(".target.bash") + BASH_OUTPUT_PATH = Yast::Path.new(".target.bash_output") + TARGET_SIZE = Yast::Path.new(".target.size") + MAIN_BACKUP_DIR = "/var/lib/YaST2/backup_boot_sectors/" + KEPT_BACKUPS = 10 + + attr_reader :device + + # Exception from this class + class Error < RuntimeError;end + + # Exception used to indicate that backup missing, so any action with it is + # not possible + class Missing < Error + def initialize + super "Backup for boot record missing." + end + end + + + + # Create backup handling class for given device + # @param device[String] expect kernel name of device like "/dev/sda" + def initialize(device) + @device = device + end + + # Write fresh backup of MBR or PBR of given device. + # Backup is stored in /var/lib/YaST2/backup_boot_sectors, in logs + # directory and if it is MBR of primary disk, then also in /boot/backup_mbr + def write + Yast::SCR.Execute(BASH_PATH, "mkdir -p #{MAIN_BACKUP_DIR}") + + if exists? + rotate + reduce_backup_count + end + + copy_br(device, device_file_path) + + # save MBR to yast2 log directory + logs_path = "/var/log/YaST2/" + device_file + copy_br(device, logs_path) + + if device == Yast::BootCommon.mbrDisk + copy_br(device, "/boot/backup_mbr") + + # save thinkpad MBR + if Yast::BootCommon.ThinkPadMBR(device) + device_file_path_thinkpad = device_file_path + "thinkpadMBR" + log.info("Backup thinkpad MBR") Yast::SCR.Execute( BASH_PATH, - Yast::Builtins.sformat("/bin/mv %1 %1-%2", device_file_path, change_date) + "cp #{device_file_path} #{device_file_path_thinkpad}", ) - - cleanup_backups(device_file) end + end + end - copy_br(device, device_file_path) + # Restore backup + # @raise [::Bootloader::BootRecordBackup::Missing] if backup missing + # @return true if copy is successful + def restore + raise Missing.new unless exists? + + # Copy only 440 bytes for Vista booting problem bnc #396444 + # and also to not destroy partition table + copy_br(device_file_path, device, bs: 440) == 0 + end - # save MBR to yast2 log directory - logs_path = "/var/log/YaST2/" + device_file - copy_br(device, logs_path) - - if device == Yast::BootCommon.mbrDisk - copy_br(device, "/boot/backup_mbr") - - # save thinkpad MBR - if Yast::BootCommon.ThinkPadMBR(device) - device_file_path_thinkpad = device_file_path + "thinkpadMBR" - log.info("Backup thinkpad MBR") - Yast::SCR.Execute( - BASH_PATH, - "cp #{device_file_path} #{device_file_path_thinkpad}", - ) - end - end - end + private - private - # Get last change time of file - # @param [String] filename string name of file - # @return [String] last change date as YYYY-MM-DD-HH-MM-SS - def formated_file_ctime(filename) - stat = Yast::SCR.Read(Yast::Path.new(".target.stat"), filename) - ctime = stat["ctime"] or raise "Cannot get modification time of file #{filename}" - time = DateTime.strptime(ctime.to_s, "%s") + def device_file + @device_file ||= @device.tr("/", "_") + end - time.strftime("%Y-%m-%d-%H-%M-%S") - end + def device_file_path + @device_file_path ||= MAIN_BACKUP_DIR + device_file + end + + def exists? + Yast::SCR.Read(TARGET_SIZE, device_file_path) > 0 + end + + # Get last change time of file + # @param [String] filename string name of file + # @return [String] last change date as YYYY-MM-DD-HH-MM-SS + def formated_file_ctime(filename) + stat = Yast::SCR.Read(Yast::Path.new(".target.stat"), filename) + ctime = stat["ctime"] or raise(Error, "Cannot get modification time of file #{filename}") + time = DateTime.strptime(ctime.to_s, "%s") + + time.strftime("%Y-%m-%d-%H-%M-%S") + end + + def copy_br(device, target_path, bs: 512) + Yast::SCR.Execute( + BASH_PATH, + "/bin/dd if=#{device} of=#{target_path} bs=#{bs} count=1 2>&1" + ) + end - def copy_br(device, target_path) + def reduce_backup_count + files = Yast::SCR.Read(Yast::Path.new(".target.dir"), MAIN_BACKUP_DIR) + # clean only backups for this device + files.select! do |c| + c =~ /#{Regexp.escape(device_file)}-\d{4}(?:-\d{2}){5}/ + end + # and sort so we can benefit from its ascending order + files.sort! + files.drop(KEPT_BACKUPS).each do |file_name| Yast::SCR.Execute( - BASH_PATH, - "/bin/dd if=#{device} of=#{target_path} bs=512 count=1 2>&1" + Yast::Path.new(".target.remove"), + MAIN_BACKUP_DIR + file_name ) end + end - def cleanup_backups(device_file) - files = Yast::SCR.Read(Yast::Path.new(".target.dir"), MAIN_BACKUP_DIR) - # clean only backups for this device - files.select! do |c| - c =~ /#{Regexp.escape(device_file)}-\d{4}(?:-\d{2}){5}/ - end - # and sort so we can benefit from its ascending order - files.sort! - files.drop(KEPT_BACKUPS).each do |file_name| - Yast::SCR.Execute( - Yast::Path.new(".target.remove"), - MAIN_BACKUP_DIR + file_name - ) - end - end + def rotate + # move it so we do not overwrite it + change_date = formated_file_ctime(device_file_path) + Yast::SCR.Execute( + BASH_PATH, + "/bin/mv %{path} %{path}-%{date}" % + { path: device_file_path, date: change_date } + ) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/lib/bootloader/grub2base.rb new/yast2-bootloader-3.1.101/src/lib/bootloader/grub2base.rb --- old/yast2-bootloader-3.1.100/src/lib/bootloader/grub2base.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/lib/bootloader/grub2base.rb 2014-10-13 11:02:12.000000000 +0200 @@ -78,12 +78,10 @@ end # Reset bootloader settings - # @param [Boolean] init boolean true to repropose also device map + # @param [Boolean] unused def Reset(init) return if Mode.autoinst - BootCommon.Reset(init) - - nil + BootCommon.Reset end def Dialogs @@ -137,9 +135,6 @@ BootCommon.globals["distributor"] = Product.name end - - BootCommon.kernelCmdLine ||= Kernel.GetCmdLine - # Propose bootloader serial settings from kernel cmdline during install (bnc#862388) serial = BootCommon.GetSerialFromAppend diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/modules/BootArch.rb new/yast2-bootloader-3.1.101/src/modules/BootArch.rb --- old/yast2-bootloader-3.1.100/src/modules/BootArch.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/modules/BootArch.rb 2014-10-13 11:02:12.000000000 +0200 @@ -57,18 +57,6 @@ end ret = Ops.add(ret, "splash=silent quiet showopts") return ret - elsif Arch.ia64 - ret = kernel_cmdline != "" ? Ops.add(kernel_cmdline, " ") : "" - ret = Ops.add(Ops.add(ret, features), " ") if features != "" - ret = Ops.add(ret, "splash=silent quiet") - - # FIXME: this does not belong here, it cannot be tracked or maintained - # and is undocumented - # on SGI Altix change kernel default hash tables sizes - if SCR.Read(path(".target.stat"), "/proc/sgi_sn") != {} - ret = Ops.add(ret, " thash_entries=2097152") - end - return ret elsif Arch.s390 file_desc = Convert.convert( SCR.Execute(path(".target.bash_output"), "echo $TERM"), @@ -102,8 +90,6 @@ ret = "showopts apm=off noresume nosmp maxcpus=0 edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset" elsif Arch.x86_64 ret = "showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset" - elsif Arch.ia64 - ret = "nohalt noresume powersaved=off" elsif Arch.s390 ret = Ops.add(DefaultKernelParams(""), " noresume") else @@ -134,13 +120,13 @@ # Is VGA parameter setting available # @return true if vga= can be set def VgaAvailable - Arch.i386 || Arch.x86_64 || Arch.ia64 + Arch.i386 || Arch.x86_64 end # Is Suspend to Disk available? # @return true if STD is available def ResumeAvailable - Arch.i386 || Arch.x86_64 || Arch.ia64 || Arch.s390 + Arch.i386 || Arch.x86_64 || Arch.s390 end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/modules/BootCommon.rb new/yast2-bootloader-3.1.101/src/modules/BootCommon.rb --- old/yast2-bootloader-3.1.100/src/modules/BootCommon.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/modules/BootCommon.rb 2014-10-13 11:02:12.000000000 +0200 @@ -23,6 +23,13 @@ module Yast class BootCommonClass < Module + + SUPPORTED_BOOTLOADERS = [ + "none", # allow user to manage bootloader itself + "grub2", + "grub2-efi" + ] + def main Yast.import "Pkg" Yast.import "UI" @@ -34,9 +41,6 @@ Yast.import "Mode" Yast.import "PackageSystem" Yast.import "Storage" - Yast.import "String" - Yast.import "Popup" - Yast.import "Package" Yast.import "PackagesProposal" Yast.import "BootStorage" @@ -45,9 +49,6 @@ # General bootloader settings - # map of global options and types for new perl-Bootloader interface - @global_options = {} - # map of global options and values @globals = {} @@ -102,9 +103,6 @@ # values are :add, :remove or nil, means do nothing @pmbr_action = nil - # Kernel parameters at previous detection - @kernelCmdLine = "" - # were settings changed (== true) @changed = false @@ -115,33 +113,16 @@ @loader_type = nil @secure_boot = nil - # sysconfig variables - - # installation proposal help variables - - # List of partitions deleted in primary proposal - @del_parts = [] - - # variables for storing data - # saving mode setting functions # map of save mode settings @write_settings = {} - # summary dialog state - - # ui help variables - - @additional_failsafe_params = "" # other variables - # Settings of other bootloaders used when switching bootloader - @other_bl = {} - # bootloader installation variables # Was the activate flag changed by user? @@ -157,16 +138,6 @@ @was_read = false # Was bootloader location changed? (== true) @location_changed = false - # Were configuration files manually edited and chamged? - @files_edited = false - # time of last change of partitioning - @partitioning_last_change = 0 - - # List of all supported bootloaders - @bootloaders = [ - "grub2", - "grub2-efi" - ] # FATE#305008: Failover boot configurations for md arrays with redundancy # if true enable redundancy for md array @@ -180,190 +151,6 @@ Yast.include self, "bootloader/routines/lib_iface.rb" end - # interface to bootloader library - - # Create section for linux kernel - # @param [String] title string the section name to create (untranslated) - # @return a map describing the section - def CreateLinuxSection(title) - ret = { - "name" => title, - "original_name" => title, - "type" => "image", - "__auto" => true, - "__changed" => true - } - - resume = BootArch.ResumeAvailable ? getLargestSwapPartition : "" - # try to use label or udev id for device name... FATE #302219 - if resume != "" && resume != nil - resume = ::Bootloader::DeviceMapping.to_mountby_device(resume) - end - - - # FIXME: - # This only works in the installed system (problem with GetFinalKernel()), - # in all other cases we use the symlinks. - - kernel_fn = "" - initrd_fn = "" - - if Mode.normal - # Find out the file names of the "real" kernel and initrd files, with - # version etc. pp. whatever (currently version-flavor) attached. - # FIXME: also do this for xen and xenpae kernels as found below - # - # Note: originally, we wanted to find out the kernel file names during - # installation proposal when the files are not yet installed. But not - # all the necessary interfaces work at that time. Now, this variant is - # only run in the "running system", and could as well look at the - # installed files. - # - - # First of all, we have to initialize the RPM database - Pkg.TargetInit( - "/", # installed system - false - ) # don't create a new RPM database - - # Then, get the file names in the "selected" kernel package, - kernel_package = Kernel.ComputePackage - files = Pkg.PkgGetFilelist(kernel_package, :installed) - Builtins.y2milestone( - "kernel package %1 has these files: %2", - kernel_package, - files - ) - - # then find the first file that matches the arch-dependent kernel file - # name prefix and the initrd filename prefix. - kernel_prefix = Ops.add("/boot/", Kernel.GetBinary) - initrd_prefix = "/boot/initrd" - - files_filtered = Builtins.filter(files) do |file| - Builtins.substring(file, 0, Builtins.size(kernel_prefix)) == kernel_prefix - end - - - # Sort the filtered files, thus the image strings by length, the big ones - # at the beginning, the small ones at the end of the list. - # So, the first element of the sorted list files_filtered is the image string - # containing the version and flavor. - files_filtered = Builtins.sort(files_filtered) do |kbig, ksmall| - Ops.greater_than(Builtins.size(kbig), Builtins.size(ksmall)) - end - - kernel_fn = Ops.get(files_filtered, 0, "") - - files_filtered = Builtins.filter(files) do |file| - Builtins.substring(file, 0, Builtins.size(initrd_prefix)) == initrd_prefix && - !Builtins.regexpmatch(file, "-kdump$") - end - - # Sort the filtered files, thus the initrd strings by length, the big ones - # at the beginning, the small ones at the end of the list. - # So, the first element of the sorted list files_filtered is the initrd string - # containing the version and flavor. - files_filtered = Builtins.sort(files_filtered) do |ibig, ismall| - Ops.greater_than(Builtins.size(ibig), Builtins.size(ismall)) - end - - initrd_fn = Ops.get(files_filtered, 0, "") - - kernel_fn = "/boot/vmlinuz" if kernel_fn == "" || kernel_fn == nil - - initrd_fn = "/boot/initrd" if initrd_fn == "" || initrd_fn == nil - - # read commandline options for kernel - cmd = Convert.convert( - SCR.Read(path(".proc.cmdline")), - :from => "any", - :to => "list <string>" - ) - - vga = nil - - # trying to find "vga" option - Builtins.foreach(cmd) do |key| - vga = key if Builtins.issubstring(key, "vga=") - Builtins.y2milestone("key: %1", key) - end - Builtins.y2milestone("vga from command line: %1", vga) - mode = [] - - # split vga=value - if vga != nil && vga != "" - mode = Builtins.splitstring(Builtins.tostring(vga), "=") - end - - vgamode = nil - - # take value if exist - if Ops.greater_than(Builtins.size(mode), 1) && - Ops.get(mode, 0, "") == "vga" - vgamode = Ops.get(mode, 1) - end - - # add value of vga into proposal (if exist) - if vgamode != nil && vgamode != "" - Ops.set(ret, "vgamode", vgamode) - Builtins.y2milestone("vga mode: %1", vgamode) - end - else - # the links are shown in the proposal; at the end of an installation, - # in bootloader_finish, they will be resolved to the real filenames - kernel_fn = Ops.add("/boot/", Kernel.GetBinary) - initrd_fn = "/boot/initrd" - end - # done: kernel_fn and initrd_fn are the results - Builtins.y2milestone("kernel_fn: %1 initrd_fn: %2", kernel_fn, initrd_fn) - - ret = Convert.convert( - Builtins.union( - ret, - { - "image" => kernel_fn, - "initrd" => initrd_fn, - # try to use label or udev id for device name... FATE #302219 - "root" => ::Bootloader::DeviceMapping.to_mountby_device( - BootStorage.RootPartitionDevice - ), - "append" => title == "failsafe" ? - BootArch.FailsafeKernelParams : - BootArch.DefaultKernelParams(resume), - "__devs" => [ - BootStorage.BootPartitionDevice, - BootStorage.RootPartitionDevice - ] - } - ), - :from => "map", - :to => "map <string, any>" - ) - if BootArch.VgaAvailable && Kernel.GetVgaType != "" - # B#352020 kokso: - Graphical failsafe mode - #if (title == "failsafe") - # ret["vga"] = "normal"; - #else - Ops.set(ret, "vgamode", Kernel.GetVgaType) - - # B#352020 end - end - if title == "xen" - Ops.set(ret, "type", "xen") - Ops.set(ret, "xen_append", "") - - Ops.set(ret, "xen", "/boot/xen.gz") - Ops.set( - ret, - "image", - Ops.add(Ops.add("/boot/", Kernel.GetBinary), "-xen") - ) - Ops.set(ret, "initrd", "/boot/initrd-xen") - end - deep_copy(ret) - end - # generic versions of bootloader-specific functions # Export bootloader settings to a map @@ -428,11 +215,9 @@ end # Reset bootloader settings - # @param [Boolean] init boolean true to repropose also device map - def Reset(init) + def Reset @sections = [] @globals = {} - # DetectDisks (); @activate = false @activate_changed = false @was_proposed = false @@ -464,10 +249,7 @@ return true if bl == "none" # bnc#589433 - Install grub into root (/) partition gives error - if Ops.get(@globals, "boot_custom") == "" && - Builtins.haskey(@globals, "boot_custom") - @globals = Builtins.remove(@globals, "boot_custom") - end + @globals.delete("boot_custom") if @globals["boot_custom"] == "" # FIXME: give mountby information to perl-Bootloader (or define some # better interface), so that perl-Bootloader can use mountby device names @@ -498,26 +280,22 @@ Builtins.y2milestone("device map after mapping %1", my_device_mapping) if VerifyMDArray() - if @enable_md_array_redundancy != true && - Builtins.haskey(my_globals, "boot_md_mbr") - my_globals = Builtins.remove(my_globals, "boot_md_mbr") - end - if @enable_md_array_redundancy == true && - !Builtins.haskey(my_globals, "boot_md_mbr") - Ops.set(my_globals, "boot_md_mbr", BootStorage.addMDSettingsToGlobals) + if !@enable_md_array_redundancy + my_globals.delete("boot_md_mbr") + elsif !my_globals["boot_md_mbr"] + my_globals["boot_md_mbr"] = BootStorage.addMDSettingsToGlobals end else - if Builtins.haskey(@globals, "boot_md_mbr") - my_globals = Builtins.remove(my_globals, "boot_md_mbr") - end + my_globals.delete("boot_md_mbr") end + Builtins.y2milestone("SetSecureBoot %1", @secure_boot) - ret = ret && SetSecureBoot(@secure_boot) - ret = ret && DefineMultipath(BootStorage.multipath_mapping) - ret = ret && SetDeviceMap(my_device_mapping) - ret = ret && SetSections(@sections) - ret = ret && SetGlobal(my_globals) - ret = ret && CommitSettings() if flush + ret &&= SetSecureBoot(@secure_boot) + ret &&= DefineMultipath(BootStorage.multipath_mapping) + ret &&= SetDeviceMap(my_device_mapping) + ret &&= SetSections(@sections) + ret &&= SetGlobal(my_globals) + ret &&= CommitSettings() if flush # write settings to /etc/sysconfig/bootloader WriteToSysconf(false) @@ -564,36 +342,26 @@ # @param [String] loader_type string loader type to initialize def setCurrentLoaderAttribs(loader_type) Builtins.y2milestone("Setting attributes for bootloader %1", loader_type) - # testsuite hack - return if Mode.test - if loader_type == nil + if !loader_type Builtins.y2error("Setting loader type to nil, this is wrong") return end # FIXME: this should be blInitializer in switcher.ycp for code cleanness # and understandability - if Ops.get(@bootloader_attribs, [loader_type, "initializer"]) != nil + boot_initializer = Ops.get(@bootloader_attribs, [loader_type, "initializer"]) + if boot_initializer Builtins.y2milestone("Running bootloader initializer") - toEval = Convert.convert( - Ops.get(@bootloader_attribs, [loader_type, "initializer"]), - :from => "any", - :to => "void ()" - ) - toEval.call + boot_initializer.call Builtins.y2milestone("Initializer finished") else Builtins.y2error("No initializer found for >>%1<<", loader_type) @current_bootloader_attribs = {} end - @current_bootloader_attribs = Convert.convert( - Builtins.union( - @current_bootloader_attribs, - Builtins.eval(Ops.get(@bootloader_attribs, loader_type, {})) - ), - :from => "map", - :to => "map <string, any>" + @current_bootloader_attribs = Builtins.union( + @current_bootloader_attribs, + Builtins.eval(Ops.get(@bootloader_attribs, loader_type, {})) ) nil @@ -603,21 +371,18 @@ # @param [String] loader string name of loader to check # @return [String] the loader name if supported, "none" otherwise def SupportedLoader(loader) - return loader if Builtins.contains(@bootloaders, loader) - "none" + SUPPORTED_BOOTLOADERS.include?(loader) ? loader : "none" end # Get currently used bootloader, detect if not set yet # @param [Boolean] recheck boolean force checking bootloader # @return [String] botloader type def getLoaderType(recheck) - return @loader_type if !recheck && @loader_type != nil + return @loader_type if !recheck && @loader_type # read bootloader to use from disk if Mode.update || Mode.normal || Mode.repair - @loader_type = Convert.to_string( - SCR.Read(path(".sysconfig.bootloader.LOADER_TYPE")) - ) - if @loader_type != nil && @loader_type != "" + @loader_type = SCR.Read(path(".sysconfig.bootloader.LOADER_TYPE")) + if @loader_type && !@loader_type.empty? @loader_type = "grub2" if @loader_type == "s390" Builtins.y2milestone( "Sysconfig bootloader is %1, using", @@ -633,23 +398,11 @@ end end # detect bootloader - @loader_type = Convert.to_string(SCR.Read(path(".probe.boot_arch"))) - @loader_type = "grub2" if @loader_type == "s390" - # ppc uses grub2 (fate #315753) - @loader_type = "grub2" if @loader_type == "ppc" - # suppose grub2 should superscede grub .. - @loader_type = "grub2" if @loader_type == "grub" + @loader_type = SCR.Read(path(".probe.boot_arch")) + # s390,ppc and also old grub now uses grub2 (fate #315753) + @loader_type = "grub2" if ["s390", "ppc", "grub"].include? @loader_type + Builtins.y2milestone("Bootloader detection returned %1", @loader_type) - # lslezak@: Arch::is_xenU() returns true only in PV guest - if Arch.is_uml || Arch.is_xenU - # y2milestone ("Not installing any bootloader for UML/Xen PV"); - # loader_type = "none"; - # bnc #380982 - pygrub cannot boot kernel - # added installation of bootloader - Builtins.y2milestone( - "It is XEN domU and the bootloader should be installed" - ) - end if (Arch.i386 || Arch.x86_64) && Linuxrc.InstallInf("EFI") == "1" # use grub2-efi as default bootloader for x86_64/i386 EFI @loader_type = "grub2-efi" @@ -665,59 +418,54 @@ # set type of bootloader # @param [String] bootloader string type of bootloader def setLoaderType(bootloader) - if bootloader == nil + if !bootloader Builtins.y2milestone("Resetting the loader type") @loader_type = nil end Builtins.y2milestone("Setting bootloader to >>%1<<", bootloader) - if bootloader != nil && Builtins.contains(@bootloaders, bootloader) && - !Mode.test - # added kexec-tools fate# 303395 - # if kexec option is equal 0 or running live installation - # doesn't install kexec-tools - - bootloader_packages = Ops.get_list( - @bootloader_attribs, - [bootloader, "required_packages"], - [] - ) - if !Mode.live_installation && Linuxrc.InstallInf("kexec_reboot") != "0" - bootloader_packages = Builtins.add(bootloader_packages, "kexec-tools") - end + raise "Unsupported bootloader '#{bootloader}'" unless SUPPORTED_BOOTLOADERS.include?(bootloader) + + bootloader_packages = Ops.get_list( + @bootloader_attribs, + [bootloader, "required_packages"], + [] + ) - # we need perl-Bootloader-YAML API to communicate with pbl - bootloader_packages << "perl-Bootloader-YAML" + # added kexec-tools fate# 303395 + # if kexec option is equal 0 or running live installation + # doesn't install kexec-tools + if !Mode.live_installation && Linuxrc.InstallInf("kexec_reboot") != "0" + bootloader_packages = Builtins.add(bootloader_packages, "kexec-tools") + end - Builtins.y2milestone("Bootloader packages: %1", bootloader_packages) + # we need perl-Bootloader-YAML API to communicate with pbl + bootloader_packages << "perl-Bootloader-YAML" - # don't configure package manager during autoinstallation preparing - if Mode.normal && !(Mode.config || Mode.repair) - PackageSystem.InstallAll(bootloader_packages) - elsif Stage.initial - bootloader_packages.each do |p| - Builtins.y2milestone("Select bootloader package: %1", p) - PackagesProposal.AddResolvables("yast2-bootloader", :package, [p]) - end + Builtins.y2milestone("Bootloader packages: %1", bootloader_packages) + + # don't configure package manager during autoinstallation preparing + if Mode.normal + PackageSystem.InstallAll(bootloader_packages) + elsif Stage.initial + bootloader_packages.each do |p| + Builtins.y2milestone("Select bootloader package: %1", p) + PackagesProposal.AddResolvables("yast2-bootloader", :package, [p]) end - elsif !Mode.test - Builtins.y2error("Unknown bootloader") end @loader_type = bootloader - setCurrentLoaderAttribs(@loader_type) if @loader_type != nil + setCurrentLoaderAttribs(@loader_type) Builtins.y2milestone("Loader type set") nil end def getSystemSecureBootStatus(recheck) - return @secure_boot if !recheck && @secure_boot != nil + return @secure_boot if !recheck && !@secure_boot.nil? if Mode.update || Mode.normal || Mode.repair - sb = Convert.to_string( - SCR.Read(path(".sysconfig.bootloader.SECURE_BOOT")) - ) + sb = SCR.Read(path(".sysconfig.bootloader.SECURE_BOOT")) - if sb != nil && !sb.empty? + if sb && !sb.empty? @secure_boot = sb == "yes" return @secure_boot end @@ -740,56 +488,35 @@ # @return a list of bootloaders def getBootloaders if Mode.config - return [ - "grub2", - "grub2-efi", - "default", - "none" - ] + # default means bootloader use what it think is the best + return SUPPORTED_BOOTLOADERS + ["default"] end - ret = [ - getLoaderType(false) - ] - if Arch.i386 || Arch.x86_64 - ret = Convert.convert( - Builtins.merge(ret, ["grub2"]), - :from => "list", - :to => "list <string>" - ) - if Arch.x86_64 - ret = Convert.convert( - Builtins.merge(ret, ["grub2-efi"]), - :from => "list", - :to => "list <string>" - ) - end + ret = [getLoaderType(false)] + if Arch.i386 || Arch.x86_64 || Arch.s390 || Arch.ppc + ret << "grub2" end - if Arch.s390 || Arch.ppc - ret = ["grub2"] + if Arch.x86_64 + ret << "grub2-efi" end - # in order not to display it twice when "none" is selected - ret = Builtins.filter(ret) { |l| l != "none" } - ret = Builtins.toset(ret) ret = Builtins.add(ret, "none") - deep_copy(ret) + # avoid double entry for selected one + ret.uniq end # FATE#305008: Failover boot configurations for md arrays with redundancy - # Verify if proposal includes md array with 2 diferent disks + # Verify if proposal includes md array with more diferent disks # - # @return [Boolean] true if there is md array based on 2 disks + # @return [Boolean] true if there is md array based on more disks def VerifyMDArray - ret = false - if Builtins.haskey(@globals, "boot_md_mbr") - md_array = Ops.get(@globals, "boot_md_mbr", "") - disks = Builtins.splitstring(md_array, ",") - disks = Builtins.filter(disks) { |v| v != "" } - if Builtins.size(disks) == 2 - Builtins.y2milestone("boot_md_mbr includes 2 disks: %1", disks) - ret = true + if @globals["boot_md_mbr"] + md_array = @globals["boot_md_mbr"] + disks = md_array.split(",").reject(&:empty?) + if Builtins.size(disks) > 1 + Builtins.y2milestone("boot_md_mbr includes disks: %1", disks) + return true end end - ret + return false end # FIXME just backward compatible interface, call directly BootStorage @@ -797,7 +524,6 @@ BootStorage.Md2Partitions(md_device) end - publish :variable => :global_options, :type => "map <string, any>" publish :variable => :globals, :type => "map <string, string>" publish :variable => :sections, :type => "list <map <string, any>>" publish :variable => :cached_settings_base_data_change_time, :type => "integer" @@ -809,24 +535,18 @@ publish :variable => :backup_mbr, :type => "boolean" publish :variable => :activate, :type => "boolean" publish :variable => :pmbr_action, :type => "symbol" - publish :variable => :kernelCmdLine, :type => "string" publish :variable => :changed, :type => "boolean" - publish :variable => :del_parts, :type => "list <string>" publish :variable => :write_settings, :type => "map" - publish :variable => :other_bl, :type => "map" publish :variable => :activate_changed, :type => "boolean" publish :variable => :save_all, :type => "boolean" publish :variable => :was_proposed, :type => "boolean" publish :variable => :was_read, :type => "boolean" publish :variable => :location_changed, :type => "boolean" - publish :variable => :files_edited, :type => "boolean" - publish :variable => :partitioning_last_change, :type => "integer" publish :variable => :enable_md_array_redundancy, :type => "boolean" publish :function => :getLoaderType, :type => "string (boolean)" publish :function => :getSystemSecureBootStatus, :type => "boolean (boolean)" publish :function => :getBootloaders, :type => "list <string> ()" publish :function => :Summary, :type => "list <string> ()" - publish :function => :CreateLinuxSection, :type => "map <string, any> (string)" publish :function => :UpdateSerialConsole, :type => "string (string, string)" publish :function => :examineMBR, :type => "string (string)" publish :function => :ThinkPadMBR, :type => "boolean (string)" @@ -841,7 +561,6 @@ publish :function => :remapGlobals, :type => "map <string, string> (map <string, string>)" publish :function => :GetBootloaderDevice, :type => "string ()" publish :function => :GetBootloaderDevices, :type => "list <string> ()" - publish :function => :IsPartitionBootable, :type => "boolean (string)" publish :function => :getKernelParamFromLine, :type => "string (string, string)" publish :function => :setKernelParamToLine, :type => "string (string, string, string)" publish :function => :myToInteger, :type => "integer (any)" @@ -876,7 +595,7 @@ publish :function => :Export, :type => "map ()" publish :function => :Import, :type => "boolean (map)" publish :function => :Read, :type => "boolean (boolean, boolean)" - publish :function => :Reset, :type => "void (boolean)" + publish :function => :Reset, :type => "void ()" publish :function => :Propose, :type => "void ()" publish :function => :Save, :type => "boolean (boolean, boolean, boolean)" publish :function => :Update, :type => "void ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/modules/BootGRUB2.rb new/yast2-bootloader-3.1.101/src/modules/BootGRUB2.rb --- old/yast2-bootloader-3.1.100/src/modules/BootGRUB2.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/modules/BootGRUB2.rb 2014-10-13 11:02:12.000000000 +0200 @@ -186,7 +186,6 @@ # def urlLocationSummary Builtins.y2milestone("Prepare url summary for GRUB2") - # FIXME identical code in BootGRUB module line = "<ul>\n<li>" if BootCommon.globals["boot_mbr"] == "true" line << _( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/src/modules/Bootloader.rb new/yast2-bootloader-3.1.101/src/modules/Bootloader.rb --- old/yast2-bootloader-3.1.100/src/modules/Bootloader.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/src/modules/Bootloader.rb 2014-10-13 11:02:12.000000000 +0200 @@ -213,8 +213,6 @@ # BootCommon::setLoaderType (nil); BootCommon.changed = false BootCommon.location_changed = false - # BootCommon::other_bl = $[]; - BootCommon.files_edited = false BootCommon.write_settings = {} blReset(init) @@ -236,7 +234,6 @@ BootCommon.was_proposed = true BootCommon.changed = true BootCommon.location_changed = true - BootCommon.partitioning_last_change = Storage.GetTargetChangeTime BootCommon.backup_mbr = true Builtins.y2milestone("Proposed settings: %1", Export()) @@ -908,7 +905,7 @@ end # check architecture for using kexec instead of reboot - if Arch.ppc || Arch.ia64 || Arch.s390 + if Arch.ppc || Arch.s390 Builtins.y2milestone("Skip using of kexec on this architecture") return true end @@ -933,40 +930,14 @@ return false end - # create default sections - linux_default = BootCommon.CreateLinuxSection("linux") - - Builtins.y2milestone("linux_default: %1", linux_default) - - default_section = {} - - name = getDefaultSection - # find default section in BootCommon::sections - Builtins.foreach(BootCommon.sections) do |section| - if Builtins.search( - Builtins.tostring(Ops.get_string(section, "name", "")), - name - ) != nil && - Ops.get(section, "root") == Ops.get(linux_default, "root") && - Ops.get_string(section, "original_name", "") != "failsafe" - Builtins.y2milestone("default section: %1", section) - default_section = deep_copy(section) - end - end - # create directory /var/lib/YaST2 WFM.Execute(path(".local.mkdir"), "/var/lib/YaST2") - # build command for copy kernel and initrd to /var/lib/YaST during instalation - cmd = nil - - default_section = updateAppend(default_section) - cmd = Builtins.sformat( - "/bin/cp %1%2 %1%3 %4", + "/bin/cp -L %1%2 %1%3 %4", Installation.destdir, - Builtins.tostring(Ops.get_string(default_section, "image", "")), - Builtins.tostring(Ops.get_string(default_section, "initrd", "")), + "vmlinuz", + "initrd", Directory.vardir ) @@ -977,32 +948,6 @@ return false end - if Ops.get_string(default_section, "root", "") == "" - Builtins.y2milestone("root is not defined in default section.") - return false - end - - if Ops.get_string(default_section, "vgamode", "") == "" - Builtins.y2milestone("vgamode is not defined in default section.") - return false - end - - # flush kernel options into /var/lib/YaST/kernel_params - cmd = Builtins.sformat( - "echo \"root=%1 %2 vga=%3\" > %4/kernel_params", - Builtins.tostring(Ops.get_string(default_section, "root", "")), - Builtins.tostring(Ops.get_string(default_section, "append", "")), - Builtins.tostring(Ops.get_string(default_section, "vgamode", "")), - Directory.vardir - ) - - Builtins.y2milestone("Command for flushing kernel args: %1", cmd) - out = Convert.to_map(WFM.Execute(path(".local.bash_output"), cmd)) - if Ops.get(out, "exit") != 0 - Builtins.y2error("Flushing kernel params failed, output: %1", out) - return false - end - true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/test/boot_record_backup_test.rb new/yast2-bootloader-3.1.101/test/boot_record_backup_test.rb --- old/yast2-bootloader-3.1.100/test/boot_record_backup_test.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/test/boot_record_backup_test.rb 2014-10-13 11:02:12.000000000 +0200 @@ -5,12 +5,37 @@ require "bootloader/boot_record_backup" describe Bootloader::BootRecordBackup do - subject { Bootloader::BootRecordBackup } - describe ".create_for" do - BASH_PATH = Yast::Path.new(".target.bash") - SIZE_PATH = Yast::Path.new(".target.size") - DIR_PATH = Yast::Path.new(".target.dir") - STAT_PATH = Yast::Path.new(".target.stat") + BASH_PATH = Yast::Path.new(".target.bash") + SIZE_PATH = Yast::Path.new(".target.size") + DIR_PATH = Yast::Path.new(".target.dir") + STAT_PATH = Yast::Path.new(".target.stat") + + subject { Bootloader::BootRecordBackup.new("/dev/sda") } + + describe "#restore" do + it "returns true if backup is successfully restored" do + allow(Yast::SCR).to receive(:Read).with(SIZE_PATH, anything).and_return(10) + expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* if=\/var\/lib\/YaST2\/backup_boot_sectors/). + and_return(0) + + expect(subject.restore).to be true + end + + it "returns false if copying backup failed" do + allow(Yast::SCR).to receive(:Read).with(SIZE_PATH, anything).and_return(10) + expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* if=\/var\/lib\/YaST2\/backup_boot_sectors/). + and_return(1) + + expect(subject.restore).to be false + end + + it "raise ::Bootloader::BootRecordBackup::Missing exception if there is not backup for device BR" do + allow(Yast::SCR).to receive(:Read).with(SIZE_PATH, anything).and_return(0) + expect{subject.restore}.to raise_error(::Bootloader::BootRecordBackup::Missing) + end + end + + describe "#write" do before do allow(Yast::SCR).to receive(:Execute).with(BASH_PATH, /mkdir/) allow(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd/) @@ -21,17 +46,17 @@ it "store backup of device first 512 bytes to /var/log/YaST2" do expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* of=\/var\/log\/YaST2/) - subject.create_for("/dev/sda") + subject.write end it "store backup of device first 512 bytes to /var/lib/YaST2/backup_boot_sectors" do expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* of=\/var\/lib\/YaST2\/backup_boot_sectors/) - subject.create_for("/dev/sda") + subject.write end - it "creates /var/lib/YaST2/backup_boot_sectors if it do not exists" do + it "writes /var/lib/YaST2/backup_boot_sectors if it do not exists" do expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /mkdir.* \/var\/lib\/YaST2\/backup_boot_sectors/) - subject.create_for("/dev/sda") + subject.write end it "move old backup in backup_boot_sectors to copy with timestamp" do @@ -40,7 +65,7 @@ allow(Yast::SCR).to receive(:Read).with(STAT_PATH, anything).and_return({"ctime" => 200}) expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/mv .*backup_boot_sectors.*\s+.*backup_boot_sectors/) - subject.create_for("/dev/sda") + subject.write end it "keep only ten backups in backup_boot_sectors" do @@ -52,15 +77,14 @@ allow(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/mv .*backup_boot_sectors.*\s+.*backup_boot_sectors/) expect(Yast::SCR).to receive(:Execute).with(Yast::Path.new(".target.remove"), /.*backup_boot_sectors.*/) - subject.create_for("/dev/sda") + subject.write end - it "store backup of device first 512 bytes to /boot/backup_mbr if it is MBR of primary disk" do allow(Yast::BootCommon).to receive(:mbrDisk).and_return("/dev/sda") expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* of=\/boot\/backup_mbr/) - subject.create_for("/dev/sda") + subject.write end it "copy backup of device also to backup_boot_sectors with thinkpadMBR suffix if it is primary disk and contain thinkpad boot code" do @@ -68,7 +92,7 @@ allow(Yast::BootCommon).to receive(:ThinkPadMBR).and_return(true) expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /\Acp.* \/var\/lib\/YaST2\/backup_boot_sectors.*thinkpadMBR/) - subject.create_for("/dev/sda") + subject.write end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.100/test/device_mapping_test.rb new/yast2-bootloader-3.1.101/test/device_mapping_test.rb --- old/yast2-bootloader-3.1.100/test/device_mapping_test.rb 2014-10-01 12:20:04.000000000 +0200 +++ new/yast2-bootloader-3.1.101/test/device_mapping_test.rb 2014-10-13 11:02:12.000000000 +0200 @@ -9,6 +9,7 @@ before do # always invalidate cache to use new mocks allow(subject.instance).to receive(:cache_valid?).and_return false + allow(Yast::Arch).to receive(:ppc).and_return(false) end describe ".to_kernel_device" do -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
