From c09c064f28594a1850dae595b20af9ba165692df Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Fri, 30 Aug 2024 11:47:30 +0200 Subject: postinstall: ignore legacy scripts non-zero return code legacy scripts are not reliable, legacy scripts continue processing on errors, warn on errors until they are converted to native code instead. --- src/utils/postinstall.py | 101 ++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 54 deletions(-) diff --git a/src/utils/postinstall.py b/src/utils/postinstall.py index 6d6e60e..7e21e67 100644 --- a/src/utils/postinstall.py +++ b/src/utils/postinstall.py @@ -99,85 +99,78 @@ def configure_os_custom(disk, partition): cmd_configure = f"{command_path} {disk} {partition}" - try: - proc = subprocess.run(shlex.split(cmd_configure), - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - check=True) - out = proc.stdout - except OSError as e: - raise OgError(f'Error processing configureOsCustom: {e}') from e + proc = subprocess.run(shlex.split(cmd_configure), + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def windows_register_c_drive(disk, partition): cmd_configure = f"ogWindowsRegisterPartition {disk} {partition} C {disk} {partition}" - try: - proc = subprocess.run(cmd_configure, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - shell=True, - check=True) - except OSError as e: - raise OgError(f'Error processing ogWindowsRegisterPartition: {e}') from e + proc = subprocess.run(cmd_configure, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + shell=True, + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def configure_mbr_boot_sector(disk, partition): cmd_configure = f"ogFixBootSector {disk} {partition}" - try: - proc = subprocess.run(cmd_configure, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - shell=True, - check=True) - except OSError as e: - raise OgError(f'Error processing ogFixBootSector: {e}') from e + proc = subprocess.run(cmd_configure, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + shell=True, + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def configure_grub_in_mbr(disk, partition): cmd_configure = f"ogGrubInstallMbr {disk} {partition} TRUE" - try: - proc = subprocess.run(cmd_configure, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - shell=True, - check=True) - except OSError as e: - raise OgError(f'Error processing ogGrubInstallMbr: {e}') from e + proc = subprocess.run(cmd_configure, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + shell=True, + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def configure_fstab(disk, partition): cmd_configure = f"ogConfigureFstab {disk} {partition}" - try: - proc = subprocess.run(cmd_configure, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - shell=True, - check=True) - except OSError as e: - raise OgError(f'Error processing ogConfigureFstab: {e}') from e + proc = subprocess.run(cmd_configure, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + shell=True, + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def install_grub(disk, partition): cmd_configure = f"ogGrubInstallPartition {disk} {partition}" - try: - proc = subprocess.run(cmd_configure, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - encoding='utf-8', - shell=True, - check=True) - except OSError as e: - raise OgError(f'Error processing ogGrubInstallPartition: {e}') from e + proc = subprocess.run(cmd_configure, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + encoding='utf-8', + shell=True, + check=True) + if proc.returncode != 0: + logging.warning(f'{cmd_configure} returned non-zero exit status {proc.returncode}') def configure_os_linux(disk, partition): -- cgit v1.2.3-18-g5258