refs #1622 add ogGrub4dosInstallMbr

pull/5/head
Natalia Serrano 2025-03-06 10:17:10 +01:00
parent 41aa2c3a5f
commit 59b702047d
1 changed files with 19 additions and 19 deletions

View File

@ -1285,12 +1285,12 @@ def ogBootLoaderSetTimeOut (disk, par, timeout):
def ogGrub4dosInstallMbr (disk, par): def ogGrub4dosInstallMbr (disk, par):
#Controlar existencia de disco y particion #Controlar existencia de disco y particion
DEVICE = DiskLib.ogDiskToDev (disk) device = DiskLib.ogDiskToDev (disk)
if not DEVICE: if not device:
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, '') SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, '')
return None return None
MOUNTDISK = FileSystemLib.ogMount (disk, par) mountdisk = FileSystemLib.ogMount (disk, par)
if not MOUNTDISK: if not mountdisk:
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, ogGlobals.lang.MSG_ERROR) SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, ogGlobals.lang.MSG_ERROR)
return None return None
#Controlar acceso de escritura a la particion #Controlar acceso de escritura a la particion
@ -1307,29 +1307,29 @@ def ogGrub4dosInstallMbr (disk, par):
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOMSDOS, ': grub2dos requiere particionado tipo MSDOS') SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOMSDOS, ': grub2dos requiere particionado tipo MSDOS')
return None return None
#Controlar la existencia del grub4dos con acceso a ntfs #Controlar la existencia del grub4dos con acceso a ntfs
BINDIR = f'{ogGlobals.OGLIB}/grub4dos/grub4dos-0.4.6a' bindir = f'{ogGlobals.OGLIB}/grub4dos/grub4dos-0.4.6a'
if not os.path.exists (f'{BINDIR}/bootlace.com'): if not os.path.exists (f'{bindir}/bootlace.com'):
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f': {BINDIR}/bootlace.com') SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f': {bindir}/bootlace.com')
return None return None
#instalar el bootloader de grlrd en el MBR #instalar el bootloader de grlrd en el MBR
subprocess.run ([f'{BINDIR}/bootlace64.com', DEVICE], capture_output=True) subprocess.run ([f'{bindir}/bootlace64.com', device], capture_output=True)
#copiar grld a la particion #copiar grld a la particion
shutil.copy2 (f'{BINDIR}/grldr', MOUNTDISK) shutil.copy2 (f'{bindir}/grldr', mountdisk)
#Instalar y configurar grub4dos #Instalar y configurar grub4dos
if os.path.exists (f'{MOUNTDISK}/boot/grub/menu.lst'): if os.path.exists (f'{mountdisk}/boot/grub/menu.lst'):
os.unlink (f'{MOUNTDISK}/boot/grub/menu.lst') os.unlink (f'{mountdisk}/boot/grub/menu.lst')
os.rmdir (f'/{MOUNTDISK}/boot/grub') os.rmdir (f'/{mountdisk}/boot/grub')
if not os.path.exists (f'{MOUNTDISK}/boot/grub/menu.lst'): if not os.path.exists (f'{mountdisk}/boot/grub/menu.lst'):
os.makedirs (f'/{MOUNTDISK}/boot/grub', exist_ok=True) os.makedirs (f'/{mountdisk}/boot/grub', exist_ok=True)
open (f'/{MOUNTDISK}/boot/grub/menu.lst', 'w').close() open (f'/{mountdisk}/boot/grub/menu.lst', 'w').close()
GRUBDISK = int (disk) - 1 grubdisk = int (disk) - 1
with open (f'/{MOUNTDISK}/boot/grub/menu.lst', 'w') as fd: with open (f'/{mountdisk}/boot/grub/menu.lst', 'w') as fd:
fd.write ('##NO-TOCAR-ESTA-LINEA MBR\n') fd.write ('##NO-TOCAR-ESTA-LINEA MBR\n')
fd.write ('timeout 0\n') fd.write ('timeout 0\n')
fd.write ('title MBR\n') fd.write ('title MBR\n')
fd.write (f'root (hd{GRUBDISK},0)\n') fd.write (f'root (hd{grubdisk},0)\n')
fd.write (f'chainloader (hd{GRUBDISK},0)+1\n') fd.write (f'chainloader (hd{grubdisk},0)+1\n')
fd.write ('boot\n') fd.write ('boot\n')
fd.write ('EOT\n') fd.write ('EOT\n')
fd.write ('\n') fd.write ('\n')