refs #1166 add ogWindowsRegisterPartition()
parent
ceb82ef24e
commit
29752be51c
|
@ -6,6 +6,7 @@
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -16,6 +17,7 @@ import FileSystemLib
|
||||||
import RegistryLib
|
import RegistryLib
|
||||||
import DiskLib
|
import DiskLib
|
||||||
import InventoryLib
|
import InventoryLib
|
||||||
|
import FileLib
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
# ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_krnlparams]
|
# ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_krnlparams]
|
||||||
|
@ -312,6 +314,51 @@ boot_entry=Herramienta de diagn<f3>stico de memoria de Windows
|
||||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
|
#ogWindowsRegisterPartition ("1", "1", "c:", "1", "1")
|
||||||
|
def ogWindowsRegisterPartition (registered_disk, registered_par, registered_vol, disk, par):
|
||||||
|
registered_vol = registered_vol[0].upper()
|
||||||
|
tmpfile = tempfile.NamedTemporaryFile (prefix='ogWBP-', mode='w').name
|
||||||
|
|
||||||
|
if not DiskLib.ogDiskToDev (registered_disk, registered_par):
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, 'particion a registrar')
|
||||||
|
return
|
||||||
|
|
||||||
|
if not DiskLib.ogDiskToDev (disk, par):
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, 'particion de windows')
|
||||||
|
return
|
||||||
|
|
||||||
|
t = InventoryLib.ogGetOsType (disk, par)
|
||||||
|
if 'Windows' not in t:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTOS, 'no es windows')
|
||||||
|
return
|
||||||
|
|
||||||
|
v = InventoryLib.ogGetOsVersion (disk, par)
|
||||||
|
|
||||||
|
if FileLib.ogGetPath (src=f'{disk} {par}', file='WINDOWS'):
|
||||||
|
systemroot = 'Windows'
|
||||||
|
elif FileLib.ogGetPath (src=f'{disk} {par}', file='WINNT'):
|
||||||
|
systemroot = 'winnt'
|
||||||
|
else:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTOS, '')
|
||||||
|
return
|
||||||
|
|
||||||
|
FileSystemLib.ogUnmount (disk, par)
|
||||||
|
disk0 = str (int (disk) - 1)
|
||||||
|
registered_disk0 = str (int (registered_disk) - 1)
|
||||||
|
|
||||||
|
with open (tmpfile, 'w') as fd:
|
||||||
|
fd.write (f"""windows_disk={disk0}
|
||||||
|
windows_main_part={par}
|
||||||
|
windows_dir={systemroot}
|
||||||
|
disk={registered_disk0}
|
||||||
|
main_part={registered_par}
|
||||||
|
;ext_part
|
||||||
|
part_letter={registered_vol}
|
||||||
|
""")
|
||||||
|
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
os.remove (tmpfile)
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
# ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
# ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||||
|
|
Loading…
Reference in New Issue