summaryrefslogtreecommitdiff
path: root/devel/gplizer
blob: 209bb95ef9dce6087f65d4b021cd6a67aa64c4ef (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
28
#!/usr/bin/env python
"""
 gplizer
=========

This modifies C files with EXPORT_SYMBOL() to EXPORT_SYMBOL_GPL().
We use this as Python code here as we may use it later for broader
substitutions. We keep it in backports as typically we forget to
use EXPORT_SYMBOL_GPL() when backporting kernel symbols.

In short this does this but in Python:

for i in $(find ./ -type f -name \*.c); do
	perl -pi -e'$_ =~ s|EXPORT_SYMBOL\(|EXPORT_SYMBOL_GPL\(|gs;' $i
done
"""

import os, fileinput

def gplize(f):
    for line in fileinput.input(f, inplace=1):
        print line.replace('EXPORT_SYMBOL(','EXPORT_SYMBOL_GPL('),

if __name__ == '__main__':
    for root, dirs, files in os.walk(os.getcwd()):
        for f in files: 
            if f.endswith('.c'):
                gplize(os.path.join(root, f))