diff --git a/.travis.yml b/.travis.yml index 1c5907696..cd03071d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ before_install: # disable rvm, use system Ruby - rvm reset - wget https://raw.githubusercontent.com/yast/yast-devtools/master/travis-tools/travis_setup.sh - - sh ./travis_setup.sh -p "yast2-devtools yast2 yast2-storage rake" -g "gettext yast-rake yard rspec:3.3.0 simplecov coveralls rubocop:0.29.1 cfa_grub2" + - sh ./travis_setup.sh -p "yast2-devtools yast2 yast2-storage rake ruby2.1-dev libaugeas-dev pkg-config" -g "gettext yast-rake yard rspec:3.3.0 simplecov coveralls rubocop:0.29.1 cfa_grub2" script: - rake check:syntax - rake check:pot diff --git a/src/modules/BootCommon.rb b/src/modules/BootCommon.rb index d813d9901..c67f77071 100644 --- a/src/modules/BootCommon.rb +++ b/src/modules/BootCommon.rb @@ -206,13 +206,6 @@ def Reset nil end - # Propose bootloader settings - def Propose - Builtins.y2error("No generic propose function available") - - nil - end - # Save all bootloader configuration files to the cache of the PlugLib # PlugLib must be initialized properly !!! # @param [Boolean] clean boolean true if settings should be cleaned up (checking their @@ -283,172 +276,6 @@ def Save(_clean, init, flush) ret end - # Display bootloader summary - # @return a list of summary lines - def Summary - bl = getLoaderType(false) - if bl == "none" - return [ - HTML.Colorize(getLoaderName(getLoaderType(false), :summary), "red") - ] - end - - # each Boot* should have own summary, that can differ - raise "Not implemented for bootloader \"#{bl}\"" - end - - # Update read settings to new version of configuration files - def Update - Builtins.y2debug("No generic update function available") - - nil - end - - # Write bootloader settings to disk - # @return [Boolean] true on success - def Write - Builtins.y2error("No generic write function available") - false - end - - # end of generic versions of bootloader-specific functions - #----------------------------------------------------------------------------- - # common functions start - - # bootloader type handling functions - - # Set attributes of specified bootloader to variable containing - # attributes of currently used bootloader, call its initializer - # @param [String] loader_type string loader type to initialize - def setCurrentLoaderAttribs(loader_type) - Builtins.y2milestone("Setting attributes for bootloader %1", loader_type) - 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 - boot_initializer = Ops.get(@bootloader_attribs, [loader_type, "initializer"]) - if boot_initializer - Builtins.y2milestone("Running bootloader initializer") - boot_initializer.call - Builtins.y2milestone("Initializer finished") - else - Builtins.y2error("No initializer found for >>%1<<", loader_type) - @current_bootloader_attribs = {} - end - - @current_bootloader_attribs = Builtins.union( - @current_bootloader_attribs, - Builtins.eval(Ops.get(@bootloader_attribs, loader_type, {})) - ) - - nil - end - - # Check whether loader with specified name is supported - # @param [String] loader string name of loader to check - # @return [String] the loader name if supported, "none" otherwise - def SupportedLoader(loader) - SUPPORTED_BOOTLOADERS.include?(loader) ? loader : "none" - end - - def boot_efi? - if Mode.live_installation - SCR.Execute(path(".target.bash_output"), "modprobe efivars >/dev/null 2>&1") - return FileUtils.Exists("/sys/firmware/efi/systab") - else - return Linuxrc.InstallInf("EFI") == "1" - end - 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 - # read bootloader to use from disk - if Mode.update || Mode.normal || Mode.repair - sysconfig = ::Bootloader::Sysconfig.from_system - @loader_type = sysconfig.bootloader - if @loader_type && !@loader_type.empty? - @loader_type = "grub2" if @loader_type == "s390" - Builtins.y2milestone( - "Sysconfig bootloader is %1, using", - @loader_type - ) - @loader_type = SupportedLoader(@loader_type) - Builtins.y2milestone( - "Sysconfig bootloader is %1, using", - @loader_type - ) - setCurrentLoaderAttribs(@loader_type) - return @loader_type - end - end - # detect bootloader - @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) - if (Arch.i386 || Arch.x86_64 || Arch.aarch64) && boot_efi? - # use grub2-efi as default bootloader for x86_64/i386/aarch64 EFI - @loader_type = "grub2-efi" - end - - @loader_type = SupportedLoader(@loader_type) - Builtins.y2milestone("Detected bootloader %1", @loader_type) - setCurrentLoaderAttribs(@loader_type) - @loader_type - end - - # set type of bootloader - # @param [String] bootloader string type of bootloader - def setLoaderType(bootloader) - if !bootloader - Builtins.y2milestone("Resetting the loader type") - @loader_type = nil - return - end - Builtins.y2milestone("Setting bootloader to >>%1<<", bootloader) - raise "Unsupported bootloader '#{bootloader}'" unless SUPPORTED_BOOTLOADERS.include?(bootloader) - - bootloader_packages = Ops.get_list( - @bootloader_attribs, - [bootloader, "required_packages"], - [] - ) - - # 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 - - # we need perl-Bootloader-YAML API to communicate with pbl - bootloader_packages << "perl-Bootloader-YAML" - - 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 - end - @loader_type = bootloader - setCurrentLoaderAttribs(@loader_type) - Builtins.y2milestone("Loader type set") - - nil - end - def getSystemSecureBootStatus(recheck) return @secure_boot if !recheck && !@secure_boot.nil? diff --git a/src/modules/Bootloader.rb b/src/modules/Bootloader.rb index cc7ec34e0..760269854 100644 --- a/src/modules/Bootloader.rb +++ b/src/modules/Bootloader.rb @@ -285,17 +285,13 @@ def Write # progress stage, text in dialog (short) _("Create initrd"), # progress stage, text in dialog (short) - _("Save boot loader configuration files"), - # progress stage, text in dialog (short) - _("Install boot loader") + _("Save boot loader configuration"), ] titles = [ # progress step, text in dialog (short) _("Creating initrd..."), # progress step, text in dialog (short) - _("Saving boot loader configuration files..."), - # progress step, text in dialog (short) - _("Installing boot loader...") + _("Saving boot loader configuration..."), ] # progress bar caption if Mode.normal @@ -332,40 +328,9 @@ def Write Progress.Title(titles[1]) end - write_sysconfig - write_proposed_params(params_to_save) - - return ret if getLoaderType == "none" - - # F#300779 - Install diskless client (NFS-root) - # kokso: bootloader will not be installed - if BootCommon.getBootDisk == "/dev/nfs" - log.info "Bootloader::Write() -> Boot partition is nfs type, bootloader will not be installed." - return ret - end - - # F#300779 -end - - # save bootloader settings - reinit = !Mode.normal - log.info "Reinitialize bootloader library before saving: #{reinit}" - ret = blSave(true, reinit, true) && ret - - log.error "Error before configuration files saving finished" unless ret - - if Mode.normal - Progress.NextStage - else - Progress.NextStep if !@repeating_write - Progress.Title(titles[2]) - end - - # call bootloader executable - log.info "Calling bootloader executable" - ret &&= blWrite - ret = handle_failed_write unless ret + Bootloader::BootloaderFactory.current.write - ret + true end # Write bootloader settings during installation @@ -565,26 +530,6 @@ def ReadOrProposeIfNeeded private - # Write settings to /etc/sysconfig/bootloader - def write_sysconfig - sysconfig = ::Bootloader::Sysconfig.new( - bootloader: getLoaderType, - secure_boot: BootCommon.getSystemSecureBootStatus(false) - ) - sysconfig.write - end - - def write_proposed_params(params_to_save) - return unless Stage.initial - - params_to_save["installation_kernel_params"] = Kernel.GetCmdLine - SCR.Write( - path(".target.ycp"), - "/var/lib/YaST2/bootloader.ycp", - params_to_save - ) - end - def mark_as_changed BootCommon.save_all = true if BootCommon.write_settings["save_all"]