new commit

This commit is contained in:
Manuel 2025-04-28 08:30:23 +00:00
parent 27a9f42bf0
commit d020dda393
2 changed files with 17 additions and 22 deletions

View File

@ -42,7 +42,6 @@ except ImportError as e:
print(f"Error importing necessary modules for install_kernel: {e}. Ensure your environment is set up correctly.") print(f"Error importing necessary modules for install_kernel: {e}. Ensure your environment is set up correctly.")
sys.exit(1) sys.exit(1)
def install_kernel(arch, kernel_type, kernels_config, target_env='rootfs', paths=None, host_arch=None, repositories_data=None): def install_kernel(arch, kernel_type, kernels_config, target_env='rootfs', paths=None, host_arch=None, repositories_data=None):
""" """
Installs the specified kernel in the target environment (rootfs, pep-target, pep-host), Installs the specified kernel in the target environment (rootfs, pep-target, pep-host),
@ -52,7 +51,7 @@ def install_kernel(arch, kernel_type, kernels_config, target_env='rootfs', paths
arch (str): Architecture (e.g., 'aarch64'). arch (str): Architecture (e.g., 'aarch64').
kernel_type (str): Kernel type (e.g., 'current', 'lts', 'mainline'). kernel_type (str): Kernel type (e.g., 'current', 'lts', 'mainline').
kernels_config (dict): Kernel configuration loaded from the YAML file. kernels_config (dict): Kernel configuration loaded from the YAML file.
Expected structure: {kernels: {<kernel_type>: {<architecture>: package_name}}} Expected structure: {kernels: {<kernel_type>: {package_names: {<architecture>: package_name_string}}}}
target_env (str): Target environment to install the kernel in ('rootfs', 'pep-target', 'pep-host'). target_env (str): Target environment to install the kernel in ('rootfs', 'pep-target', 'pep-host').
Defaults to 'rootfs'. Defaults to 'rootfs'.
paths (dict): Dictionary of build paths. Required to get target path and cache dir. paths (dict): Dictionary of build paths. Required to get target path and cache dir.
@ -72,29 +71,29 @@ def install_kernel(arch, kernel_type, kernels_config, target_env='rootfs', paths
logger.error("Paths dictionary is missing or incorrect.") logger.error("Paths dictionary is missing or incorrect.")
raise ValueError("Paths dictionary is required.") raise ValueError("Paths dictionary is required.")
kernel_package_name = None kernel_package_name_string = None
if kernels_config and 'kernels' in kernels_config and kernel_type in kernels_config['kernels']: if kernels_config and 'kernels' in kernels_config and kernel_type in kernels_config['kernels']:
kernel_info_for_type = kernels_config['kernels'][kernel_type] kernel_info_for_type = kernels_config['kernels'][kernel_type]
if isinstance(kernel_info_for_type, dict): if isinstance(kernel_info_for_type, dict):
kernel_package_name = kernel_info_for_type.get(arch) package_names_dict = kernel_info_for_type.get('package_names', {})
if isinstance(package_names_dict, dict):
kernel_package_name_string = package_names_dict.get(arch)
if kernel_package_name: if kernel_package_name_string:
logger.info(f"=> Selected Void Linux kernel package name (YAML) for {arch} / {kernel_type}: {kernel_package_name}") logger.info(f"=> Selected Void Linux kernel package name string (YAML) for {arch} / {kernel_type}: '{kernel_package_name_string}'")
kernel_packages_list = kernel_package_name_string.split()
else: else:
default_package_name = "linux" default_package_name_string = "linux"
logger.warning(f"Kernel type '{kernel_type}' or architecture '{arch}' not found in the YAML configuration. Using '{default_package_name}' as default package name.") logger.warning(f"Kernel type '{kernel_type}' or architecture '{arch}' not found in 'package_names' section of the YAML configuration. Using '{default_package_name_string}' as default package name string.")
kernel_package_name = default_package_name kernel_packages_list = [default_package_name_string]
if not kernel_package_name: if not kernel_packages_list:
logger.error(f"Kernel package name is empty even after fallback. Cannot install kernel.") logger.error(f"Kernel package list is empty even after fallback. Cannot install kernel.")
raise ValueError("Kernel package name is not defined.") raise ValueError("Kernel package list is not defined.")
adapted_package_structure = {target_env: {arch: [kernel_package_name]}}
adapted_package_structure = {target_env: {arch: kernel_packages_list}}
kernel_packages_args = bootstrap.construct_xbps_install_args( kernel_packages_args = bootstrap.construct_xbps_install_args(
target_env, target_env,
paths,
arch, arch,
repositories_data, repositories_data,
adapted_package_structure adapted_package_structure

View File

@ -207,10 +207,6 @@ def iso_builder_main(
) )
kernels_config = load_yaml_config(paths['KERNELS_CONFIG_YAML'], 'kernels.yaml') kernels_config = load_yaml_config(paths['KERNELS_CONFIG_YAML'], 'kernels.yaml')
logger.info(f"=> DEBUG: Kernel YAML file path loaded: {paths['KERNELS_CONFIG_YAML']}") # Linha de debug temporária
import json # Importa a biblioteca json para formatar o dicionário
logger.info(f"=> DEBUG: Loaded kernels_config content: {json.dumps(kernels_config, indent=2)}") # Linha de debug temporária
install_kernel( install_kernel(
arch=architecture, arch=architecture,
kernel_type=kernel_type, kernel_type=kernel_type,