blob: 764bb2d33c494d266fe9deecee63eabf89a50629 (
plain)
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
|
#!/usr/bin/env python3
def kernel_version(path):
version = None
patchlevel = None
sublevel = None
with open(path + 'Makefile') as f:
for line in f:
if line.startswith('VERSION ='):
version = line[len('VERSION ='):].strip()
elif line.startswith('PATCHLEVEL ='):
patchlevel = line[len('PATCHLEVEL ='):].strip()
elif line.startswith('SUBLEVEL ='):
sublevel = line[len('SUBLEVEL ='):].strip()
assert(version and patchlevel and sublevel)
return '.'.join([version, patchlevel, sublevel])
if __name__ == '__main__':
from sys import argv
path = argv[1]
if path[:-1] != '/':
path += '/'
print(kernel_version(path))
|