forked from CharlesWang/ali_kernel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
kabitool
103 lines (77 loc) · 1.99 KB
/
kabitool
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/python
#
# kabitool - Red Hat kABI extraction tool (version 2)
#
# We use this script to generate RPM dependencies based on symversions.
#
# Author: Jon Masters <jcm@redhat.com>
# Copyright (C) 2009 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# General Public License (GPL).
# Changelog:
#
# 2009/08/01 - New version based on kABI dep plan for RHEL6.
#
__author__ = "Jon Masters <jcm@redhat.com>"
__version__ = "$Revisions: 2.0 $"
__date__ = "$Date$"
__copyright__ = "Copyright (C) 2009 Red Hat, Inc"
__license__ = "GPL"
import getopt
import os
import re
import sha
import string
import sys
true = 1
false = 0
def load_symbols(filename):
"""Load the kernel exported symbols from Module.symvers."""
ksyms = open(filename,"r")
symbols={}
while true:
line = ksyms.readline()
if line == "":
break;
if line == "\n":
continue
checksum,symbol,path,license = string.split(line)
symbols[symbol] = dict(checksum=checksum,
path=path,
license=license)
return symbols
def output_deps(depsfile,symbols):
deps_file = open(depsfile,"w")
for symbol in sorted(symbols.keys()):
deps_file.write("kernel("+symbol+") = " +
symbols[symbol]['checksum'] + "\n")
def usage():
print """
kabitool: process Module.symvers into useful exported kABI dependencies
kabitool [-k kernel] [-s symbols ]
-o The file to output sorted dependencies to
-s The Module.symvers file to import from
"""
if __name__ == "__main__":
symdeps_file = ""
symvers_file = ""
opts, args = getopt.getopt(sys.argv[1:], 'ho:s:')
for o, v in opts:
if o == "-h":
usage()
sys.exit(0)
if o == "-o":
symdeps_file = v
if o == "-s":
symvers_file = v
if (symdeps_file == ""):
symdeps_file = "Module.symdeps"
if (symvers_file == ""):
symvers_file = "Module.symvers"
if not (os.path.isfile(symvers_file)):
print "cannot read Module.symvers file"
usage()
exit(1)
symbols = load_symbols(symvers_file)
output_deps(symdeps_file, symbols)