|
|
|
@ -41,6 +41,7 @@ from datavars import DataVarsInstall
|
|
|
|
|
from distr import DistributiveError, PartitionDistributive
|
|
|
|
|
from subprocess import Popen, PIPE, STDOUT
|
|
|
|
|
from itertools import *
|
|
|
|
|
from calculate.lib.utils.tools import traverse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InstallError(Exception):
|
|
|
|
@ -249,9 +250,6 @@ class Install(MethodsInterface):
|
|
|
|
|
"""
|
|
|
|
|
# получить загрузочный раздел (если есть /boot, то
|
|
|
|
|
# он является загрузочным иначе корень)
|
|
|
|
|
chroot_cmd = getProgPath('/usr/bin/chroot')
|
|
|
|
|
chroot_dn = target.getDirectory()
|
|
|
|
|
|
|
|
|
|
for boot_path in ("/boot", "/"):
|
|
|
|
|
boot_disk = self.clVars.Select("os_install_disk_dev",
|
|
|
|
|
where="os_install_disk_mount",
|
|
|
|
@ -260,11 +258,18 @@ class Install(MethodsInterface):
|
|
|
|
|
self.setActivePartition(boot_disk)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
chroot_cmd = getProgPath('/usr/bin/chroot')
|
|
|
|
|
chroot_dn = target.getDirectory()
|
|
|
|
|
if chroot_dn == '/':
|
|
|
|
|
chrooting = []
|
|
|
|
|
else:
|
|
|
|
|
chrooting = [chroot_cmd, chroot_dn]
|
|
|
|
|
# если GRUB2 версии 2.00 и выше, обычная установка требует
|
|
|
|
|
# параметра --target=i386-pc, иначе GRUB2 может попытаться
|
|
|
|
|
# прописать себя как UEFI
|
|
|
|
|
if filter(lambda x: "2." in x,
|
|
|
|
|
process(cmd_grub_install, '--version')):
|
|
|
|
|
process(*traverse([chrooting,
|
|
|
|
|
cmd_grub_install, '--version']))):
|
|
|
|
|
platform = ["--target=i386-pc"]
|
|
|
|
|
else:
|
|
|
|
|
platform = []
|
|
|
|
@ -275,12 +280,11 @@ class Install(MethodsInterface):
|
|
|
|
|
try:
|
|
|
|
|
for mbr_disk in self.clVars.Get('os_install_mbr'):
|
|
|
|
|
grub_process = process(
|
|
|
|
|
chroot_cmd,
|
|
|
|
|
chroot_dn,
|
|
|
|
|
*traverse([chrooting,
|
|
|
|
|
cmd_grub_install,
|
|
|
|
|
"--boot-directory=/%s" % path.relpath(target.getBootDirectory(),
|
|
|
|
|
chroot_dn),
|
|
|
|
|
mbr_disk, "--force", *platform,
|
|
|
|
|
mbr_disk, "--force",platform]),
|
|
|
|
|
stderr=STDOUT, envdict=os.environ)
|
|
|
|
|
if grub_process.failed():
|
|
|
|
|
raise DistributiveError(
|
|
|
|
@ -398,6 +402,10 @@ class Install(MethodsInterface):
|
|
|
|
|
"""
|
|
|
|
|
chroot_cmd = getProgPath('/usr/bin/chroot')
|
|
|
|
|
chroot_dn = target.getDirectory()
|
|
|
|
|
if chroot_dn == '/':
|
|
|
|
|
chrooting = []
|
|
|
|
|
else:
|
|
|
|
|
chrooting = [chroot_cmd, chroot_dn]
|
|
|
|
|
grub_params = [
|
|
|
|
|
"--boot-directory=/%s" % path.relpath(target.getBootDirectory(),
|
|
|
|
|
chroot_dn),
|
|
|
|
@ -431,10 +439,10 @@ class Install(MethodsInterface):
|
|
|
|
|
targetdir.mountSystemDirectories()
|
|
|
|
|
try:
|
|
|
|
|
grub_process = process(
|
|
|
|
|
chroot_cmd,
|
|
|
|
|
chroot_dn,
|
|
|
|
|
*traverse([
|
|
|
|
|
chrooting,
|
|
|
|
|
cmd_grub_install,
|
|
|
|
|
*grub_params, stderr=STDOUT,
|
|
|
|
|
grub_params]), stderr=STDOUT,
|
|
|
|
|
envdict=os.environ)
|
|
|
|
|
if grub_process.failed():
|
|
|
|
|
raise DistributiveError(_("Failed to install the bootloader"))
|
|
|
|
|