Get the full path to a kernel image based on the architecture and image name if necessary. Parameters: kernel_location (str): Absolute or relative path to kernel image or kernel build folder. image (str): Kernel image name. arch (s
(kernel_location: Path | str, image: str, arch: str | None = None)
| 107 | |
| 108 | |
| 109 | def get_full_kernel_path(kernel_location: Path | str, image: str, arch: str | None = None) -> Path: |
| 110 | """ |
| 111 | Get the full path to a kernel image based on the architecture and image |
| 112 | name if necessary. |
| 113 | |
| 114 | Parameters: |
| 115 | kernel_location (str): Absolute or relative path to kernel image or |
| 116 | kernel build folder. |
| 117 | image (str): Kernel image name. |
| 118 | arch (str, optional): Architecture name according to Kbuild; should be |
| 119 | the parent of the "boot" folder containing the |
| 120 | kernel image (default: None). |
| 121 | """ |
| 122 | kernel_location = Path(kernel_location) |
| 123 | |
| 124 | # If '-k' is a file, we can just use it directly |
| 125 | if kernel_location.is_file(): |
| 126 | kernel = kernel_location |
| 127 | # If the image is an uncompressed vmlinux or a UML image, it is in the |
| 128 | # root of the build folder |
| 129 | elif image in {"vmlinux", "linux"}: |
| 130 | kernel = kernel_location.joinpath(image) |
| 131 | # Otherwise, it is in the architecture's boot directory |
| 132 | elif arch: |
| 133 | kernel = kernel_location.joinpath("arch", arch, "boot", image) |
| 134 | else: |
| 135 | die(f"Kernel image ('{image}') is in the arch/ directory but 'arch' was not provided!") |
| 136 | |
| 137 | if not kernel.exists(): |
| 138 | die(f"Kernel ('{kernel}') does not exist!") |
| 139 | |
| 140 | return kernel.resolve() |
| 141 | |
| 142 | |
| 143 | def get_gh_json(endpoint: str) -> dict[str, Any]: |