Изменёно выполнение grub-install

* grub-install выполняется из устанавливаемой системы, для того, чтобы
исключить возможное несоответствие версий grub
legacy27 3.6.1
parent d6851726f2
commit cdd5e1c3f4

@ -652,11 +652,15 @@ class DirectoryDistributive(Distributive):
if not parent: if not parent:
self._makeDirectory(self.directory) self._makeDirectory(self.directory)
def hasSystemDirectories(self):
return self.system_mounted or self.directory == '/'
def mountSystemDirectories(self, skip=("remote",)): def mountSystemDirectories(self, skip=("remote",)):
""" """
Подключить к дистрибутиву системые ресурсы (/proc, /sys) Подключить к дистрибутиву системые ресурсы (/proc, /sys)
:return: :return:
""" """
if not self.system_mounted:
for obj in filter(lambda x: x['name'] not in skip, self.data): for obj in filter(lambda x: x['name'] not in skip, self.data):
target_path = path.join(self.directory, obj['target']) target_path = path.join(self.directory, obj['target'])
if obj['type'] == 'bind': if obj['type'] == 'bind':

@ -249,6 +249,9 @@ class Install(MethodsInterface):
""" """
# получить загрузочный раздел (если есть /boot, то # получить загрузочный раздел (если есть /boot, то
# он является загрузочным иначе корень) # он является загрузочным иначе корень)
chroot_cmd = getProgPath('/usr/bin/chroot')
chroot_dn = target.getDirectory()
for boot_path in ("/boot", "/"): for boot_path in ("/boot", "/"):
boot_disk = self.clVars.Select("os_install_disk_dev", boot_disk = self.clVars.Select("os_install_disk_dev",
where="os_install_disk_mount", where="os_install_disk_mount",
@ -266,16 +269,25 @@ class Install(MethodsInterface):
else: else:
platform = [] platform = []
# прописать GRUB2 на все указанные диски # прописать GRUB2 на все указанные диски
targetdir = target.convertToDirectory()
if not targetdir.hasSystemDirectories():
targetdir.mountSystemDirectories()
try:
for mbr_disk in self.clVars.Get('os_install_mbr'): for mbr_disk in self.clVars.Get('os_install_mbr'):
grub_process = process(cmd_grub_install, grub_process = process(
"--boot-directory=%s" % pathJoin( chroot_cmd,
prefix_boot, chroot_dn,
target.getBootDirectory()), 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) stderr=STDOUT, envdict=os.environ)
if grub_process.failed(): if grub_process.failed():
raise DistributiveError( raise DistributiveError(
_("Failed to install the bootloader")) _("Failed to install the bootloader"))
finally:
if targetdir.system_mounted:
targetdir.umountSystemDirectories()
def update_efi_fstab(self): def update_efi_fstab(self):
""" """
@ -384,14 +396,14 @@ class Install(MethodsInterface):
""" """
Установить grub с UEFI загрузчиком Установить grub с UEFI загрузчиком
""" """
efifulldir = pathJoin(target.getDirectory(), efidir) chroot_cmd = getProgPath('/usr/bin/chroot')
chroot_dn = target.getDirectory()
grub_params = [ grub_params = [
"--boot-directory=%s" % pathJoin( "--boot-directory=/%s" % path.relpath(target.getBootDirectory(),
prefix_boot, chroot_dn),
target.getBootDirectory()),
"--bootloader-id=%s" % efiname, "--bootloader-id=%s" % efiname,
"--target=x86_64-efi", "--target=x86_64-efi",
"--efi-directory=%s" % efifulldir, "--efi-directory=%s" % efidir,
"--force"] "--force"]
# проверяем наличие в nv-ram нужной нам записи для исключения повтора # проверяем наличие в nv-ram нужной нам записи для исключения повтора
efi_boot_mgr = getProgPath('/usr/sbin/efibootmgr') efi_boot_mgr = getProgPath('/usr/sbin/efibootmgr')
@ -414,11 +426,21 @@ class Install(MethodsInterface):
# в efivars # в efivars
if self.clVars.Get('os_install_root_type') == 'usb-hdd': if self.clVars.Get('os_install_root_type') == 'usb-hdd':
grub_params.append("--removable") grub_params.append("--removable")
grub_process = process(cmd_grub_install, targetdir = target.convertToDirectory()
if not targetdir.hasSystemDirectories():
targetdir.mountSystemDirectories()
try:
grub_process = process(
chroot_cmd,
chroot_dn,
cmd_grub_install,
*grub_params, stderr=STDOUT, *grub_params, stderr=STDOUT,
envdict=os.environ) envdict=os.environ)
if grub_process.failed(): if grub_process.failed():
raise DistributiveError(_("Failed to install the bootloader")) raise DistributiveError(_("Failed to install the bootloader"))
finally:
if targetdir.system_mounted:
targetdir.umountSystemDirectories()
# проверяем успешность создания загрузочной записи # проверяем успешность создания загрузочной записи
# если среди загрузочных записей отсутствует запись # если среди загрузочных записей отсутствует запись
# calculate и dmesg содержит сообщение об ошибке efivars - # calculate и dmesg содержит сообщение об ошибке efivars -

@ -765,13 +765,16 @@ class VariableOsGrub2Path(Variable):
def get(self): def get(self):
# find grub2-install # find grub2-install
grubInstall = getProgPath('/usr/sbin/grub2-install') chroot_path = self.Get('cl_chroot_path')
chroot_cmd = getProgPath('/usr/bin/chroot')
grubInstall = getProgPath('/usr/sbin/grub2-install', prefix=chroot_path)
if grubInstall: if grubInstall:
return grubInstall return grubInstall
# find grub-install and check, that this is grub2-install (ver 1.99) # find grub-install and check, that this is grub2-install (ver 1.99)
grubInstall = getProgPath('/usr/sbin/grub-install') grubInstall = getProgPath('/usr/sbin/grub-install', prefix=chroot_path)
if grubInstall and filter(lambda x: "1.99" in x or "2." in x, if grubInstall and filter(lambda x: "1.99" in x or "2." in x,
process(grubInstall, '--version')): process(chroot_cmd, chroot_path,
grubInstall, '--version')):
return grubInstall return grubInstall
return "" return ""

Loading…
Cancel
Save