aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-03-01 09:10:20 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:52 +1200
commit687c2b0051140020fc52bf268e532115ab00501a (patch)
treef37e561170ed9f640c01ed2aa163556d230fd605
parent33e3dee9e7eb88b2e39bfc1b08f49f399a54ae40 (diff)
downloadopenembedded-core-contrib-687c2b0051140020fc52bf268e532115ab00501a.tar.gz
rrs_maintainer_history.py: support maintenance plans and remove poky hardcoding
Instead of hardcoded references to the poky repository, look for any maintainers.inc file in layers associated with the layerbranches for all enabled maintenance plans. At present few layers have this file, but at least it will now work generically in any layer index instance. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rwxr-xr-xrrs/tools/rrs_maintainer_history.py186
1 files changed, 95 insertions, 91 deletions
diff --git a/rrs/tools/rrs_maintainer_history.py b/rrs/tools/rrs_maintainer_history.py
index 277cd78b2e..d0fac4ac7b 100755
--- a/rrs/tools/rrs_maintainer_history.py
+++ b/rrs/tools/rrs_maintainer_history.py
@@ -13,7 +13,7 @@ import optparse
import logging
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
-from common import common_setup, update_repo, get_logger, DryRunRollbackException
+from common import common_setup, get_logger, DryRunRollbackException
common_setup()
from layerindex import utils, recipeparse
@@ -22,9 +22,12 @@ from django.db import transaction
import settings
from layerindex.models import Recipe, LayerBranch, LayerItem
-from rrs.models import Maintainer, RecipeMaintainerHistory, RecipeMaintainer
+from rrs.models import MaintenancePlan, Maintainer, RecipeMaintainerHistory, RecipeMaintainer
+from django.core.exceptions import ObjectDoesNotExist
-MAINTAINERS_INCLUDE_PATH = 'meta-poky/conf/distro/include/maintainers.inc'
+# FIXME we shouldn't be hardcoded to expect RECIPE_MAINTAINER to be set in this file,
+# as it may be in the recipe in future
+MAINTAINERS_INCLUDE_PATH = 'conf/distro/include/maintainers.inc'
"""
@@ -65,101 +68,102 @@ def get_commit_info(info, logger):
return (author_name, author_email, date, title)
"""
- Recreate Maintainership history from the beign of Yocto Project
+ Recreate Maintainership history from the beginning
"""
def maintainer_history(options, logger):
- layername = settings.CORE_LAYER_NAME
- branchname = "master"
-
- layer = LayerItem.objects.filter(name__iexact = layername)[0]
- if not layer:
- logger.error("Core layer does not exist, please add into settings.")
+ maintplans = MaintenancePlan.objects.filter(updates_enabled=True)
+ if not maintplans.exists():
+ logger.error('No enabled maintenance plans found')
sys.exit(1)
- urldir = layer.get_fetch_dir()
- layerbranch = LayerBranch.objects.filter(layer__name__iexact =
- layername).filter(branch__name__iexact =
- branchname)[0]
- repodir = os.path.join(settings.LAYER_FETCH_DIR, urldir)
- layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
-
- pokypath = update_repo(settings.LAYER_FETCH_DIR, 'poky', settings.POKY_REPO_URL,
- True, logger)
- utils.runcmd("git checkout master -f", pokypath, logger=logger)
- maintainers_full_path = os.path.join(pokypath, MAINTAINERS_INCLUDE_PATH)
-
- commits = utils.runcmd("git log --format='%H' --reverse --date=rfc " +
- MAINTAINERS_INCLUDE_PATH, pokypath, logger=logger)
-
- try:
- with transaction.atomic():
- for commit in commits.strip().split("\n"):
- if RecipeMaintainerHistory.objects.filter(sha1=commit):
- continue
-
- logger.debug("Analysing commit %s ..." % (commit))
-
- (author_name, author_email, date, title) = \
- get_commit_info(utils.runcmd("git show " + commit, pokypath,
- logger=logger), logger)
-
- author = Maintainer.create_or_update(author_name, author_email)
- rms = RecipeMaintainerHistory(title=title, date=date, author=author,
- sha1=commit)
- rms.save()
-
- utils.runcmd("git checkout %s -f" % commit,
- pokypath, logger=logger)
-
- lines = [line.strip() for line in open(maintainers_full_path)]
- for line in lines:
- res = get_recipe_maintainer(line, logger)
- if res:
- (pn, name, email) = res
- qry = Recipe.objects.filter(pn = pn, layerbranch = layerbranch)
-
- if qry:
- m = Maintainer.create_or_update(name, email)
+ no_maintainer, _ = Maintainer.objects.get_or_create(name='No maintainer')
+
+ for maintplan in maintplans:
+ for item in maintplan.maintenanceplanlayerbranch_set.all():
+ layerbranch = item.layerbranch
+ urldir = str(layerbranch.layer.get_fetch_dir())
+ repodir = os.path.join(settings.LAYER_FETCH_DIR, urldir)
+ layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
+
+ utils.runcmd("git checkout master -f", layerdir, logger=logger)
+ maintainers_full_path = os.path.join(layerdir, MAINTAINERS_INCLUDE_PATH)
+ if not os.path.exists(maintainers_full_path):
+ logger.debug('No maintainers.inc for %s, skipping' % layerbranch)
+ continue
+
+ commits = utils.runcmd("git log --format='%H' --reverse --date=rfc " +
+ os.path.join(layerbranch.vcs_subdir, MAINTAINERS_INCLUDE_PATH), repodir, logger=logger)
+
+ try:
+ with transaction.atomic():
+ for commit in commits.strip().split("\n"):
+ if RecipeMaintainerHistory.objects.filter(sha1=commit):
+ continue
+
+ logger.debug("Analysing commit %s ..." % (commit))
+
+ (author_name, author_email, date, title) = \
+ get_commit_info(utils.runcmd("git show " + commit, repodir,
+ logger=logger), logger)
+
+ author = Maintainer.create_or_update(author_name, author_email)
+ rms = RecipeMaintainerHistory(title=title, date=date, author=author,
+ sha1=commit)
+ rms.save()
+
+ utils.runcmd("git checkout %s -f" % commit,
+ repodir, logger=logger)
+
+ lines = [line.strip() for line in open(maintainers_full_path)]
+ for line in lines:
+ res = get_recipe_maintainer(line, logger)
+ if res:
+ (pn, name, email) = res
+ qry = Recipe.objects.filter(pn = pn, layerbranch = layerbranch)
+
+ if qry:
+ m = Maintainer.create_or_update(name, email)
+
+ rm = RecipeMaintainer()
+ rm.recipe = qry[0]
+ rm.maintainer = m
+ rm.history = rms
+ rm.save()
+
+ logger.debug("%s: Change maintainer to %s in commit %s." % \
+ (pn, m.name, commit))
+ else:
+ logger.debug("%s: Not found in %s." % \
+ (pn, layerbranch))
+
+ # set missing recipes to no maintainer
+ for recipe in layerbranch.recipe_set.all():
+ if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
+ rm = RecipeMaintainer()
+ rm.recipe = recipe
+ rm.maintainer = no_maintainer
+ rm.history = rms
+ rm.save()
+ logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
+ (recipe.pn, rms.sha1))
+
+ utils.runcmd("git checkout master -f", repodir, logger=logger)
+
+ # set new recipes to no maintainer if don't have one
+ rms = RecipeMaintainerHistory.get_last()
+ for recipe in layerbranch.recipe_set.all():
+ if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
rm = RecipeMaintainer()
- rm.recipe = qry[0]
- rm.maintainer = m
+ rm.recipe = recipe
+ rm.maintainer = no_maintainer
rm.history = rms
rm.save()
-
- logger.debug("%s: Change maintainer to %s in commit %s." % \
- (pn, m.name, commit))
- else:
- logger.debug("%s: Not found in layer %s." % \
- (pn, layername))
-
- # set missing recipes to no maintainer
- m = Maintainer.objects.get(id = 0) # No Maintainer
- for recipe in Recipe.objects.all():
- if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
- rm = RecipeMaintainer()
- rm.recipe = recipe
- rm.maintainer = m
- rm.history = rms
- rm.save()
- logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
- (recipe.pn, rms.sha1))
-
- # set new recipes to no maintainer if don't have one
- m = Maintainer.objects.get(id = 0) # No Maintainer
- rms = RecipeMaintainerHistory.get_last()
- for recipe in Recipe.objects.all():
- if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
- rm = RecipeMaintainer()
- rm.recipe = recipe
- rm.maintainer = m
- rm.history = rms
- rm.save()
- logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
- (recipe.pn))
- if options.dry_run:
- raise DryRunRollbackException
- except DryRunRollbackException:
- pass
+ logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
+ (recipe.pn))
+ if options.dry_run:
+ raise DryRunRollbackException
+ except DryRunRollbackException:
+ pass
if __name__=="__main__":
parser = optparse.OptionParser(usage = """%prog [options]""")