mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
rrs: handle linking maintainership
Provide a mechanism set the maintainer for things like gcc-cross-<arch> to the same as gcc. (We do have entries in the .inc file for these, however they aren't useful as they don't match the recipe name when we parse it, and due to the fact that RecipeMaintainer objects link directly to Recipe objects, we can't handle entries that don't map to a real recipe). Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
0d112b1d97
commit
6a332c5d8f
|
@ -9,7 +9,8 @@ from django.contrib.admin import DateFieldListFilter
|
|||
|
||||
from rrs.models import Release, Milestone, Maintainer, RecipeMaintainerHistory, \
|
||||
RecipeMaintainer, RecipeDistro, RecipeUpgrade, RecipeUpstream, \
|
||||
RecipeUpstreamHistory, MaintenancePlan, MaintenancePlanLayerBranch
|
||||
RecipeUpstreamHistory, MaintenancePlan, MaintenancePlanLayerBranch, \
|
||||
RecipeMaintenanceLink
|
||||
|
||||
class MaintenancePlanLayerBranchInline(admin.StackedInline):
|
||||
model = MaintenancePlanLayerBranch
|
||||
|
@ -70,6 +71,9 @@ class RecipeUpstreamAdmin(admin.ModelAdmin):
|
|||
'type', ('date', DateFieldListFilter), 'history']
|
||||
model = RecipeUpstream
|
||||
|
||||
class RecipeMaintenanceLinkAdmin(admin.ModelAdmin):
|
||||
model = RecipeMaintenanceLink
|
||||
|
||||
admin.site.register(MaintenancePlan, MaintenancePlanAdmin)
|
||||
admin.site.register(Release, ReleaseAdmin)
|
||||
admin.site.register(Milestone, MilestoneAdmin)
|
||||
|
@ -80,3 +84,4 @@ admin.site.register(RecipeDistro, RecipeDistroAdmin)
|
|||
admin.site.register(RecipeUpgrade, RecipeUpgradeAdmin)
|
||||
admin.site.register(RecipeUpstreamHistory, RecipeUpstreamHistoryAdmin)
|
||||
admin.site.register(RecipeUpstream, RecipeUpstreamAdmin)
|
||||
admin.site.register(RecipeMaintenanceLink, RecipeMaintenanceLinkAdmin)
|
||||
|
|
40
rrs/migrations/0010_recipemaintenancelink.py
Normal file
40
rrs/migrations/0010_recipemaintenancelink.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def insert_initial_link_data(apps, schema_editor):
|
||||
RecipeMaintenanceLink = apps.get_model('rrs', 'RecipeMaintenanceLink')
|
||||
|
||||
r = RecipeMaintenanceLink(pn_match='gcc-cross-*', pn_target='gcc')
|
||||
r.save()
|
||||
r = RecipeMaintenanceLink(pn_match='gcc-crosssdk-*', pn_target='gcc')
|
||||
r.save()
|
||||
r = RecipeMaintenanceLink(pn_match='gcc-source-*', pn_target='gcc')
|
||||
r.save()
|
||||
r = RecipeMaintenanceLink(pn_match='binutils-cross-*', pn_target='binutils')
|
||||
r.save()
|
||||
r = RecipeMaintenanceLink(pn_match='binutils-crosssdk-*', pn_target='binutils')
|
||||
r.save()
|
||||
r = RecipeMaintenanceLink(pn_match='gdb-cross-*', pn_target='gdb')
|
||||
r.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rrs', '0009_rmh_layerbranch'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='RecipeMaintenanceLink',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
|
||||
('pn_match', models.CharField(max_length=100, help_text='Expression to match against pn of recipes that should be linked (glob expression)')),
|
||||
('pn_target', models.CharField(max_length=100, help_text='Name of recipe to link to')),
|
||||
],
|
||||
),
|
||||
migrations.RunPython(insert_initial_link_data, reverse_code=migrations.RunPython.noop),
|
||||
]
|
|
@ -408,3 +408,23 @@ class RecipeUpgrade(models.Model):
|
|||
return '%s: (%s, %s)' % (self.recipe.pn, self.version,
|
||||
self.commit_date)
|
||||
|
||||
|
||||
class RecipeMaintenanceLink(models.Model):
|
||||
pn_match = models.CharField(max_length=100, help_text='Expression to match against pn of recipes that should be linked (glob expression)')
|
||||
pn_target = models.CharField(max_length=100, help_text='Name of recipe to link to')
|
||||
|
||||
@staticmethod
|
||||
def link_maintainer(pn, rmh):
|
||||
import fnmatch
|
||||
for rml in RecipeMaintenanceLink.objects.all():
|
||||
if fnmatch.fnmatch(pn, rml.pn_match):
|
||||
recipe_link_objs = rmh.layerbranch.recipe_set.filter(pn=rml.pn_target)
|
||||
if recipe_link_objs:
|
||||
lrm = RecipeMaintainer.objects.filter(recipe=recipe_link_objs[0], history=rmh)
|
||||
if lrm:
|
||||
return lrm[0]
|
||||
return None
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return '%s -> %s' % (self.pn_match, self.pn_target)
|
||||
|
|
|
@ -22,7 +22,7 @@ from django.db import transaction
|
|||
import settings
|
||||
|
||||
from layerindex.models import Recipe, LayerBranch, LayerItem
|
||||
from rrs.models import MaintenancePlan, Maintainer, RecipeMaintainerHistory, RecipeMaintainer
|
||||
from rrs.models import MaintenancePlan, Maintainer, RecipeMaintainerHistory, RecipeMaintainer, RecipeMaintenanceLink
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
||||
# FIXME we shouldn't be hardcoded to expect RECIPE_MAINTAINER to be set in this file,
|
||||
|
@ -150,9 +150,16 @@ def maintainer_history(options, logger):
|
|||
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
||||
rm = RecipeMaintainer()
|
||||
rm.recipe = recipe
|
||||
link_maintainer = RecipeMaintenanceLink.link_maintainer(recipe.pn, rms)
|
||||
if link_maintainer:
|
||||
rm.maintainer = link_maintainer.maintainer
|
||||
else:
|
||||
rm.maintainer = no_maintainer
|
||||
rm.history = rms
|
||||
rm.save()
|
||||
if link_maintainer:
|
||||
logger.debug("%s: linked to maintainer for %s" % (recipe.pn, link_maintainer.recipe.pn))
|
||||
else:
|
||||
logger.debug("%s: Not found maintainer in commit %s set to 'No maintainer'." % \
|
||||
(recipe.pn, rms.sha1))
|
||||
|
||||
|
@ -162,9 +169,16 @@ def maintainer_history(options, logger):
|
|||
if not RecipeMaintainer.objects.filter(recipe = recipe, history = rms):
|
||||
rm = RecipeMaintainer()
|
||||
rm.recipe = recipe
|
||||
link_maintainer = RecipeMaintenanceLink.link_maintainer(recipe.pn, rms)
|
||||
if link_maintainer:
|
||||
rm.maintainer = link_maintainer.maintainer
|
||||
else:
|
||||
rm.maintainer = no_maintainer
|
||||
rm.history = rms
|
||||
rm.save()
|
||||
if link_maintainer:
|
||||
logger.debug("%s: New recipe linked to maintainer for %s" % (recipe.pn, link_maintainer.recipe.pn))
|
||||
else:
|
||||
logger.debug("%s: New recipe not found maintainer set to 'No maintainer'." % \
|
||||
(recipe.pn))
|
||||
if options.dry_run:
|
||||
|
|
Loading…
Reference in New Issue
Block a user