Skip to content

Commit

Permalink
lib(kernel): iteratively query whatprovides
Browse files Browse the repository at this point in the history
  • Loading branch information
mhecko committed Aug 15, 2023
1 parent 4f02006 commit 55996d5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions repos/system_upgrade/common/libraries/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,21 @@ def get_kernel_pkg_info_for_uname_r(uname_r):
:returns: Information about the kernel package providing given uname_r
:rtype: KernelPkgInfo
"""
try:
kernel_pkg_nevras = run(['rpm', '-q', '--whatprovides'] + KERNEL_UNAME_R_PROVIDES, split=True)['stdout']
for kernel_pkg_nevra in kernel_pkg_nevras:
provided_uname = get_uname_r_provided_by_kernel_pkg(kernel_pkg_nevra)
if not provided_uname:
api.current_logger().warning('Failed to obtain uname-r provided by %s', kernel_pkg_nevra)
if provided_uname == uname_r:
return get_kernel_pkg_info(kernel_pkg_nevra)
except CalledProcessError as e:
raise StopActorExecutionError(message='Unable to obtain kernel information of the booted kernel.',
details={'details': str(e), 'stderr': e.stderr})
kernel_pkg_nevras = []
for kernel_uname_r_provide in KERNEL_UNAME_R_PROVIDES:
try:
kernel_pkg_nevras += run(['rpm', '-q', '--whatprovides', kernel_uname_r_provide], split=True)['stdout']
except CalledProcessError: # There is nothing providing a particular provide, e.g, kernel-rt-uname-r
continue # Nothing bad happened, continue

kernel_pkg_nevras = set(kernel_pkg_nevras)

for kernel_pkg_nevra in kernel_pkg_nevras:
provided_uname = get_uname_r_provided_by_kernel_pkg(kernel_pkg_nevra) # We know all packages provide a uname
if not provided_uname:
api.current_logger().warning('Failed to obtain uname-r provided by %s', kernel_pkg_nevra)
if provided_uname == uname_r:
return get_kernel_pkg_info(kernel_pkg_nevra)

raise StopActorExecutionError(message='Unable to obtain kernel information of the booted kernel: no package is '
'providing the booted kernel release returned by uname.')

0 comments on commit 55996d5

Please sign in to comment.