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

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

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

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

@ -765,13 +765,16 @@ class VariableOsGrub2Path(Variable):
def get(self):
# 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:
return grubInstall
# 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,
process(grubInstall, '--version')):
process(chroot_cmd, chroot_path,
grubInstall, '--version')):
return grubInstall
return ""

Loading…
Cancel
Save