diff --git a/builder/core/initramfs_builder.py b/builder/core/initramfs_builder.py index a2e483fe..e87785b6 100644 --- a/builder/core/initramfs_builder.py +++ b/builder/core/initramfs_builder.py @@ -54,14 +54,15 @@ def execute_xbps_uhelper_chroot(rootfs_path, xbps_uhelper_args, iso_build_config completed_process = subprocess.run(command_xbps_uhelper, capture_output=True, text=True) return completed_process.stdout.strip() -def copy_kernel_image(rootfs_path, boot_path, iso_build_config): +def copy_kernel_image(rootfs_path, boot_path, target_architecture, iso_build_config): """ Copies the kernel image file (vmlinuz or vmlinux) from the ROOTFS to the ISO's BOOT directory, renaming it to 'vmlinuz' (x86_64, i686) or 'vmlinux' (aarch64) and using the correct kernel version. """ logger.info("=> Copying kernel image to the ISO BOOT directory...") - kernel_versions = get_kernel_version_in_chroot(rootfs_path, iso_build_config) + kernel_versions = get_kernel_version_in_chroot(rootfs_path, target_architecture, iso_build_config) + if not kernel_versions or 'version_final_part' not in kernel_versions: logger.error("=> ERROR: Could not obtain kernel version to copy the image.") raise ValueError("Could not obtain kernel version.") @@ -108,38 +109,25 @@ def copy_kernel_image(rootfs_path, boot_path, iso_build_config): return kernel_path_in_boot def get_kernel_version_in_chroot(rootfs_path, target_architecture, iso_build_config): - logger.info("=> DEBUG: Entering get_kernel_version_in_chroot...") - target_arch = target_architecture.lower() - - logger.info(f"=> DEBUG: get_kernel_version_in_chroot using target_arch: '{target_arch}'") - boot_dir = os.path.join(rootfs_path, 'boot') - logger.info(f"=> DEBUG: get_kernel_version_in_chroot checking directory: '{boot_dir}'") - try: boot_files = os.listdir(boot_dir) - logger.info(f"=> DEBUG: get_kernel_version_in_chroot found files: {boot_files}") except FileNotFoundError: logger.error(f"=> ERROR: /boot directory not found at: {boot_dir}") return None kernel_version = None for filename in boot_files: - logger.info(f"=> DEBUG: Checking filename: '{filename}'") if target_arch.startswith('i686') or target_arch == 'x86_64': if filename.startswith('vmlinuz-'): - logger.info(f"=> DEBUG: Matched vmlinuz pattern for x86/i686: '{filename}'") kernel_version = filename.replace('vmlinuz-', '') break elif target_arch == 'aarch64': if filename.startswith('vmlinux-'): - logger.info(f"=> DEBUG: Matched vmlinux pattern for aarch64: '{filename}'") kernel_version = filename.replace('vmlinux-', '') break - logger.info(f"=> DEBUG: kernel_version after loop: '{kernel_version}'") - if not kernel_version: logger.error(f"=> ERROR: Kernel image not found in: {boot_dir}") return None @@ -150,7 +138,6 @@ def get_kernel_version_in_chroot(rootfs_path, target_architecture, iso_build_con 'version_final_part': kernel_version, 'version_major_minor': ".".join(kernel_version.split('.')[:2]) } - logger.info(f"=> DEBUG: kernel_versions_dict: {kernel_versions_dict}") return kernel_versions_dict def get_kernel_module_dir_in_chroot(rootfs_path, kernel_version): @@ -187,7 +174,6 @@ def create_initramfs(rootfs_path, boot_path, target_architecture, xbps_commands, "/boot/initrd", kernel_version_final_part, ] - logger.info("=> *** EXTRA CHECK: EXECUTING CORRECTED ISO_BUILDER.PY SCRIPT VERSION (BEFORE DRACUT!) ***") try: subprocess.run(dracut_command, check=True) except subprocess.CalledProcessError as e: