fix(image): select actual Gentoo distribution kernel image
This commit is contained in:
+19
-4
@@ -129,16 +129,29 @@ def copy_overlay(root, overlay):
|
||||
destination.chmod(source.stat().st_mode & 0o777)
|
||||
|
||||
|
||||
def kernel_version(root):
|
||||
def _kernel_version(root):
|
||||
modules = root_path(root, 'lib/modules')
|
||||
versions = sorted(path.name for path in modules.iterdir() if path.is_dir()) if modules.is_dir() else []
|
||||
if len(versions) != 1 or not re.fullmatch(r'[A-Za-z0-9_.+-]+', versions[0]):
|
||||
raise ImageError('Exactly one installed payload kernel is required')
|
||||
if not root_path(root, 'boot/vmlinuz-' + versions[0]).is_file():
|
||||
raise ImageError('Installed modules have no matching /boot/vmlinuz-VERSION')
|
||||
return versions[0]
|
||||
|
||||
|
||||
def kernel_image(root):
|
||||
version = _kernel_version(root)
|
||||
candidates = [root_path(root, 'boot/' + prefix + version)
|
||||
for prefix in ('kernel-', 'vmlinuz-')]
|
||||
images = [path for path in candidates if path.is_file()]
|
||||
if len(images) != 1:
|
||||
raise ImageError('Installed modules require exactly one matching boot kernel image')
|
||||
return images[0]
|
||||
|
||||
|
||||
def kernel_version(root):
|
||||
kernel_image(root)
|
||||
return _kernel_version(root)
|
||||
|
||||
|
||||
def live_kernel_args():
|
||||
return [f'root=live:CDLABEL={LABEL}', 'rd.live.image', 'rd.live.overlay.overlayfs=1',
|
||||
'ro', 'console=tty0', 'console=ttyS0,115200n8']
|
||||
@@ -356,7 +369,7 @@ def digest(path):
|
||||
|
||||
def main(argv=None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('step', choices=('configure', 'kernel', 'network', 'audio'))
|
||||
parser.add_argument('step', choices=('configure', 'kernel', 'kernel-image', 'network', 'audio'))
|
||||
parser.add_argument('root', nargs='?', type=Path)
|
||||
parser.add_argument('--source', type=Path)
|
||||
options = parser.parse_args(argv)
|
||||
@@ -367,6 +380,8 @@ def main(argv=None):
|
||||
raise ImageError('An isolated rootfs directory is required')
|
||||
if options.step == 'kernel':
|
||||
print(kernel_version(options.root))
|
||||
elif options.step == 'kernel-image':
|
||||
print(kernel_image(options.root))
|
||||
elif options.step == 'audio':
|
||||
enable_user_audio(options.root)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user