mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
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>
This commit is contained in:
parent
33e3dee9e7
commit
687c2b0051
|
@ -13,7 +13,7 @@ import optparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__))))
|
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()
|
common_setup()
|
||||||
from layerindex import utils, recipeparse
|
from layerindex import utils, recipeparse
|
||||||
|
|
||||||
|
@ -22,9 +22,12 @@ from django.db import transaction
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
from layerindex.models import Recipe, LayerBranch, LayerItem
|
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,30 +68,31 @@ def get_commit_info(info, logger):
|
||||||
return (author_name, author_email, date, title)
|
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):
|
def maintainer_history(options, logger):
|
||||||
layername = settings.CORE_LAYER_NAME
|
maintplans = MaintenancePlan.objects.filter(updates_enabled=True)
|
||||||
branchname = "master"
|
if not maintplans.exists():
|
||||||
|
logger.error('No enabled maintenance plans found')
|
||||||
layer = LayerItem.objects.filter(name__iexact = layername)[0]
|
|
||||||
if not layer:
|
|
||||||
logger.error("Core layer does not exist, please add into settings.")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
urldir = layer.get_fetch_dir()
|
|
||||||
layerbranch = LayerBranch.objects.filter(layer__name__iexact =
|
no_maintainer, _ = Maintainer.objects.get_or_create(name='No maintainer')
|
||||||
layername).filter(branch__name__iexact =
|
|
||||||
branchname)[0]
|
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)
|
repodir = os.path.join(settings.LAYER_FETCH_DIR, urldir)
|
||||||
layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
|
layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
|
||||||
|
|
||||||
pokypath = update_repo(settings.LAYER_FETCH_DIR, 'poky', settings.POKY_REPO_URL,
|
utils.runcmd("git checkout master -f", layerdir, logger=logger)
|
||||||
True, logger)
|
maintainers_full_path = os.path.join(layerdir, MAINTAINERS_INCLUDE_PATH)
|
||||||
utils.runcmd("git checkout master -f", pokypath, logger=logger)
|
if not os.path.exists(maintainers_full_path):
|
||||||
maintainers_full_path = os.path.join(pokypath, MAINTAINERS_INCLUDE_PATH)
|
logger.debug('No maintainers.inc for %s, skipping' % layerbranch)
|
||||||
|
continue
|
||||||
|
|
||||||
commits = utils.runcmd("git log --format='%H' --reverse --date=rfc " +
|
commits = utils.runcmd("git log --format='%H' --reverse --date=rfc " +
|
||||||
MAINTAINERS_INCLUDE_PATH, pokypath, logger=logger)
|
os.path.join(layerbranch.vcs_subdir, MAINTAINERS_INCLUDE_PATH), repodir, logger=logger)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
@ -99,7 +103,7 @@ def maintainer_history(options, logger):
|
||||||
logger.debug("Analysing commit %s ..." % (commit))
|
logger.debug("Analysing commit %s ..." % (commit))
|
||||||
|
|
||||||
(author_name, author_email, date, title) = \
|
(author_name, author_email, date, title) = \
|
||||||
get_commit_info(utils.runcmd("git show " + commit, pokypath,
|
get_commit_info(utils.runcmd("git show " + commit, repodir,
|
||||||
logger=logger), logger)
|
logger=logger), logger)
|
||||||
|
|
||||||
author = Maintainer.create_or_update(author_name, author_email)
|
author = Maintainer.create_or_update(author_name, author_email)
|
||||||
|
@ -108,7 +112,7 @@ def maintainer_history(options, logger):
|
||||||
rms.save()
|
rms.save()
|
||||||
|
|
||||||
utils.runcmd("git checkout %s -f" % commit,
|
utils.runcmd("git checkout %s -f" % commit,
|
||||||
pokypath, logger=logger)
|
repodir, logger=logger)
|
||||||
|
|
||||||
lines = [line.strip() for line in open(maintainers_full_path)]
|
lines = [line.strip() for line in open(maintainers_full_path)]
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
@ -129,29 +133,29 @@ def maintainer_history(options, logger):
|
||||||
logger.debug("%s: Change maintainer to %s in commit %s." % \
|
logger.debug("%s: Change maintainer to %s in commit %s." % \
|
||||||
(pn, m.name, commit))
|
(pn, m.name, commit))
|
||||||
else:
|
else:
|
||||||
logger.debug("%s: Not found in layer %s." % \
|
logger.debug("%s: Not found in %s." % \
|
||||||
(pn, layername))
|
(pn, layerbranch))
|
||||||
|
|
||||||
# set missing recipes to no maintainer
|
# set missing recipes to no maintainer
|
||||||
m = Maintainer.objects.get(id = 0) # No Maintainer
|
for recipe in layerbranch.recipe_set.all():
|
||||||
for recipe in Recipe.objects.all():
|
|
||||||
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
||||||
rm = RecipeMaintainer()
|
rm = RecipeMaintainer()
|
||||||
rm.recipe = recipe
|
rm.recipe = recipe
|
||||||
rm.maintainer = m
|
rm.maintainer = no_maintainer
|
||||||
rm.history = rms
|
rm.history = rms
|
||||||
rm.save()
|
rm.save()
|
||||||
logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
|
logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
|
||||||
(recipe.pn, rms.sha1))
|
(recipe.pn, rms.sha1))
|
||||||
|
|
||||||
|
utils.runcmd("git checkout master -f", repodir, logger=logger)
|
||||||
|
|
||||||
# set new recipes to no maintainer if don't have one
|
# set new recipes to no maintainer if don't have one
|
||||||
m = Maintainer.objects.get(id = 0) # No Maintainer
|
|
||||||
rms = RecipeMaintainerHistory.get_last()
|
rms = RecipeMaintainerHistory.get_last()
|
||||||
for recipe in Recipe.objects.all():
|
for recipe in layerbranch.recipe_set.all():
|
||||||
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
||||||
rm = RecipeMaintainer()
|
rm = RecipeMaintainer()
|
||||||
rm.recipe = recipe
|
rm.recipe = recipe
|
||||||
rm.maintainer = m
|
rm.maintainer = no_maintainer
|
||||||
rm.history = rms
|
rm.history = rms
|
||||||
rm.save()
|
rm.save()
|
||||||
logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
|
logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
|
||||||
|
|
Loading…
Reference in New Issue
Block a user