forked from clrkwllms/realtime-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel-rt-protect.py
28 lines (25 loc) · 1.01 KB
/
kernel-rt-protect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# SPDX-License-Identifier: GPL-2.0-or-later
from yum.plugins import TYPE_INTERACTIVE
requires_api_version = '2.5'
plugin_type = (TYPE_INTERACTIVE,)
def config_hook(conduit):
def get_running_kernel_pkgtup(ts):
"""This takes the output of uname and figures out the pkgtup of the running
kernel (name, arch, epoch, version, release)."""
import os, glob
ver = os.uname()[2]
# we glob for the file that MIGHT have this kernel
# and then look up the file in our rpmdb.
fns = sorted(glob.glob('/boot/vmlinuz*%s*' % ver))
for fn in fns:
mi = ts.dbMatch('basenames', fn)
for h in mi:
e = h['epoch']
if h['epoch'] is None:
e = '0'
else:
e = str(e)
return (h['name'], h['arch'], e, h['version'], h['release'])
return (None, None, None, None, None)
from yum import misc
misc.get_running_kernel_pkgtup = get_running_kernel_pkgtup