summaryrefslogtreecommitdiff
path: root/gentree.py
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2013-10-30 22:13:49 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2013-10-31 22:49:27 +0100
commit86d99c9d455e5695a24cf8504f2ba0a0cde9ce28 (patch)
tree93412cb5ecf4530ffbbf1e33936e0931002f27c8 /gentree.py
parent338c4388ccd4bc5829c9c0c5953264f529ae1ad4 (diff)
backports: replace netlink portid by semantic patch
Introduce the infrastructure to apply semantic patches and make use of it for the (frequently breaking) portid patch for netlink. Unfortunately this is significantly slower: before: real 0m14.312s user 0m12.144s sys 0m1.784s after: real 0m25.932s user 0m21.768s sys 0m2.932s Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'gentree.py')
-rwxr-xr-xgentree.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/gentree.py b/gentree.py
index 744f48da..e16e2976 100755
--- a/gentree.py
+++ b/gentree.py
@@ -594,10 +594,13 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None,
logwrite('Apply patches ...')
patches = []
+ sempatches = []
for root, dirs, files in os.walk(os.path.join(source_dir, 'patches')):
for f in files:
if f.endswith('.patch'):
patches.append(os.path.join(root, f))
+ if f.endswith('.cocci'):
+ sempatches.append(os.path.join(root, f))
patches.sort()
prefix_len = len(os.path.join(source_dir, 'patches')) + 1
for pfile in patches:
@@ -675,6 +678,39 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None,
os.unlink(os.path.join(root, f))
git_debug_snapshot(args, "apply backport patch %s" % print_name)
+ sempatches.sort()
+ prefix_len = len(os.path.join(source_dir, 'patches')) + 1
+ for cocci_file in sempatches:
+ print_name = cocci_file[prefix_len:]
+ if args.verbose:
+ logwrite("Applying patch %s" % print_name)
+
+ process = subprocess.Popen(['spatch', '--sp-file', cocci_file, '--in-place',
+ '--backup-suffix', '.cocci_backup', '--dir', '.'],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ close_fds=True, universal_newlines=True,
+ cwd=args.outdir)
+ output = process.communicate()[0]
+ output = output.split('\n')
+ if output[-1] == '':
+ output = output[:-1]
+ if args.verbose:
+ for line in output:
+ logwrite('> %s' % line)
+ if process.returncode != 0:
+ if not args.verbose:
+ logwrite("Failed to apply changes from %s" % print_name)
+ for line in output:
+ logwrite('> %s' % line)
+ return 2
+
+ # remove cocci_backup files
+ for root, dirs, files in os.walk(args.outdir):
+ for f in files:
+ if f.endswith('.cocci_backup'):
+ os.unlink(os.path.join(root, f))
+ git_debug_snapshot(args, "apply backport patch %s" % print_name)
+
# some post-processing is required
configtree = kconfig.ConfigTree(os.path.join(args.outdir, 'Kconfig'))
logwrite('Modify Kconfig tree ...')