source: chapter10/kernel/kernel_version.py@ 70bf551

12.0 12.0-rc1 12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 70bf551 was 70bf551, checked in by Xi Ruoyao <xry111@…>, 11 months ago

kernel: Use new kernel configuration rendering method

Import kernel-config infrastructure from BLFS and use it for kernel
configuration. Note that kernel-config.py is slightly different from
BLFS: we need role="nodump" for <screen> here.

  • Property mode set to 100755
File size: 752 bytes
Line 
1#!/usr/bin/env python3
2
3def kernel_version(path):
4 version = None
5 patchlevel = None
6 sublevel = None
7
8 with open(path + 'Makefile') as f:
9 for line in f:
10 if line.startswith('VERSION ='):
11 version = line[len('VERSION ='):].strip()
12 elif line.startswith('PATCHLEVEL ='):
13 patchlevel = line[len('PATCHLEVEL ='):].strip()
14 elif line.startswith('SUBLEVEL ='):
15 sublevel = line[len('SUBLEVEL ='):].strip()
16
17 assert(version and patchlevel and sublevel)
18 return '.'.join([version, patchlevel, sublevel])
19
20if __name__ == '__main__':
21 from sys import argv
22
23 path = argv[1]
24 if path[:-1] != '/':
25 path += '/'
26
27 print(kernel_version(path))
Note: See TracBrowser for help on using the repository browser.