Заблокирована попытка уставновки дистрибутива в который нельзя выполнить chroot

* из i686 -> x86_64
* old kernel
develop 3.6.1.1
parent cdd5e1c3f4
commit 96be7db2ab

@ -524,6 +524,12 @@ class Distributive(object):
d['cl_profile_name'] = dv.Get('cl_profile_name')
# make lazy call
d['os_linux_files'] = partial(dv.Get, 'os_linux_files')
d['os_chrootable_set'] = "off"
try:
if process("/usr/bin/chroot", directory, "/bin/true").success():
d['os_chrootable_set'] = "on"
except Exception:
pass
except VariableError:
pass
return d.copy()

@ -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"))

@ -328,6 +328,9 @@ class VariableClImageFilename(DistroRepository, Variable):
imageData.get('os_linux_build', '') and
"os_arch_machine" in imageData):
raise VariableError(_("Wrong image file"))
if imageData["os_chrootable_set"] == 'off':
raise VariableError(
_("The image is not compatible with the current kernel"))
def humanImageName(self, distroinfo, filepath):
if all(x in distroinfo for x in ("os_linux_shortname",

@ -47,6 +47,9 @@ class InstallLinux(Linux, VariableInterface):
"""Get by distroinfo or current info"""
return self.__getFromImageOrCurrent(self.current_variable)
class VariableOsInstallChrootableSet(InstallLinux, ReadonlyVariable):
"""Можно ли выполнить chroot в систему"""
current_variable = "os_chrootable_set"
class VariableOsInstallLinuxShortname(InstallLinux, ReadonlyVariable):
"""Shortname of system"""

Loading…
Cancel
Save