# # Copyright (C) 2023 Soleta Networks # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the # Free Software Foundation; either version 3 of the License, or # (at your option) any later version. import logging import os from src.log import OgError def get_vmlinuz_path(mountpoint): linuz_dir = os.path.join(mountpoint, 'boot') target_file = None for file in sorted(os.listdir(linuz_dir)): if file.startswith('vmlinuz-'): target_file = file if not target_file: raise OgError(f'vmlinuz not found in {linuz_dir}') return os.path.join(linuz_dir, target_file) def get_initrd_path(mountpoint): initrd_dir = os.path.join(mountpoint, 'boot') target_file = None for file in sorted(os.listdir(initrd_dir)): if file.startswith('initrd.img-') or file.startswith('initramfs-') and file.endswith('.img'): target_file = file if not target_file: raise OgError(f'initrd not found in {initrd_dir}') return os.path.join(initrd_dir, target_file)