refs #1331 add ogCopyEfiBootLoader
parent
6f59aaaca7
commit
6538fe90b3
|
@ -117,6 +117,39 @@ def ogNvramAddEntry (bootlbl, bootldr, nvram_set=False):
|
||||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||||
#@note Si existe el cargador en la partición de sistema no es válido
|
#@note Si existe el cargador en la partición de sistema no es válido
|
||||||
#*/ ##
|
#*/ ##
|
||||||
|
def ogCopyEfiBootLoader (disk, par):
|
||||||
|
mntdir = FileSystemLib.ogMount (disk, par)
|
||||||
|
if not mntdir:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, f'{disk} {par}')
|
||||||
|
return None
|
||||||
|
|
||||||
|
esp = DiskLib.ogGetEsp()
|
||||||
|
if not esp:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, 'EFI partition')
|
||||||
|
return
|
||||||
|
esp_disk, esp_par = esp.split()
|
||||||
|
efidir = FileSystemLib.ogMount (esp_disk, esp_par)
|
||||||
|
if not efidir:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, 'ESP')
|
||||||
|
return
|
||||||
|
|
||||||
|
bootlabel = f'Part-{int(disk):02d}-{int(par):02d}'
|
||||||
|
osversion = InventoryLib.ogGetOsVersion (disk, par)
|
||||||
|
print (f'bootlabel ({bootlabel})')
|
||||||
|
print (f'osversion ({osversion})')
|
||||||
|
if 'Windows 1' in osversion:
|
||||||
|
loader = None
|
||||||
|
for i in f'{efidir}/EFI/Microsoft/Boot/bootmgfw.efi', f'{efidir}/EFI/{bootlabel}/Boot/bootmgfw.efi':
|
||||||
|
if os.path.exists (i):
|
||||||
|
loader = i
|
||||||
|
if not loader:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTOS, f'{disk} {par} ({osversion}, EFI)')
|
||||||
|
return None
|
||||||
|
|
||||||
|
if (os.path.isdir (f'{mntdir}/ogBoot')):
|
||||||
|
shutil.rmtree (f'{mntdir}/ogBoot')
|
||||||
|
dirloader = os.path.realpath (os.path.dirname (loader) + '/..')
|
||||||
|
shutil.copytree (f'{dirloader}/Boot', f'{mntdir}/ogBoot')
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from UEFILib import ogCopyEfiBootLoader
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser (add_help=False)
|
||||||
|
parser.add_argument ('disk')
|
||||||
|
parser.add_argument ('par')
|
||||||
|
|
||||||
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||||
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||||
|
ogHelp ('ogCopyEfiBootLoader', 'ogCopyEfiBootLoader int_ndisk int_part', ['ogCopyEfiBootLoader 1 2'])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
ret = ogCopyEfiBootLoader (args.disk, args.par)
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
if ret == True: sys.exit (0)
|
||||||
|
elif ret == False: sys.exit (1)
|
||||||
|
else: print (ret)
|
Loading…
Reference in New Issue