new commit
This commit is contained in:
parent
88eb59ff06
commit
863c17afba
@ -1,5 +1,3 @@
|
||||
# Assuming this is in builder/core/packages_install.py
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
SPDX-FileCopyrightText: 2023-2025 PeppermintOS Team
|
||||
@ -26,24 +24,17 @@ import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
# BASE_DIR and sys.path.insert might be needed at the top of this file too if it's run standalone
|
||||
# BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
# sys.path.insert(0, BASE_DIR)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.insert(0, BASE_DIR)
|
||||
|
||||
try:
|
||||
# Import modules used by this function
|
||||
from builder.core.command_runner import run_command
|
||||
# xbps_commands is likely not needed here as construct_xbps_install_args handles it
|
||||
# from builder.core.xbps_commands import xbps_commands
|
||||
from builder.configs import logger_config
|
||||
# paths is passed as argument, so not needed as direct import
|
||||
# from builder.core.bootstrap.paths import paths
|
||||
from builder.core.config_loader import load_yaml_config # Needed to load common packages YAML
|
||||
from builder.core import bootstrap # Import bootstrap module for construct_xbps_install_args
|
||||
from builder.core.config_loader import load_yaml_config
|
||||
from builder.core import bootstrap
|
||||
|
||||
logger = logger_config.setup_logger('packages_install') # Setup logger for this module
|
||||
logger = logger_config.setup_logger('packages_install')
|
||||
except ImportError as e:
|
||||
# Handle import error for this module
|
||||
try:
|
||||
basic_logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
@ -53,9 +44,6 @@ except ImportError as e:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# MODIFIED FUNCTION SIGNATURE to accept 5 arguments, using names from the call in iso_builder_main
|
||||
# Note: The first argument name 'rootfs_path' is kept for clarity but the actual rootfs path
|
||||
# will be obtained from the 'paths' dictionary passed as the first argument.
|
||||
def install_common_packages_rootfs_yaml(paths, common_packages_yaml_path, target_architecture, host_architecture, repositories_data):
|
||||
"""
|
||||
Installs common packages into the rootfs from a YAML file, using the host-execution strategy.
|
||||
@ -74,72 +62,45 @@ def install_common_packages_rootfs_yaml(paths, common_packages_yaml_path, target
|
||||
ValueError: If configuration data is missing or incorrect.
|
||||
KeyError: If required paths are not found.
|
||||
"""
|
||||
# Re-initialize logger if needed, or rely on module-level logger
|
||||
# logger = logging.getLogger(__name__) # Remove this line if logger is setup at module level
|
||||
|
||||
logger.info(f"=> Installing common packages into ROOTFS ({target_architecture}) using YAML: {common_packages_yaml_path}")
|
||||
|
||||
# Ensure paths dict is available
|
||||
if not isinstance(paths, dict):
|
||||
logger.error("Paths dictionary is missing or incorrect.")
|
||||
raise ValueError("Paths dictionary is required.")
|
||||
|
||||
# Get the actual rootfs path from the paths dictionary
|
||||
rootfs_path = paths.get("ROOTFS")
|
||||
if not rootfs_path:
|
||||
logger.error(f"Path for environment 'rootfs' not found in paths dictionary.")
|
||||
raise KeyError(f"Path for environment 'rootfs' not found.")
|
||||
|
||||
|
||||
# Load common packages configuration from the specified YAML path
|
||||
# Assumes common_packages_yaml_path points to a YAML structured like {arch: [package list]}
|
||||
try:
|
||||
common_packages_config = load_yaml_config(common_packages_yaml_path, os.path.basename(common_packages_yaml_path))
|
||||
except Exception as e: # load_yaml_config should handle FileNotFoundError/YAMLError
|
||||
except Exception as e:
|
||||
logger.error(f"Error loading common packages YAML '{common_packages_yaml_path}': {e}")
|
||||
raise # Re-raise the exception
|
||||
raise
|
||||
|
||||
# Get the list of common packages specifically for the target architecture
|
||||
# The YAML structure is expected to be {<architecture>: [package1, package2, ...]}
|
||||
common_packages_for_arch = common_packages_config.get(target_architecture, [])
|
||||
|
||||
if not common_packages_for_arch:
|
||||
logger.warning(f"No common packages defined for architecture {target_architecture} in {common_packages_yaml_path}. Skipping installation.")
|
||||
return # Exit the function
|
||||
return
|
||||
|
||||
# Construct the xbps-install command arguments using the helper from bootstrap module
|
||||
# construct_xbps_install_args expects the package list in the structure {'env_name': {'arch': [package_list]}}
|
||||
# So, we adapt the common package list for the target architecture into this structure temporarily.
|
||||
# We pass "rootfs" as env_name because we are installing into the rootfs environment.
|
||||
adapted_package_structure = {"rootfs": {target_architecture: common_packages_for_arch}}
|
||||
|
||||
# construct_xbps_install_args handles repository filtering, -r, -c args internally
|
||||
# It needs paths, target_architecture, repositories_data, and the adapted package structure
|
||||
common_packages_args = bootstrap.construct_xbps_install_args(
|
||||
"rootfs", # Environment name for paths/package lookup within the structure
|
||||
paths, # Paths dictionary (needed by construct_xbps_install_args for rootfs path and cache)
|
||||
target_architecture, # Target architecture
|
||||
repositories_data, # All repository data
|
||||
adapted_package_structure # Pass common packages in the structure expected by construct_xbps_install_args
|
||||
"rootfs",
|
||||
paths,
|
||||
target_architecture,
|
||||
repositories_data,
|
||||
adapted_package_structure
|
||||
)
|
||||
|
||||
if not common_packages_args:
|
||||
logger.warning("Skipping common packages installation due to failure in constructing xbps-install arguments.")
|
||||
# The error was likely logged within construct_xbps_install_args
|
||||
return # Exit the function
|
||||
return
|
||||
|
||||
|
||||
# Execute the xbps-install command directly on the host, targeting the rootfs
|
||||
# Prepend the xbps-install binary path on the host
|
||||
common_install_command = ["/usr/bin/xbps-install"] + common_packages_args
|
||||
|
||||
logger.info(f"Executing common packages installation command (host): {' '.join(common_install_command)}")
|
||||
try:
|
||||
run_command(common_install_command) # Use the existing run_command helper
|
||||
run_command(common_install_command)
|
||||
logger.info(f"=> Installation of common packages into ROOTFS completed.")
|
||||
except Exception as e: # Catching general Exception, consider more specific CalledProcessError
|
||||
except Exception as e:
|
||||
logger.error(f"Error executing XBPS_INSTALL_CMD for common packages: {e}")
|
||||
raise # Re-raise the exception to stop the build
|
||||
|
||||
# Note: The hardcoded package_categories list and the loop over it are removed
|
||||
# as the packages are now expected to be listed directly under the architecture key in the YAML.
|
||||
# The loading of repos_yaml_file inside this function is removed as repositories_data is passed.
|
||||
raise
|
||||
|
@ -185,13 +185,14 @@ def iso_builder_main(
|
||||
ficheiro_pacotes_desktop_yaml = f'builder/configs/desktops/{desktop_selecionado}.yaml'
|
||||
iso_build_config['desktop'] = desktop
|
||||
iso_build_config['kernel_type'] = kernel_type
|
||||
|
||||
install_common_packages_rootfs_yaml(
|
||||
paths,
|
||||
paths["COMMON_PACKAGES_YAML"],
|
||||
architecture,
|
||||
host_arch,
|
||||
repositories
|
||||
)
|
||||
)
|
||||
desktop_config = load_yaml_config(ficheiro_pacotes_desktop_yaml, desktop_selecionado + ".yaml")
|
||||
install_desktop_environment(
|
||||
arch=architecture,
|
||||
|
Loading…
Reference in New Issue
Block a user