All of lore.kernel.org
 help / color / mirror / Atom feed
* [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe
@ 2024-01-23  4:15 Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 1/5] layerindex/models: add BBClassRecipe BBClassGlobal Tim Orling
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Previously, only the 'classes' path was searched, but we should also be searching
'classes-global' and 'classes-recipe' since:
  bitbake f33ce7e7
    'BBHandler/cooker: Implement recipe and global classes'
and
  oe-core f5c12800
    'classes: Update classes to match new bitbake class scope functionality'

This requires changes not only in models.py, but also in recipeparse.py, update_layer.py
and views.py.

While we are at it, add "Global" and "Recipe" 'badges' next to the class names in the
appropriate class view templates.

[YOCTO #15238]

The following changes since commit 83378f2f9c881505027220a98514bcb933d82682:

  global: deprecated pkg_resources parse_version (2024-01-22 16:08:37 -0800)

are available in the Git repository at:

  https://github.com/moto-timo/layerindex-web timo/classes-global-recipe
  https://github.com/moto-timo/layerindex-web/tree/timo/classes-global-recipe

Tim Orling (5):
  layerindex/models: add BBClassRecipe BBClassGlobal
  layerindex/recipeparse.py: extend bbclass regex
  layerindex/views: add classes-recipe,-global
  templates: add bbclasstype badge
  layerindex/update_layer.py: enable classes-global,-recipe

 ...obal_bbclassrecipe_bbclass_bbclass_type.py | 41 ++++++++++++++++++
 layerindex/models.py                          | 43 ++++++++++++++++++-
 layerindex/recipeparse.py                     |  4 +-
 layerindex/update_layer.py                    | 19 ++++++--
 layerindex/views.py                           |  3 +-
 templates/layerindex/classes.html             |  5 ++-
 templates/layerindex/detail.html              |  5 ++-
 7 files changed, 111 insertions(+), 9 deletions(-)
 create mode 100644 layerindex/migrations/0048_bbclassglobal_bbclassrecipe_bbclass_bbclass_type.py

-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [layerindex-web][PATCH 1/5] layerindex/models: add BBClassRecipe BBClassGlobal
  2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
@ 2024-01-23  4:15 ` Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 2/5] layerindex/recipeparse.py: extend bbclass regex Tim Orling
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Add support for classes-global and classes-recipe, but use
"proxy=True" to not create new tables for the new classes.
Rather, we use the bbclass_type field.

[YOCTO #15238]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 ...obal_bbclassrecipe_bbclass_bbclass_type.py | 41 ++++++++++++++++++
 layerindex/models.py                          | 43 ++++++++++++++++++-
 2 files changed, 83 insertions(+), 1 deletion(-)
 create mode 100644 layerindex/migrations/0048_bbclassglobal_bbclassrecipe_bbclass_bbclass_type.py

diff --git a/layerindex/migrations/0048_bbclassglobal_bbclassrecipe_bbclass_bbclass_type.py b/layerindex/migrations/0048_bbclassglobal_bbclassrecipe_bbclass_bbclass_type.py
new file mode 100644
index 0000000..dba7927
--- /dev/null
+++ b/layerindex/migrations/0048_bbclassglobal_bbclassrecipe_bbclass_bbclass_type.py
@@ -0,0 +1,41 @@
+# Generated by Django 4.2.9 on 2024-01-20 21:20
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ("layerindex", "0047_layerbranch_updates_enabled"),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name="BBClassGlobal",
+            fields=[],
+            options={
+                "proxy": True,
+                "indexes": [],
+                "constraints": [],
+            },
+            bases=("layerindex.bbclass",),
+        ),
+        migrations.CreateModel(
+            name="BBClassRecipe",
+            fields=[],
+            options={
+                "proxy": True,
+                "indexes": [],
+                "constraints": [],
+            },
+            bases=("layerindex.bbclass",),
+        ),
+        migrations.AddField(
+            model_name="bbclass",
+            name="bbclass_type",
+            field=models.CharField(
+                choices=[("", "Class"), ("Global", "Global"), ("Recipe", "Recipe")],
+                default="",
+                max_length=25,
+            ),
+        ),
+    ]
diff --git a/layerindex/models.py b/layerindex/models.py
index 676f05f..c52927f 100644
--- a/layerindex/models.py
+++ b/layerindex/models.py
@@ -784,18 +784,59 @@ class BBAppend(models.Model):
 class BBClass(models.Model):
     layerbranch = models.ForeignKey(LayerBranch, on_delete=models.CASCADE)
     name = models.CharField(max_length=100)
+    # Type field
+    TYPE_CHOICES = [
+        ('', 'Class'),
+        ('Global', 'Global'),
+        ('Recipe', 'Recipe')
+        ]
+    bbclass_type = models.CharField(max_length=25, choices=TYPE_CHOICES, default='')
 
     class Meta:
         verbose_name = "Class"
         verbose_name_plural = "Classes"
 
     def vcs_web_url(self):
-        url = self.layerbranch.file_url(os.path.join('classes', "%s.bbclass" % self.name))
+        # We cannot override vcs_web_url in the sub-classes without defining self.url
+        # but we want url to be dynamic
+        if self.bbclass_type == 'Global':
+            url = self.layerbranch.file_url(os.path.join('classes-global', "%s.bbclass" % self.name))
+        elif self.bbclass_type == 'Recipe':
+            url = self.layerbranch.file_url(os.path.join('classes-recipe', "%s.bbclass" % self.name))
+        else:
+            url = self.layerbranch.file_url(os.path.join('classes', "%s.bbclass" % self.name))
         return url or ''
 
     def __str__(self):
         return '%s (%s)' % (self.name, self.layerbranch.layer.name)
 
+class BBClassGlobalManager(models.Manager):
+    def get_queryset(self):
+        return super().get_queryset().filter(bbclass_type='Global')
+
+class BBClassGlobal(BBClass):
+    objects = BBClassGlobalManager()
+
+    class Meta:
+        proxy = True
+
+    def save(self, *args, **kwargs):
+        self.bbclass_type = 'Global'
+        return super(BBClassGlobal, self).save(*args, **kwargs)
+
+class BBClassRecipeManager(models.Manager):
+    def get_queryset(self):
+        return super().get_queryset().filter(bbclass_type='Recipe')
+
+class BBClassRecipe(BBClass):
+    objects = BBClassRecipeManager()
+
+    class Meta:
+        proxy = True
+
+    def save(self, *args, **kwargs):
+        self.bbclass_type = 'Recipe'
+        return super(BBClassRecipe, self).save(*args, **kwargs)
 
 class IncFile(models.Model):
     layerbranch = models.ForeignKey(LayerBranch, on_delete=models.CASCADE)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [layerindex-web][PATCH 2/5] layerindex/recipeparse.py: extend bbclass regex
  2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 1/5] layerindex/models: add BBClassRecipe BBClassGlobal Tim Orling
@ 2024-01-23  4:15 ` Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 3/5] layerindex/views: add classes-recipe,-global Tim Orling
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Extend the bbclass regex to match classes-global and classes-recipe

[YOCTO #15238]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/recipeparse.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/layerindex/recipeparse.py b/layerindex/recipeparse.py
index 6202745..9be6c10 100644
--- a/layerindex/recipeparse.py
+++ b/layerindex/recipeparse.py
@@ -130,7 +130,7 @@ def setup_layer(config_data, fetchdir, layerdir, layer, layerbranch, logger):
 
 machine_conf_re = re.compile(r'conf/machine/([^/.]*).conf$')
 distro_conf_re = re.compile(r'conf/distro/([^/.]*).conf$')
-bbclass_re = re.compile(r'classes/([^/.]*).bbclass$')
+bbclass_re = re.compile(r'classes(?P<subtype>-global|-recipe)?/(?P<name>[^/.]*).bbclass$')
 def detect_file_type(path, subdir_start):
     typename = None
     if fnmatch.fnmatch(path, "*.bb"):
@@ -149,7 +149,7 @@ def detect_file_type(path, subdir_start):
         res = bbclass_re.match(subpath)
         if res:
             typename = 'bbclass'
-            return (typename, None, res.group(1))
+            return (typename, None, res.group('name'))
         res = distro_conf_re.match(subpath)
         if res:
             typename = 'distro'
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [layerindex-web][PATCH 3/5] layerindex/views: add classes-recipe,-global
  2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 1/5] layerindex/models: add BBClassRecipe BBClassGlobal Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 2/5] layerindex/recipeparse.py: extend bbclass regex Tim Orling
@ 2024-01-23  4:15 ` Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 4/5] templates: add bbclasstype badge Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 5/5] layerindex/update_layer.py: enable classes-global,-recipe Tim Orling
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Since commits:
bitbake f33ce7e7
    'BBHandler/cooker: Implement recipe and global classes'
oe-core f5c12800
    'classes: Update classes to match new bitbake class scope functionality'
we now have a lot of the oe-core recipe classes in meta/classes-recipe.

We are also missing any bbclasses in meta/classes-global

[YOCTO #15238]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/views.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/layerindex/views.py b/layerindex/views.py
index 04e39d7..c7a1f09 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -51,7 +51,8 @@ from layerindex.forms import (AdvancedRecipeSearchForm, BulkChangeEditFormSet,
                               LayerMaintainerFormSet, RecipeChangesetForm,
                               PatchDispositionForm, PatchDispositionFormSet,
                               BranchComparisonForm, RecipeDependenciesForm)
-from layerindex.models import (BBAppend, BBClass, Branch, ClassicRecipe,
+from layerindex.models import (BBAppend, BBClass, BBClassGlobal, BBClassRecipe,
+                               Branch, ClassicRecipe,
                                Distro, DynamicBuildDep, IncFile, LayerBranch,
                                LayerDependency, LayerItem, LayerMaintainer,
                                LayerNote, LayerUpdate, Machine, Patch, Recipe,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [layerindex-web][PATCH 4/5] templates: add bbclasstype badge
  2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
                   ` (2 preceding siblings ...)
  2024-01-23  4:15 ` [layerindex-web][PATCH 3/5] layerindex/views: add classes-recipe,-global Tim Orling
@ 2024-01-23  4:15 ` Tim Orling
  2024-01-23  4:15 ` [layerindex-web][PATCH 5/5] layerindex/update_layer.py: enable classes-global,-recipe Tim Orling
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Now that we have different BBClass subtypes, it is handy to have
a UI indication of the different types. Add "badges" to display
"Global" (for 'classes-global' paths) or "Recipe" (for
'classes-recipe' paths).

[YOCTO #15238]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 templates/layerindex/classes.html | 5 ++++-
 templates/layerindex/detail.html  | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/templates/layerindex/classes.html b/templates/layerindex/classes.html
index bc3d0ac..e99761b 100644
--- a/templates/layerindex/classes.html
+++ b/templates/layerindex/classes.html
@@ -54,7 +54,10 @@
                     <tbody>
                         {% for class in class_list %}
                             <tr>
-                                <td><a href="{{ class.vcs_web_url }}">{{ class.name }}</a></td>
+                                <td>
+                                    <a href="{{ class.vcs_web_url }}">{{ class.name }}</a>
+                                     <span class="badge badge-info" id="id_bbclass_type">{{ class.bbclass_type }}</span>
+                                </td>
                                 <td><a href="{% url 'layer_item' url_branch class.layerbranch.layer.name %}">{{ class.layerbranch.layer.name }}</a></td>
                             </tr>
                         {% endfor %}
diff --git a/templates/layerindex/detail.html b/templates/layerindex/detail.html
index 0fa8caf..11c7df7 100644
--- a/templates/layerindex/detail.html
+++ b/templates/layerindex/detail.html
@@ -311,7 +311,10 @@
                         <tbody>
                             {% for class in classes %}
                                 <tr>
-                                    <td><a href="{{ class.vcs_web_url }}">{{ class.name }}</a></td>
+                                    <td>
+                                        <a href="{{ class.vcs_web_url }}">{{ class.name }}</a>
+                                        <span class="badge badge-info" id="id_bbclass_typ">{{ class.bbclass_type }}</span>
+                                    </td>
                                 </tr>
                             {% endfor %}
                         </tbody>
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [layerindex-web][PATCH 5/5] layerindex/update_layer.py: enable classes-global,-recipe
  2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
                   ` (3 preceding siblings ...)
  2024-01-23  4:15 ` [layerindex-web][PATCH 4/5] templates: add bbclasstype badge Tim Orling
@ 2024-01-23  4:15 ` Tim Orling
  4 siblings, 0 replies; 6+ messages in thread
From: Tim Orling @ 2024-01-23  4:15 UTC (permalink / raw)
  To: yocto

Add support for the new BBClassGlobal and BBClassRecipe
sub-classes.

[YOCTO #15238]

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 layerindex/update_layer.py | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index d9bec0c..33c5cfb 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -296,7 +296,10 @@ def main():
 
     utils.setup_django()
     import settings
-    from layerindex.models import LayerItem, LayerBranch, LayerDependency, Recipe, RecipeFileDependency, Machine, Distro, BBAppend, BBClass, IncFile
+    from layerindex.models import (LayerItem, LayerBranch, LayerDependency,
+                                   Recipe, RecipeFileDependency, Machine,
+                                   Distro, BBAppend, BBClass,
+                                   BBClassGlobal, BBClassRecipe, IncFile)
     from django.db import transaction
 
     logger.setLevel(options.loglevel)
@@ -644,7 +647,12 @@ def main():
                                 update_distro_conf_file(os.path.join(repodir, path), distro, config_data_copy)
                                 distro.save()
                             elif typename == 'bbclass':
-                                bbclass = BBClass()
+                                if '/classes-global/' in path:
+                                    bbclass = BBClassGlobal()
+                                elif '/classes-recipe/' in path:
+                                    bbclass = BBClassRecipe()
+                                else:
+                                    bbclass = BBClass()
                                 bbclass.layerbranch = layerbranch
                                 bbclass.name = filename
                                 bbclass.save()
@@ -765,7 +773,12 @@ def main():
                                 update_distro_conf_file(fullpath, distro, config_data_copy)
                                 distro.save()
                             elif typename == 'bbclass':
-                                bbclass = BBClass()
+                                if '/classes-global/' in fullpath:
+                                    bbclass = BBClassGlobal()
+                                elif '/classes-recipe/' in fullpath:
+                                    bbclass = BBClassRecipe()
+                                else:
+                                    bbclass = BBClass()
                                 bbclass.layerbranch = layerbranch
                                 bbclass.name = filename
                                 bbclass.save()
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-23  4:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23  4:15 [layerindex-web][PATCH 0/5] Add support for classes-global and classes-recipe Tim Orling
2024-01-23  4:15 ` [layerindex-web][PATCH 1/5] layerindex/models: add BBClassRecipe BBClassGlobal Tim Orling
2024-01-23  4:15 ` [layerindex-web][PATCH 2/5] layerindex/recipeparse.py: extend bbclass regex Tim Orling
2024-01-23  4:15 ` [layerindex-web][PATCH 3/5] layerindex/views: add classes-recipe,-global Tim Orling
2024-01-23  4:15 ` [layerindex-web][PATCH 4/5] templates: add bbclasstype badge Tim Orling
2024-01-23  4:15 ` [layerindex-web][PATCH 5/5] layerindex/update_layer.py: enable classes-global,-recipe Tim Orling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.