MCPcopy Create free account
hub / github.com/ClangBuiltLinux/boot-utils / get_full_kernel_path

Function get_full_kernel_path

utils.py:109–140  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

dieFunction · 0.85

Tested by

no test coverage detected