diff --git a/python_modules/build_iso.py b/python_modules/build_iso.py index 15b0c0fc..cbbe55ef 100644 --- a/python_modules/build_iso.py +++ b/python_modules/build_iso.py @@ -55,20 +55,26 @@ class BuildXfce: def lb_helper(self): - """ - Helper for the lb setup this is shared for all builds - """ - lbset_dict = { - "deb": {"64": conf.LBSET_DEB64, "32": conf.LBSET_DEB32, - "arm": conf.LBSET_DEBARM}, - "dev": {"64": conf.LBSET_DEV64, "32": conf.LBSET_DEV32, - "arm": conf.LBSET_DEVARM}, - } - lbsetup = lbset_dict.get(self.sbase, {}).get(self.sarch[1:]) + """Helper for the lb setup shared for all builds""" + # Define a dictionary to map sbase and sarch[1:] to lbsetup values + lbsetups = { + ("deb", "64"): conf.LBSET_DEB64, + ("deb", "32"): conf.LBSET_DEB32, + ("deb", "arm"): conf.LBSET_DEBARM, + ("dev", "64"): conf.LBSET_DEV64, + ("dev", "32"): conf.LBSET_DEV32, + ("dev", "arm"): conf.LBSET_DEVARM, + } + + # Get lbsetup based on sbase and sarch[1:] + lbsetup = lbsetups.get((self.sbase, self.sarch[1:])) + if lbsetup: os.system(lbsetup) else: - raise ValueError(f"Unsupported combination: {self.sbase},{self.sarch}") + # Handle unsupported cases, e.g., raise an exception + raise ValueError(f"Unsupported combination: sbase={self.sbase}, sarch={self.sarch[1:]}") + def infra_helper(self): """ @@ -84,17 +90,29 @@ class BuildXfce: """ Helper for the xfce desktop shared for all builds """ - cmd_list = { - "64": conf.build64_xfce_build, - "32": conf.build32_xfce_build, - "arm": conf.buildarm_xfce_build, - } - arch_cmds = cmd_list.get(self.sarch[1:]) - if arch_cmds: - for command in arch_cmds: - print(f"Executing command: {command}") - getattr(getattr(conf, 'inflate_bubble'), 'set_fusato_structure')() - + if self.sarch[1:] == "64": + cmd_list = collections.deque(conf.build64_xfce_build) + list_size = len(cmd_list) + for _ in range(list_size): + i = cmd_list.popleft() + execute = i + '()' + exec(execute) + elif self.sarch[1:] == "32": + cmd_list = collections.deque(conf.build32_xfce_build) + list_size = len(cmd_list) + for _ in range(list_size): + i = cmd_list.popleft() + execute = i + '()' + exec(execute) + elif self.sarch[1:] == "arm": + cmd_list = collections.deque(conf.buildarm_xfce_build) + list_size = len(cmd_list) + for _ in range(list_size): + i = cmd_list.popleft() + execute = i + '()' + exec(execute) + else: + cmd_list = None def cleanup_helper(self): @@ -102,50 +120,39 @@ class BuildXfce: finish_cleanup.make_check_sum() finish_cleanup.check_build_type_xfce() finish_cleanup.kill_old_iso() - + def build_system(self): - """Builds the ISO XFCE Depending on the Arch""" + """ Builds the ISO XFCE Depedning on the Arch """ current_working_directory = os.getcwd() dir_current = WRKING_DIR + current_working_directory logger.info(f"Building a {self.sbase}{self.sarch[1:]} bit ISO") logger.info(dir_current) - # Set the config tree self.lb_helper() - # Start with the XFCE stuff self.xfce_helper() - # Run the specific classes self.infra_helper() - # Run the Build logger.info(CFG_READY) logger.info(START_LIVEBUILD) logger.info(dir_current) - + self.lb_helper() run_cmd = 'sudo lb build' - - # Set the build indicator + current_working_directory = os.getcwd() + os.chdir(HOME_FOLDER + FUSATO_ROOT) + # Set the build inidcator inflate_bubble.make_bld_xfce(self.sbase, self.sarch[1:]) logger.info(dir_current) - - os.chdir(HOME_FOLDER + FUSATO_ROOT) - current_working_directory = os.getcwd() - - # Execute the build command os.system(run_cmd) - logger.info(BUILD_COMPLETED) logger.info(dir_current) - - # Perform cleanup self.cleanup_helper() - logger.info(BUILD_COMPLETED) + class BuildGflashback: """ Determine what base to use and then build the ISO