rrs_upgrade_history: implement file path filtering

Make it possible to re-collect all the history for a given path.
(Typically this would only be used for debugging, as it saves time if
you are trying to correct an issue with upgrade data collection for a
single recipe.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-08-20 10:28:23 +12:00
parent 8f9c95abff
commit d8011bc305
2 changed files with 28 additions and 3 deletions

View File

@ -71,6 +71,8 @@ def run_internal(maintplanlayerbranch, commit, commitdate, options, logger, bitb
cmd += ' --initial="%s"' % comment
if bitbake_rev:
cmd += ' --bitbake-rev %s' % bitbake_rev
if options.filter_files:
cmd += ' --filter-files %s' % options.filter_files
if options.dry_run:
cmd += ' --dry-run'
if options.loglevel == logging.DEBUG:
@ -131,6 +133,10 @@ def upgrade_history(options, logger):
for maintplanbranch in maintplan.maintenanceplanlayerbranch_set.all():
layerbranch = maintplanbranch.layerbranch
if options.fullreload and not options.dry_run:
logger.debug('fullreload: deleting upgrade objects')
if options.filter_files:
RecipeUpgrade.objects.filter(recipesymbol__layerbranch=layerbranch, filepath__startswith=options.filter_files).delete()
else:
RecipeUpgrade.objects.filter(recipesymbol__layerbranch=layerbranch).delete()
layer = layerbranch.layer
urldir = layer.get_fetch_dir()
@ -195,6 +201,9 @@ def upgrade_history(options, logger):
if layersubdir_start and not (diffitem.a_path.startswith(layersubdir_start) or diffitem.b_path.startswith(layersubdir_start)):
# Not in this layer, skip it
continue
if options.filter_files and not (diffitem.a_path.startswith(options.filter_files) or diffitem.b_path.startswith(options.filter_files)):
# Doesn't match path filter
continue
if diffitem.a_path.endswith(('.bb', '.inc')) or diffitem.b_path.endswith(('.bb', '.inc')):
# We need to look at this commit
touches_recipe = True
@ -211,7 +220,7 @@ def upgrade_history(options, logger):
continue
logger.debug("Analysing commit %s ..." % ct)
run_internal(maintplanbranch, ct, ctdate, options, logger, bitbake_map)
if not options.dry_run:
if not (options.dry_run or options.filter_files):
maintplanbranch.upgrade_rev = ct
maintplanbranch.upgrade_date = ctdate
maintplanbranch.save()
@ -247,6 +256,10 @@ if __name__=="__main__":
help="Specify maintenance plan to operate on (default is all plans that have updates enabled)",
action="store", dest="plan", default=None)
parser.add_option("-F", "--filter-files",
help="Only operate on a specified subset of files (filepath 'startswith')",
action="store", dest="filter_files", default='')
parser.add_option("--regroup",
help="Re-group records only",
action="store_true", dest="regroup", default=False)
@ -254,4 +267,8 @@ if __name__=="__main__":
options, args = parser.parse_args(sys.argv)
logger.setLevel(options.loglevel)
if options.filter_files and not options.plan:
logger.error('-F/--filter-files must be specified in conjunction with -p/--plan and --fullreload')
sys.exit(1)
upgrade_history(options, logger)

View File

@ -349,7 +349,11 @@ def generate_history(options, layerbranch_id, commit, logger):
deleted = []
moved = []
else:
fns, deleted, moved = _get_recipes_filenames(commit, repo, repodir, layersubdir_start, logger)
if options.filter_files:
filepath_start = options.filter_files
else:
filepath_start = layersubdir_start
fns, deleted, moved = _get_recipes_filenames(commit, repo, repodir, filepath_start, logger)
if not (fns or deleted or moved):
return
@ -501,6 +505,10 @@ if __name__=="__main__":
help = "Do not write any data back to the database",
action="store_true", dest="dry_run", default=False)
parser.add_option("-F", "--filter-files",
help="Only operate on a specified subset of files (wildcards allowed)",
action="store", dest="filter_files", default='')
options, args = parser.parse_args(sys.argv)
logger.setLevel(options.loglevel)