'however run `kup ls` on the target paths so ' +
'at the very least we test your kup configuration. ' +
'If this is your first time uploading use this first!')
+ parser.add_argument('--test-cocci', metavar='<sp_file>', type=str, default=None,
+ help='Only use the cocci file passed for Coccinelle, don\'t do anything else, ' +
+ 'also creates a git repo on the target directory for easy inspection ' +
+ 'of changes done by Coccinelle.')
args = parser.parse_args()
def logwrite(msg):
extra_driver=args.extra_driver,
kup=args.kup,
kup_test=args.kup_test,
+ test_cocci=args.test_cocci,
logwrite=logwrite)
def process(kerneldir, outdir, copy_list_file, git_revision=None,
clean=False, refresh=False, base_name="Linux", gitdebug=False,
verbose=False, extra_driver=[], kup=False,
kup_test=False,
+ test_cocci=None,
logwrite=lambda x:None,
git_tracked_version=False):
class Args(object):
def __init__(self, kerneldir, outdir, copy_list_file,
git_revision, clean, refresh, base_name,
gitdebug, verbose, extra_driver, kup,
- kup_test):
+ kup_test,
+ test_cocci):
self.kerneldir = kerneldir
self.outdir = outdir
self.copy_list = copy_list_file
self.extra_driver = extra_driver
self.kup = kup
self.kup_test = kup_test
+ self.test_cocci = test_cocci
+ if self.test_cocci:
+ self.gitdebug = True
def git_paranoia(tree=None, logwrite=lambda x:None):
data = git.paranoia(tree)
if (data['r'] != 0):
args = Args(kerneldir, outdir, copy_list_file,
git_revision, clean, refresh, base_name,
- gitdebug, verbose, extra_driver, kup, kup_test)
+ gitdebug, verbose, extra_driver, kup, kup_test,
+ test_cocci)
rel_prep = None
# start processing ...
bpcfg.disable_symbols(disable_list)
git_debug_snapshot(args, 'Add automatic backports')
+ # Extend with other tests for Coccinelle
+ test_cocci = args.test_cocci
+
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'):
+ if not test_cocci and f.endswith('.patch'):
patches.append(os.path.join(root, f))
if f.endswith('.cocci'):
+ if test_cocci:
+ if f not in test_cocci:
+ continue
+ if args.test_cocci:
+ logwrite("Testing Coccinelle SmPL patch: %s" % test_cocci)
sempatches.append(os.path.join(root, f))
patches.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)
+ logwrite("Applying SmPL patch %s" % print_name)
- output = coccinelle.threaded_spatch(cocci_file, args.outdir, logwrite, print_name)
+ output = coccinelle.threaded_spatch(cocci_file, args.outdir,
+ logwrite, print_name,
+ test_cocci)
output = output.split('\n')
if output[-1] == '':
output = output[:-1]
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)
+ git_debug_snapshot(args, "apply backport SmPL patch %s" % print_name)
+
+ if test_cocci:
+ logwrite('Done!')
+ return 0
# some post-processing is required
configtree = kconfig.ConfigTree(os.path.join(args.outdir, 'Kconfig'))