refs #1622 add ogGrub4dosInstallMbr
parent
41aa2c3a5f
commit
59b702047d
|
@ -1285,12 +1285,12 @@ def ogBootLoaderSetTimeOut (disk, par, timeout):
|
|||
|
||||
def ogGrub4dosInstallMbr (disk, par):
|
||||
#Controlar existencia de disco y particion
|
||||
DEVICE = DiskLib.ogDiskToDev (disk)
|
||||
if not DEVICE:
|
||||
device = DiskLib.ogDiskToDev (disk)
|
||||
if not device:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, '')
|
||||
return None
|
||||
MOUNTDISK = FileSystemLib.ogMount (disk, par)
|
||||
if not MOUNTDISK:
|
||||
mountdisk = FileSystemLib.ogMount (disk, par)
|
||||
if not mountdisk:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, ogGlobals.lang.MSG_ERROR)
|
||||
return None
|
||||
#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')
|
||||
return None
|
||||
#Controlar la existencia del grub4dos con acceso a ntfs
|
||||
BINDIR = f'{ogGlobals.OGLIB}/grub4dos/grub4dos-0.4.6a'
|
||||
if not os.path.exists (f'{BINDIR}/bootlace.com'):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f': {BINDIR}/bootlace.com')
|
||||
bindir = f'{ogGlobals.OGLIB}/grub4dos/grub4dos-0.4.6a'
|
||||
if not os.path.exists (f'{bindir}/bootlace.com'):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f': {bindir}/bootlace.com')
|
||||
return None
|
||||
|
||||
#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
|
||||
shutil.copy2 (f'{BINDIR}/grldr', MOUNTDISK)
|
||||
shutil.copy2 (f'{bindir}/grldr', mountdisk)
|
||||
#Instalar y configurar grub4dos
|
||||
if os.path.exists (f'{MOUNTDISK}/boot/grub/menu.lst'):
|
||||
os.unlink (f'{MOUNTDISK}/boot/grub/menu.lst')
|
||||
os.rmdir (f'/{MOUNTDISK}/boot/grub')
|
||||
if not os.path.exists (f'{MOUNTDISK}/boot/grub/menu.lst'):
|
||||
os.makedirs (f'/{MOUNTDISK}/boot/grub', exist_ok=True)
|
||||
open (f'/{MOUNTDISK}/boot/grub/menu.lst', 'w').close()
|
||||
GRUBDISK = int (disk) - 1
|
||||
with open (f'/{MOUNTDISK}/boot/grub/menu.lst', 'w') as fd:
|
||||
if os.path.exists (f'{mountdisk}/boot/grub/menu.lst'):
|
||||
os.unlink (f'{mountdisk}/boot/grub/menu.lst')
|
||||
os.rmdir (f'/{mountdisk}/boot/grub')
|
||||
if not os.path.exists (f'{mountdisk}/boot/grub/menu.lst'):
|
||||
os.makedirs (f'/{mountdisk}/boot/grub', exist_ok=True)
|
||||
open (f'/{mountdisk}/boot/grub/menu.lst', 'w').close()
|
||||
grubdisk = int (disk) - 1
|
||||
with open (f'/{mountdisk}/boot/grub/menu.lst', 'w') as fd:
|
||||
fd.write ('##NO-TOCAR-ESTA-LINEA MBR\n')
|
||||
fd.write ('timeout 0\n')
|
||||
fd.write ('title MBR\n')
|
||||
fd.write (f'root (hd{GRUBDISK},0)\n')
|
||||
fd.write (f'chainloader (hd{GRUBDISK},0)+1\n')
|
||||
fd.write (f'root (hd{grubdisk},0)\n')
|
||||
fd.write (f'chainloader (hd{grubdisk},0)+1\n')
|
||||
fd.write ('boot\n')
|
||||
fd.write ('EOT\n')
|
||||
fd.write ('\n')
|
||||
|
|
Loading…
Reference in New Issue