refs #1594 simplify a couple of lines

pull/1/head
Natalia Serrano 2025-02-20 14:00:41 +01:00
parent acf2c1dc49
commit e6937a211a
1 changed files with 5 additions and 8 deletions

View File

@ -176,9 +176,7 @@ def ogCreatePartitions (disk, parts):
ogCreatePartitionTable (ND)
# Definir particiones y notificar al kernel.
print (f'about to run sfdisk: ({sfdisk_input})')
p = subprocess.run (['sfdisk', DISK], input=sfdisk_input, capture_output=True, text=True)
print (f'rc ({p.returncode}) stdout ({p.stdout}) stderr ({p.stderr})')
subprocess.run (['partprobe', DISK])
if CACHESIZE: CacheLib.ogMountCache()
return True
@ -257,10 +255,11 @@ def ogCreateGptPartitions (disk, parts):
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, TYPE)
return None
# Comprobar tamaño numérico y convertir en sectores de 512 B.
SIZE = 2 * SIZE
SIZE *= 2
# SIZE debe ser múltiplo de ALIGN, si no gdisk lo mueve automáticamente.
DIV = SIZE // ALIGN
SIZE = DIV * ALIGN
SIZE = (SIZE // ALIGN) * ALIGN
# Generar datos para la partición.
# En el caso de que la partición sea EMPTY no se crea nada
if 'EMPTY' != TYPE:
OPTIONS += [f'-n{PART}:{START}:+{SIZE}', f'-t{PART}:{ID}']
@ -276,14 +275,12 @@ def ogCreateGptPartitions (disk, parts):
# Desmontar los sistemas de archivos del disco antes de realizar las operaciones.
FileSystemLib.ogUnmountAll (ND)
if CACHESIZE:
CacheLib.ogUnmountCache()
if CACHESIZE: CacheLib.ogUnmountCache()
# Si la tabla de particiones no es valida, volver a generarla.
ogCreatePartitionTable (ND)
# Definir particiones y notificar al kernel.
# Borramos primero las particiones y luego creamos las nuevas
subprocess.run (['sgdisk'] + DELOPTIONS + OPTIONS + [DISK])
subprocess.run (['partprobe', DISK])
if CACHESIZE: CacheLib.ogMountCache()