[yocto] [layerindex-web][PATCH 08/10] layerindex: Add collection and version to layerbranch

Mark Hatle mark.hatle at windriver.com
Tue Sep 27 13:53:23 PDT 2016


On 9/26/16 1:25 PM, Liam R. Howlett wrote:
> Collection and version will be pulled from the layer.conf if it exists
> and dependencies will be resolved by first checking for layers with the
> dependency name and then checking for collections.  It is necessary to
> shutdown tinfoil to avoid bitbake complaining about multiple instances.

I think I found a bug in this patch.  The collection/version apparently needs to
be 'unique' in the layerbranch.

So if you have two layerbranch entries, associated with different branches (say
master and krogoth) you will get an error that they both have the same
collection name.

(This happened when I tried to use the admin interface to set the values.)

I will look into a solution for this problem.

--Mark

> Signed-off-by: Liam R. Howlett <Liam.Howlett at WindRiver.com>
> ---
>  layerindex/models.py             |  2 ++
>  layerindex/tools/import_layer.py |  3 ---
>  layerindex/update.py             |  1 +
>  layerindex/update_layer.py       | 25 +++++++++++++++++++------
>  layerindex/utils.py              | 16 ++++++++++++++--
>  5 files changed, 36 insertions(+), 11 deletions(-)
> 
> diff --git a/layerindex/models.py b/layerindex/models.py
> index 2db8818..dcccb1f 100644
> --- a/layerindex/models.py
> +++ b/layerindex/models.py
> @@ -130,6 +130,8 @@ class LayerItem(models.Model):
>  class LayerBranch(models.Model):
>      layer = models.ForeignKey(LayerItem)
>      branch = models.ForeignKey(Branch)
> +    collection = models.CharField('Layer Collection', max_length=40, unique=True, null=True, help_text='Name of the layer that could be used in the list of dependencies - must be unique and can only contain letters, numbers and dashes')
> +    version = models.CharField('Layer Version', max_length=10, null=True, help_text='The layer version for this particular branch.')
>      vcs_subdir = models.CharField('Repository subdirectory', max_length=40, blank=True, help_text='Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)')
>      vcs_last_fetch = models.DateTimeField('Last successful fetch', blank=True, null=True)
>      vcs_last_rev = models.CharField('Last revision fetched', max_length=80, blank=True)
> diff --git a/layerindex/tools/import_layer.py b/layerindex/tools/import_layer.py
> index 0a13d21..21dd802 100755
> --- a/layerindex/tools/import_layer.py
> +++ b/layerindex/tools/import_layer.py
> @@ -383,9 +383,6 @@ def main():
>                          layerdep.layerbranch = layerbranch
>                          layerdep.dependency = core_layer
>                          layerdep.save()
> -                    layerconfparser = LayerConfParse(logger=logger)
> -                    config_data = layerconfparser.parse_layer(layerdir)
> -                    layerconfparser.shutdown()
>                      utils.add_dependencies(layerbranch, config_data, logger=logger)
>  
>  
> diff --git a/layerindex/update.py b/layerindex/update.py
> index ecd2380..e15caf6 100755
> --- a/layerindex/update.py
> +++ b/layerindex/update.py
> @@ -213,6 +213,7 @@ def main():
>                  layerbranch = layer.get_layerbranch(branch)
>                  if layerbranch.vcs_subdir:
>                      repodir = os.path.join(repodir, layerbranch.vcs_subdir)
> +
>                  config_data = layerconfparser.parse_layer(repodir)
>                  utils.add_dependencies(layerbranch, config_data, logger=logger)
>  
> diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
> index a937000..22c0dab 100644
> --- a/layerindex/update_layer.py
> +++ b/layerindex/update_layer.py
> @@ -196,16 +196,18 @@ def main():
>      except recipeparse.RecipeParseError as e:
>          logger.error(str(e))
>          sys.exit(1)
> +    config_data = bb.data.createCopy(tinfoil.config_data)
> +    tinfoil.shutdown()
>  
>      # Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set
> -    tinfoil.config_data.setVar('SUMMARY', '')
> +    config_data.setVar('SUMMARY', '')
>      # Clear the default value of DESCRIPTION so that we can see where it's not set
> -    tinfoil.config_data.setVar('DESCRIPTION', '')
> +    config_data.setVar('DESCRIPTION', '')
>      # Clear the default value of HOMEPAGE ('unknown')
> -    tinfoil.config_data.setVar('HOMEPAGE', '')
> +    config_data.setVar('HOMEPAGE', '')
>      # Set a blank value for LICENSE so that it doesn't cause the parser to die (e.g. with meta-ti -
>      # why won't they just fix that?!)
> -    tinfoil.config_data.setVar('LICENSE', '')
> +    config_data.setVar('LICENSE', '')
>  
>      try:
>          with transaction.atomic():
> @@ -244,7 +246,7 @@ def main():
>                  layerbranch = LayerBranch()
>                  layerbranch.layer = layer
>                  layerbranch.branch = branch
> -                layerbranch_source = layer.get_layerbranch('master')
> +
>                  if not layerbranch_source:
>                      layerbranch_source = layer.get_layerbranch(None)
>                  if layerbranch_source:
> @@ -262,6 +264,9 @@ def main():
>                          dep.layerbranch = layerbranch
>                          dep.save()
>  
> +            layerbranch_source = layer.get_layerbranch('master')
> +
> +
>              if layerbranch.vcs_subdir and not options.nocheckout:
>                  # Find latest commit in subdirectory
>                  # A bit odd to do it this way but apparently there's no other way in the GitPython API
> @@ -280,6 +285,14 @@ def main():
>  
>              layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
>              layerdir_start = os.path.normpath(layerdir) + os.sep
> +
> +            from layerconfparse import LayerConfParse
> +            layerconfparser = LayerConfParse(logger=logger)
> +            layer_config_data = layerconfparser.parse_layer(layerdir)
> +            layerconfparser.shutdown()
> +            utils.set_layerbranch_collection_version(layerbranch, layer_config_data, logger=logger)
> +            layerbranch.save()
> +
>              layerrecipes = Recipe.objects.filter(layerbranch=layerbranch)
>              layermachines = Machine.objects.filter(layerbranch=layerbranch)
>              layerdistributions = Distribution.objects.filter(layerbranch=layerbranch)
> @@ -305,7 +318,7 @@ def main():
>                  logger.info("Collecting data for layer %s on branch %s" % (layer.name, branchdesc))
>  
>                  try:
> -                    config_data_copy = recipeparse.setup_layer(tinfoil.config_data, fetchdir, layerdir, layer, layerbranch)
> +                    config_data_copy = recipeparse.setup_layer(config_data, fetchdir, layerdir, layer, layerbranch)
>                  except recipeparse.RecipeParseError as e:
>                      logger.error(str(e))
>                      sys.exit(1)
> diff --git a/layerindex/utils.py b/layerindex/utils.py
> index f82f8c7..2b49d64 100644
> --- a/layerindex/utils.py
> +++ b/layerindex/utils.py
> @@ -30,8 +30,10 @@ def get_layer(layername):
>  def get_dependency_layer(depname, version_str=None, logger=None):
>      from layerindex.models import LayerItem, LayerBranch
>  
> -    # Get any LayerBranch with a layer that has a name that matches the depname
> -    res = list(LayerBranch.objects.filter(layer__name=depname))
> +    # Get any LayerBranch with a layer that has a name that matches depmod, or
> +    # a LayerBranch that has the collection name depmod.
> +    res = list(LayerBranch.objects.filter(layer__name=depname)) + \
> +          list(LayerBranch.objects.filter(collection=depname))
>  
>      # Nothing found, return.
>      if len(res) == 0:
> @@ -104,11 +106,21 @@ def _add_dependency(var, name, layerbranch, config_data, logger=None):
>  
>          if logger:
>              logger.debug('Adding %s %s to %s' % (name, dep_layer.name, layer_name))
> +
>          layerdep = LayerDependency()
>          layerdep.layerbranch = layerbranch
>          layerdep.dependency = dep_layer
>          layerdep.save()
>  
> +def set_layerbranch_collection_version(layerbranch, config_data, logger=None):
> +
> +            layerbranch.collection = config_data.getVar('BBFILE_COLLECTIONS', True)
> +            ver_str = "LAYERVERSION_"
> +            if layerbranch.collection:
> +                layerbranch.collection = layerbranch.collection.strip()
> +                ver_str += layerbranch.collection
> +                layerbranch.version = config_data.getVar(ver_str, True)
> +
>  def setup_tinfoil(bitbakepath, enable_tracking):
>      sys.path.insert(0, bitbakepath + '/lib')
>      import bb.tinfoil
> 




More information about the yocto mailing list