Skip to content

Commit

Permalink
Merge pull request #204 from yast/new_inst_clients
Browse files Browse the repository at this point in the history
New inst clients
  • Loading branch information
jreidinger committed Jan 5, 2015
2 parents 3c48970 + 106a002 commit 1b38278
Show file tree
Hide file tree
Showing 15 changed files with 798 additions and 630 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -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:2.14.1 simplecov coveralls rubocop"
- sh ./travis_setup.sh -p "yast2-devtools yast2 yast2-storage rake" -g "gettext yast-rake yard rspec:2.14.1 simplecov coveralls rubocop:0.27.1"
script:
- rake check:syntax
- rake check:pot
Expand Down
7 changes: 3 additions & 4 deletions package/yast2-bootloader.spec
Expand Up @@ -27,15 +27,14 @@ Group: System/YaST
License: GPL-2.0+
Url: http://github.com/yast/yast-bootloader
BuildRequires: yast2-devtools >= 3.1.10
BuildRequires: yast2 >= 3.1.0
BuildRequires: yast2 >= 3.1.112
BuildRequires: rubygem(rspec)
BuildRequires: rubygem(yast-rake)
BuildRequires: yast2-storage
BuildRequires: yast2-ruby-bindings >= 1.0.0
PreReq: /bin/sed %fillup_prereq
# Installation::*version variables
# Wizard::SetDialogTitleAndIcon
Requires: yast2 >= 3.1.0
# Base classes for inst clients
Requires: yast2 >= 3.1.112
Requires: yast2-packager >= 2.17.24
Requires: yast2-pkg-bindings >= 2.17.25
Requires: perl-Bootloader-YAML
Expand Down
133 changes: 2 additions & 131 deletions src/clients/bootloader_auto.rb
@@ -1,132 +1,3 @@
# encoding: utf-8
require "bootloader/auto_client"

# File:
# bootloader_auto.ycp
#
# Module:
# Bootloader installation and configuration
#
# Summary:
# Bootloader autoinstallation preparation
#
# Authors:
# Jiri Srain <jsrain@suse.cz>
#
# $Id$
#
module Yast
class BootloaderAutoClient < Client
def main
Yast.import "UI"
textdomain "bootloader"

Builtins.y2milestone("----------------------------------------")
Builtins.y2milestone("bootloader auto started")

Yast.import "Bootloader"
Yast.import "BootCommon"
Yast.import "Initrd"
Yast.import "Progress"
Yast.import "Mode"

Yast.include self, "bootloader/routines/autoinstall.rb"
Yast.include self, "bootloader/routines/wizards.rb"

@progress_orig = Progress.set(false)

@ret = nil
@func = ""
@param = {}

# Check arguments
if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
Ops.is_string?(WFM.Args(0))
@func = Convert.to_string(WFM.Args(0))
if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
Ops.is_map?(WFM.Args(1))
@param = Convert.to_map(WFM.Args(1))
end
end
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Import"
data = AI2Export(@param)
if data
@ret = Bootloader.Import(data)
# moved here from inst_autosetup*
if Stage.initial
BootCommon.DetectDisks
Builtins.y2debug("autoyast: Proposing - fix")
Bootloader.Propose
Builtins.y2debug("autoyast: Proposing done")
end
else
@ret = false
end
# Create a summary
# return string
elsif @func == "Summary"
@ret = Ops.add(
Ops.add(
"<UL>",
Builtins.mergestring(Builtins.maplist(Bootloader.Summary) do |l|
Ops.add("<LI>", l)
end, "\n")
),
"</UL>"
)
# did configuration changed
# return boolean
elsif @func == "GetModified"
@ret = BootCommon.changed
# set configuration as changed
# return boolean
elsif @func == "SetModified"
BootCommon.changed = true
@ret = true
# Reset configuration
# return map or list
elsif @func == "Reset"
Bootloader.Reset
@ret = {}
# Change configuration
# return symbol (i.e. `finish || `accept || `next || `cancel || `abort)
elsif @func == "Change"
@ret = BootloaderAutoSequence()
return deep_copy(@ret)
# Return configuration data
# return map or list
elsif @func == "Export"
@ret = Export2AI(
Convert.convert(
Bootloader.Export,
:from => "map",
:to => "map <string, any>"
)
)
# Write configuration data
# return boolean
elsif @func == "Write"
@ret = Bootloader.Write
elsif @func == "Read"
Initrd.Read
@ret = Bootloader.Read
else
Builtins.y2error("unknown function: %1", @func)
@ret = false
end
Progress.set(@progress_orig)

Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("bootloader_auto finished")
Builtins.y2milestone("----------------------------------------")

deep_copy(@ret)

# EOF
end
end
end

Yast::BootloaderAutoClient.new.main
::Bootloader::AutoClient.run
222 changes: 2 additions & 220 deletions src/clients/bootloader_finish.rb
@@ -1,221 +1,3 @@
# encoding: utf-8
require "bootloader/finish_client"

# File:
# bootloader_finish.ycp
#
# Module:
# Step of base installation finish
#
# Authors:
# Jiri Srain <jsrain@suse.cz>
# Olaf Dabrunz <od@suse.de>
#
# $Id$
#
require "bootloader/kexec"

module Yast
class BootloaderFinishClient < Client
def main
textdomain "bootloader"

Yast.import "Arch"
Yast.import "Bootloader"
Yast.import "Installation"
Yast.import "Linuxrc"
Yast.import "Misc"
Yast.import "Mode"
Yast.import "BootCommon"

@ret = nil
@func = ""
@param = {}

# Check arguments
if Ops.greater_than(Builtins.size(WFM.Args), 0) &&
Ops.is_string?(WFM.Args(0))
@func = Convert.to_string(WFM.Args(0))
if Ops.greater_than(Builtins.size(WFM.Args), 1) &&
Ops.is_map?(WFM.Args(1))
@param = Convert.to_map(WFM.Args(1))
end
end

Builtins.y2milestone("starting bootloader_finish")
Builtins.y2debug("func=%1", @func)
Builtins.y2debug("param=%1", @param)

if @func == "Info"
return {
"steps" => 3,
# progress step title
"title" => _(
"Saving bootloader configuration..."
),
"when" => [:installation, :live_installation, :update, :autoinst]
}
elsif @func == "Write"
# provide the /dev content from the inst-sys also inside the chroot of just the upgraded system
# umount of this bind mount will happen in umount_finish
if Mode.update
@cmd = Ops.add(
Ops.add("targetdir=", Installation.destdir),
"\n" \
"if test ${targetdir} = / ; then echo targetdir is / ; exit 1 ; fi\n" \
"grep -E \"^[^ ]+ ${targetdir}/dev \" < /proc/mounts\n" \
"if test $? = 0\n" \
"then\n" \
"\techo targetdir ${targetdir} already mounted.\n" \
"\texit 1\n" \
"else\n" \
"\tmkdir -vp ${targetdir}/dev\n" \
"\tcp --preserve=all --recursive --remove-destination /lib/udev/devices/* ${targetdir}/dev\n" \
"\tmount -v --bind /dev ${targetdir}/dev\n" \
"fi\n"
)
Builtins.y2milestone("mount --bind cmd: %1", @cmd)
@out = Convert.to_map(WFM.Execute(path(".local.bash_output"), @cmd))
if Ops.get_integer(@out, "exit", 0) != 0
Builtins.y2error("unable to bind mount /dev in chroot")
end
Builtins.y2milestone("mount --bind /dev /mnt/dev output: %1", @out)
end
# --------------------------------------------------------------
# message after first round of packet installation
# now the installed system is run and more packages installed
# just warn the user that the screen is going back to text mode
# and yast2 will come up again.
# dont mention this "going back to text mode" here, maybe this
# wont be necessary in the final version

# we should tell the user to remove the cd on an SMP or Laptop system
# where we do a hard reboot. However, the cdrom is still mounted here
# and cant be removed.

@finish_ret = nil
if Arch.s390
@reipl_client = "reipl_bootloader_finish"

# Calling a special reIPL client
# it returns a result map (keys: (boolean) different, (string) ipl_msg)

if WFM.ClientExists(@reipl_client)
@finish_ret = Convert.to_map(WFM.call(@reipl_client))
Builtins.y2milestone(
"result of reipl_bootloader_finish [%1, %2]",
Ops.get_boolean(@finish_ret, "different", true),
Ops.get_string(@finish_ret, "ipl_msg", "N/A2")
)
Builtins.y2milestone(
"finish_ret[\"different\"]:true == true : %1",
Ops.get_boolean(@finish_ret, "different", true) == true
)
if Ops.get_boolean(@finish_ret, "different", false) == true
Builtins.y2milestone("finish_ret[\"different\"] is true")
else
Builtins.y2milestone(
"finish_ret[\"different\"] is not true (either undefined or false)"
)
end
else
Builtins.y2error("No such client: %1", @reipl_client)
end
end

if Arch.s390 && Ops.get_boolean(@finish_ret, "different", true) == true
# reIPL message
@ipl_msg = ""
@ipl_msg = Ops.get_string(@finish_ret, "ipl_msg", "")

# TRANSLATORS: reboot message
# %1 is replaced with additional message from reIPL
Misc.boot_msg = Builtins.sformat(
_(
"\n" \
"Your system will now shut down.%1\n" \
"For details, read the related chapter \n" \
"in the documentation. \n"
),
@ipl_msg
)
else
# Final message after all packages from CD1 are installed
# and we're ready to start (boot into) the installed system
# Message that will be displayed along with information
# how the boot loader was installed
Misc.boot_msg = _("The system will reboot now...")
end

#--------------------------------------------------------------
# Install bootloader (always, see #23018)
# should also set Misc::boot_msg appropriate

# 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
# Bootloader::ReadOrProposeIfNeeded() (which is called the first time
# Write() is reached from the call-chain that starts below:
# Bootloader::Update() -> Write()).

@retcode = false

if !Mode.update
@retcode = Bootloader.WriteInstallation
else
@retcode = Bootloader.Update

# workaround for packages that forgot to update initrd(bnc#889616)
# do not use Initrd module as it can also change configuration, which we do not want
res = SCR.Execute(path(".target.bash_output"), "/sbin/mkinitrd")
Builtins.y2milestone("Regerate initrd with result #{res}")
end

# FIXME: workaround grub2 need manual rerun of branding due to overwrite by
# pbl. see bnc#879686 and bnc#901003
if Bootloader.getLoaderType =~ /grub2/
prefix = Installation.destdir
branding_activator = Dir["#{prefix}/usr/share/grub2/themes/*/activate-theme"].first
if branding_activator
branding_activator = branding_activator[prefix.size..-1]
res = SCR.Execute(path(".target.bash_output"), branding_activator)
Builtins.y2milestone("Reactivate branding with #{branding_activator} and result #{res}")
res = SCR.Execute(path(".target.bash_output"), "/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg")
Builtins.y2milestone("Regenerating config for branding with result #{res}")
end
end

if @retcode
# re-read external changes, then boot through to second stage of
# installation or update
Bootloader.Read
# fate #303395: Use kexec to avoid booting between first and second stage
# copy vmlinuz, initrd and flush kernel option into /var/lib/YaST2
retcode = false
if Linuxrc.InstallInf("kexec_reboot") == "1"
kexec = ::Bootloader::Kexec.new
retcode = kexec.prepare_environment
else
Builtins.y2milestone("Installation started with kexec_reboot set 0")
end

# (bnc #381192) don't use it if kexec is used
# update calling onetime boot bnc #339024
if !retcode
@ret = Bootloader.FlagOnetimeBoot(Bootloader.getDefaultSection)
end
else
return @retcode
end
else
Builtins.y2error("unknown function: %1", @func)
@ret = nil
end

Builtins.y2debug("ret=%1", @ret)
Builtins.y2milestone("bootloader_finish finished")
deep_copy(@ret)
end
end
end

Yast::BootloaderFinishClient.new.main
Bootloader::FinishClient.run

0 comments on commit 1b38278

Please sign in to comment.