new commit
This commit is contained in:
parent
816fbf1978
commit
dba1abc0ca
@ -3,7 +3,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file defines the configuration for different kernel types available for Peppermint Void Linux ISO builds.
|
||||
# This file defines the configuration for different kernel types available for Peppermint Void Linux ISO builds,
|
||||
# including architecture-specific package names.
|
||||
#
|
||||
# Credits:
|
||||
# - PeppermintOS Team (peppermintosteam@proton.me) - Development and maintenance of the project.
|
||||
@ -11,107 +12,168 @@
|
||||
# License:
|
||||
# This code is distributed under the GNU General Public License version 3 or later (GPL-3.0-or-later).
|
||||
# For more details, please refer to the LICENSE file included in the project or visit:
|
||||
# https://www.gnu.org/licenses/gpl-3.0.html
|
||||
# https://www.gnu.org/licenses/gpl-3.0-or-later.html
|
||||
|
||||
kernels:
|
||||
current:
|
||||
display_name: "Linux"
|
||||
full_display_name: "Current (Rolling Release)"
|
||||
package_name: "linux linux-headers " # Meta-package 'linux' points to the latest stable kernel
|
||||
description: "Linux kernel from the 'current' branch of Void Linux. Recommended for most users. Offers a good balance between functionality, support for newer hardware, and stability."
|
||||
package_names:
|
||||
x86_64: "linux linux-headers"
|
||||
i686: "linux linux-headers"
|
||||
aarch64: "linux-aarch64 linux-aarch64-headers"
|
||||
# Adicionar outras arquiteturas conforme suportado por este tipo de kernel
|
||||
|
||||
lts:
|
||||
display_name: "LTS"
|
||||
full_display_name: "LTS (Long Term Support)"
|
||||
package_name: "linux-lts linux-lts-headers " # Meta-package 'linux-lts' for Long Term Support
|
||||
description: "Long Term Support (LTS) Linux kernel from Void Linux. Ideal for systems requiring greater stability and long-term support. May not include the latest drivers."
|
||||
package_names:
|
||||
x86_64: "linux-lts linux-lts-headers"
|
||||
i686: "linux-lts linux-lts-headers"
|
||||
aarch64: "linux-lts-aarch64 linux-lts-aarch64-headers"
|
||||
|
||||
mainline:
|
||||
display_name: "Mainline"
|
||||
full_display_name: "Mainline (Latest)"
|
||||
package_name: "linux-mainline linux-mainline-headers " # Meta-package 'linux-mainline' for the latest kernel
|
||||
description: "The latest 'mainline' Linux kernel from Void Linux. For users who want the newest features and drivers. May be less stable than 'current' or 'LTS'."
|
||||
package_names:
|
||||
x86_64: "linux-mainline linux-mainline-headers"
|
||||
# aarch64: "linux-mainline-aarch64 linux-mainline-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux4.19:
|
||||
display_name: "4.19"
|
||||
full_display_name: "4.19 Series"
|
||||
package_name: "linux4.19 linux4.19-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 4.19 series. An older series. Use only if you have very specific hardware or software requirements for this series."
|
||||
package_names:
|
||||
x86_64: "linux4.19 linux4.19-headers"
|
||||
i686: "linux4.19 linux4.19-headers"
|
||||
# Adicionar outras arquiteturas se suportado
|
||||
|
||||
linux5.4:
|
||||
display_name: "5.4"
|
||||
full_display_name: "5.4 Series"
|
||||
package_name: "linux5.4 linux5.4-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 5.4 series. An older series. Use only if you have very specific hardware or software requirements for this series."
|
||||
package_names:
|
||||
x86_64: "linux5.4 linux5.4-headers"
|
||||
i686: "linux5.4 linux5.4-headers"
|
||||
# Adicionar outras arquiteturas se suportado
|
||||
|
||||
linux5.10:
|
||||
display_name: "5.10"
|
||||
full_display_name: "5.10 Series"
|
||||
package_name: "linux5.10 linux5.10-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 5.10 series. An older series. Use only if you have very specific hardware or software requirements for this series."
|
||||
package_names:
|
||||
x86_64: "linux5.10 linux5.10-headers"
|
||||
i686: "linux5.10 linux5.10-headers"
|
||||
# Adicionar outras arquiteturas se suportado
|
||||
|
||||
linux5.15:
|
||||
display_name: "5.15"
|
||||
full_display_name: "5.15 Series"
|
||||
package_name: "linux5.15 linux5.15-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 5.15 series. Still receiving security updates. May be suitable for older hardware."
|
||||
package_names:
|
||||
x86_64: "linux5.15 linux5.15-headers"
|
||||
i686: "linux5.15 linux5.15-headers"
|
||||
# Adicionar outras arquiteturas se suportado
|
||||
|
||||
linux6.1:
|
||||
display_name: "6.1"
|
||||
full_display_name: "6.1 Series"
|
||||
package_name: "linux6.1 linux6.1-headers " # Explicit series meta-package - LTS
|
||||
description: "Kernel Linux 6.1 series (LTS). A good choice for stability and reasonably recent hardware support. LTS (Long Term Support)."
|
||||
full_display_name: "6.1 Series (LTS)"
|
||||
description: "Kernel Linux 6.1 series (LTS). A good choice for stability and reasonably recent hardware support."
|
||||
package_names:
|
||||
x86_64: "linux6.1 linux6.1-headers"
|
||||
i686: "linux6.1 linux6.1-headers"
|
||||
aarch64: "linux6.1-aarch64 linux6.1-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.5:
|
||||
display_name: "6.5"
|
||||
full_display_name: "6.5 Series"
|
||||
package_name: "linux6.5 linux6.5-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 6.5 series. A more recent series, offering a good balance. May be suitable for newer hardware."
|
||||
package_names:
|
||||
x86_64: "linux6.5 linux6.5-headers"
|
||||
i686: "linux6.5 linux6.5-headers"
|
||||
aarch64: "linux6.5-aarch64 linux6.5-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.6:
|
||||
display_name: "6.6"
|
||||
full_display_name: "6.6 Series"
|
||||
package_name: "linux6.6 linux6.6-headers " # Explicit series meta-package - LTS
|
||||
description: "Kernel Linux 6.6 series (LTS). A more recent LTS series, offering good hardware support and stability. LTS (Long Term Support)."
|
||||
full_display_name: "6.6 Series (LTS)"
|
||||
description: "Kernel Linux 6.6 series (LTS). A more recent LTS series, offering good hardware support and stability."
|
||||
package_names:
|
||||
x86_64: "linux6.6 linux6.6-headers"
|
||||
i686: "linux6.6 linux6.6-headers"
|
||||
aarch64: "linux6.6-aarch64 linux6.6-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.7:
|
||||
display_name: "6.7"
|
||||
full_display_name: "6.7 Series"
|
||||
package_name: "linux6.7 linux6.7-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 6.7 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.7 linux6.7-headers"
|
||||
i686: "linux6.7 linux6.7-headers"
|
||||
aarch64: "linux6.7-aarch64 linux6.7-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.8:
|
||||
display_name: "6.8"
|
||||
full_display_name: "6.8 Series"
|
||||
package_name: "linux6.8 linux6.8-headers " # Explicit series meta-package
|
||||
description: "Kernel Linux 6.8 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.8 linux6.8-headers"
|
||||
i686: "linux6.8 linux6.8-headers"
|
||||
aarch64: "linux6.8-aarch64 linux6.8-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.9:
|
||||
display_name: "6.9"
|
||||
full_display_name: "6.9 Series"
|
||||
package_name: "linux6.9 linux6.9-headers " # Explicit series meta-package - very recent
|
||||
description: "Kernel Linux 6.9 series. Latest stable kernel. For users who want the latest possible kernel with good stability."
|
||||
package_names:
|
||||
x86_64: "linux6.9 linux6.9-headers"
|
||||
i686: "linux6.9 linux6.9-headers"
|
||||
aarch64: "linux6.9-aarch64 linux6.9-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.10: # Stable series - updated to reflect its current status
|
||||
linux6.10:
|
||||
display_name: "6.10"
|
||||
full_display_name: "6.10 Series (Testing)"
|
||||
package_name: "linux6.10 linux6.10-headers " # Explicit series meta-package - very recent
|
||||
description: "Kernel Linux 6.10 series. Very recent kernel series. May be less tested and contain more bugs. For testers and advanced users. Use with caution."
|
||||
full_display_name: "6.10 Series"
|
||||
description: "Kernel Linux 6.10 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.10 linux6.10-headers"
|
||||
i686: "linux6.10 linux6.10-headers"
|
||||
aarch64: "linux6.10-aarch64 linux6.10-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.11: # Kernel Linux série 6.11. Atualizado para estável, adequado para uso geral.
|
||||
linux6.11:
|
||||
display_name: "6.11"
|
||||
full_display_name: "6.11 Series (Testing)"
|
||||
package_name: "linux6.11 linux6.11-headers " # Explicit series meta-package - very recent
|
||||
description: "Kernel Linux 6.11 series. Very recent kernel series. May be less tested and contain more bugs. For testers and advanced users. Use with caution."
|
||||
full_display_name: "6.11 Series"
|
||||
description: "Kernel Linux 6.11 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.11 linux6.11-headers"
|
||||
i686: "linux6.11 linux6.11-headers"
|
||||
aarch64: "linux6.11-aarch64 linux6.11-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.12: # Stable series - updated to reflect its current status
|
||||
linux6.12:
|
||||
display_name: "6.12"
|
||||
full_display_name: "6.12 Series (Testing)"
|
||||
package_name: "linux6.12 linux6.12-headers " # Explicit series meta-package - very recent
|
||||
description: "Kernel Linux 6.12 series. Very recent kernel series. May be less tested and contain more bugs. For testers and advanced users. Use with caution."
|
||||
full_display_name: "6.12 Series" # Removido "(Testing)"
|
||||
description: "Kernel Linux 6.12 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.12 linux6.12-headers"
|
||||
i686: "linux6.12 linux6.12-headers"
|
||||
aarch64: "linux6.12-aarch64 linux6.12-aarch64-headers"
|
||||
# Adicionar outras arquiteturas
|
||||
|
||||
linux6.13: # Kernel Linux série 6.13. Atualizado para estável, adequado para uso geral.
|
||||
linux6.13:
|
||||
display_name: "6.13"
|
||||
full_display_name: "6.13 Series (Testing)"
|
||||
package_name: "linux6.13 linux6.13-headers " # Explicit series meta-package - very recent
|
||||
description: "Kernel Linux 6.13 series. Very recent kernel series. May be less tested and contain more bugs. For testers and advanced users. Use with caution."
|
||||
full_display_name: "6.13 Series"
|
||||
description: "Kernel Linux 6.13 series. Recent kernel series, with updated features and drivers."
|
||||
package_names:
|
||||
x86_64: "linux6.13 linux6.13-headers"
|
||||
i686: "linux6.13 linux6.13-headers"
|
||||
aarch64: "linux6.13-aarch64 linux6.13-aarch64-headers"
|
||||
|
@ -7,12 +7,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
This module provides a function to install the specified kernel package within different
|
||||
environments of the PeppermintOS build process, such as the root filesystem, the pep-target,
|
||||
or the pep-host. It reads kernel package information from a YAML configuration file and
|
||||
or the pep-host, using the host-execution strategy. It reads kernel package information
|
||||
from a YAML configuration file, handling architecture-specific package names, and
|
||||
uses the XBPS package manager for installation.
|
||||
|
||||
The module allows for flexibility in choosing the kernel type (e.g., current, lts, mainline)
|
||||
and handles cases where the specified kernel type is not found in the configuration.
|
||||
|
||||
Credits:
|
||||
- PeppermintOS Team (peppermintosteam@proton.me) - Development and maintenance of the project.
|
||||
|
||||
@ -24,100 +22,97 @@ License:
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import yaml
|
||||
import logging
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.insert(0, BASE_DIR)
|
||||
|
||||
try:
|
||||
from builder.core.xbps_commands import xbps_commands
|
||||
from builder.core.command_runner import run_command
|
||||
from builder.core.bootstrap.paths import paths
|
||||
from builder.configs import logger_config
|
||||
from builder.core.bootstrap import bootstrap
|
||||
|
||||
logger = logger_config.setup_logger('install_kernel')
|
||||
except ImportError as e:
|
||||
print(f"Error importing necessary modules: {e}. Ensure your environment is set up correctly.")
|
||||
try:
|
||||
basic_logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
basic_logger.error(f"Error importing necessary modules for install_kernel: {e}. Ensure your environment is set up correctly.")
|
||||
except Exception:
|
||||
print(f"Error importing necessary modules for install_kernel: {e}. Ensure your environment is set up correctly.")
|
||||
sys.exit(1)
|
||||
|
||||
def install_kernel(arch, kernel_type, kernels_config, target_env='rootfs'):
|
||||
|
||||
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),
|
||||
using the host-execution strategy and handling architecture-specific package names.
|
||||
|
||||
Args:
|
||||
arch (str): Architecture (e.g., 'x86_64').
|
||||
arch (str): Architecture (e.g., 'aarch64').
|
||||
kernel_type (str): Kernel type (e.g., 'current', 'lts', 'mainline').
|
||||
kernels_config (dict): Kernel configuration loaded from the YAML file.
|
||||
Expected structure: {kernels: {<kernel_type>: {<architecture>: package_name}}}
|
||||
target_env (str): Target environment to install the kernel in ('rootfs', 'pep-target', 'pep-host').
|
||||
Defaults to 'rootfs'.
|
||||
paths (dict): Dictionary of build paths. Required to get target path and cache dir.
|
||||
host_arch (str): The architecture of the host system.
|
||||
repositories_data (list): List of repository dictionaries from YAML config.
|
||||
Expected structure: [{'name': '...', 'uri': '...', 'architectures': [...]}, ...]
|
||||
|
||||
Raises:
|
||||
subprocess.CalledProcessError: If the xbps-install command fails.
|
||||
ValueError: If configuration data is missing or incorrect.
|
||||
KeyError: If required paths are not found.
|
||||
"""
|
||||
|
||||
logger.info(f"=> Starting kernel installation: {kernel_type} in environment: {target_env}...")
|
||||
logger.info(f"=> Installing kernel: {kernel_type} ({target_env})")
|
||||
logger.info(f"=> Starting kernel installation: {kernel_type} for {arch} in environment: {target_env}...")
|
||||
|
||||
if paths is None or not isinstance(paths, dict):
|
||||
logger.error("Paths dictionary is missing or incorrect.")
|
||||
raise ValueError("Paths dictionary is required.")
|
||||
|
||||
if target_env == 'rootfs':
|
||||
target_path = paths['ROOTFS']
|
||||
elif target_env == 'pep-host':
|
||||
target_path = paths['PEPHOSTDIR']
|
||||
elif target_env == 'pep-target':
|
||||
target_path = paths['PEPTARGETDIR']
|
||||
else:
|
||||
logger.error(f"Invalid target environment for kernel installation: {target_env}. Installing in ROOTFS by default.")
|
||||
target_path = paths['ROOTFS']
|
||||
target_env = 'rootfs'
|
||||
kernel_package_name = None
|
||||
|
||||
if kernels_config and 'kernels' in kernels_config and kernel_type in kernels_config['kernels']:
|
||||
kernel_info = kernels_config['kernels'][kernel_type]
|
||||
kernel_package_name = kernel_info.get('package_name')
|
||||
kernel_info_for_type = kernels_config['kernels'][kernel_type]
|
||||
if isinstance(kernel_info_for_type, dict):
|
||||
kernel_package_name = kernel_info_for_type.get(arch)
|
||||
|
||||
if kernel_package_name:
|
||||
logger.info(f"=> Selected Void Linux kernel package name (YAML): {kernel_package_name}")
|
||||
logger.info(f"=> Selected Void Linux kernel package name (YAML) for {arch} / {kernel_type}: {kernel_package_name}")
|
||||
else:
|
||||
kernel_package_name = "linux"
|
||||
logger.warning(f"Kernel type '{kernel_type}' not found in the YAML configuration. Installing kernel 'linux' by default.")
|
||||
default_package_name = "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.")
|
||||
kernel_package_name = default_package_name
|
||||
|
||||
if not kernel_package_name:
|
||||
kernel_package_name = "linux"
|
||||
logger.error(f"Kernel package name not defined, even after checking YAML. Using 'linux' as fallback.")
|
||||
logger.error(f"Kernel package name is empty even after fallback. Cannot install kernel.")
|
||||
raise ValueError("Kernel package name is not defined.")
|
||||
|
||||
kernel_packages_list = kernel_package_name.split()
|
||||
adapted_package_structure = {target_env: {arch: [kernel_package_name]}}
|
||||
|
||||
repos_yaml_file = paths['REPOS_YAML_FILE']
|
||||
kernel_packages_args = bootstrap.construct_xbps_install_args(
|
||||
target_env,
|
||||
paths,
|
||||
arch,
|
||||
repositories_data,
|
||||
adapted_package_structure
|
||||
)
|
||||
|
||||
if not kernel_packages_args:
|
||||
logger.warning("Skipping kernel installation due to failure in constructing xbps-install arguments.")
|
||||
else:
|
||||
kernel_install_command = ["/usr/bin/xbps-install"] + kernel_packages_args
|
||||
|
||||
logger.info(f"Executing kernel installation command (host) [TARGETED AT: {target_env}]: {' '.join(kernel_install_command)}")
|
||||
try:
|
||||
with open(repos_yaml_file, 'r') as f:
|
||||
repo_data = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
logger.error(f"Repository YAML file not found: {repos_yaml_file}")
|
||||
return
|
||||
except yaml.YAMLError as e:
|
||||
logger.error(f"Error reading the repository YAML file: {repos_yaml_file} - {e}")
|
||||
return
|
||||
repositories = repo_data.get('repositories', [])
|
||||
|
||||
xbps_install_command = [
|
||||
xbps_commands["XBPS_INSTALL_CMD"], '-S', '-y',
|
||||
'-r', target_path,
|
||||
'-c', os.path.join(paths["ISO_CACHE_DIR"], arch)
|
||||
]
|
||||
|
||||
for repo_dict in repositories:
|
||||
if arch in repo_dict.get('architectures', []):
|
||||
repo_url = repo_dict['uri']
|
||||
xbps_install_command.extend(['-R', repo_url])
|
||||
|
||||
xbps_install_command.extend(kernel_packages_list)
|
||||
|
||||
|
||||
command_str = " ".join(xbps_install_command)
|
||||
logger.info(f"=> Executing XBPS_INSTALL_CMD for kernel [TARGETED AT: {target_path}] (Environment: {target_env}): {command_str}")
|
||||
|
||||
|
||||
try:
|
||||
run_command(xbps_install_command)
|
||||
run_command(kernel_install_command)
|
||||
logger.info(f"=> Kernel installed successfully in the environment: {target_env}.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error installing the kernel in the environment: {target_env}: {e}")
|
||||
raise
|
||||
|
||||
|
||||
logger.info(f"=> Kernel installation: {kernel_type} ({target_env}) completed.")
|
||||
logger.info(f"--------------------------------------------------------------------\n")
|
Loading…
Reference in New Issue
Block a user