From d97f347a6afd8740d88178915e7ece34da93bc88 Mon Sep 17 00:00:00 2001 From: Manuel Date: Mon, 28 Apr 2025 00:39:49 +0000 Subject: [PATCH] new commit --- builder/core/bootstrap/bootstrap.py | 23 +++++------------------ builder/core/packages_install.py | 2 +- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/builder/core/bootstrap/bootstrap.py b/builder/core/bootstrap/bootstrap.py index 2561d7d5..cfacc06a 100644 --- a/builder/core/bootstrap/bootstrap.py +++ b/builder/core/bootstrap/bootstrap.py @@ -1,34 +1,24 @@ -# builder/core/bootstrap.py (Apenas Construção de Argumentos) - import os import logging import platform import sys -# shutil não é necessário neste ficheiro com esta estratégia - -# base_dir e sys.path.insert são geralmente feitos no script principal -# from builder.core.bootstrap.paths import paths # Não é necessário importar paths aqui try: from builder.configs import logger_config - # from builder.core.command_runner import run_command # Não precisamos de run_command neste ficheiro com esta estratégia except ImportError as e: - # Usar print ou logger básico se logger_config falhar try: basic_logger = logging.getLogger(__name__) - logging.basicConfig(level=logging.ERROR) # Configurar um logger básico para erro + logging.basicConfig(level=logging.ERROR) basic_logger.error(f"Error importing necessary modules for bootstrap helper: {e}. Ensure your environment is set up correctly.") except Exception: print(f"Error importing necessary modules for bootstrap helper: {e}. Ensure your environment is set up correctly.") sys.exit(1) -# Configurar logger para este módulo try: logger = logger_config.setup_logger('bootstrap') except NameError: - # Fallback logger se logger_config não estiver disponível - logging.basicConfig(level=logging.INFO) # Nível INFO por padrão para este helper + logging.basicConfig(level=logging.INFO) logger = logging.getLogger('bootstrap') @@ -109,7 +99,7 @@ def construct_xbps_install_args(env_name, paths, target_architecture, repositori if not packages_to_install: logger.warning(f"No packages defined for {env_name} on architecture {target_architecture}. Skipping command construction.") - return [] # Return empty list if no packages + return [] filtered_repo_args = filter_repositories_by_architecture(repositories_data, target_architecture) @@ -117,18 +107,15 @@ def construct_xbps_install_args(env_name, paths, target_architecture, repositori logger.error(f"No repositories found supporting target architecture: {target_architecture}. Cannot construct command for {env_name}.") raise ValueError(f"No repositories found for architecture {target_architecture}") - # Get the XBPS cache directory for the target architecture (on the host) host_cachedir = os.path.join(os.getcwd(), "xbps_package_cache", target_architecture) os.makedirs(host_cachedir, exist_ok=True) logger.debug(f"Using XBPS cache directory (on host): {host_cachedir}") - # Construct the xbps-install command arguments - # This command will be run directly on the host, targeting the specified directory (-r) xbps_command_args = [ "-S", "-y", ] + filtered_repo_args + [ - "-r", target_directory_path, # Install to the target directory (path on host) - "-c", host_cachedir, # XBPS cache directory (path on host) + "-r", target_directory_path, + "-c", host_cachedir, ] + packages_to_install logger.info(f"Constructed arguments for {env_name}: {xbps_command_args}") diff --git a/builder/core/packages_install.py b/builder/core/packages_install.py index b4527765..d1279bc8 100644 --- a/builder/core/packages_install.py +++ b/builder/core/packages_install.py @@ -31,7 +31,7 @@ try: from builder.core.command_runner import run_command from builder.configs import logger_config from builder.core.config_loader import load_yaml_config - from builder.core import bootstrap + from builder.core.bootstrap import bootstrap logger = logger_config.setup_logger('packages_install') except ImportError as e: