All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: "Liam R. Howlett" <Liam.Howlett@windriver.com>
Cc: yocto@yoctoproject.org
Subject: Re: [layerindex-web][PATCH 07/10] layerindex: Detect dependencies from layer.conf files
Date: Tue, 04 Oct 2016 11:54:11 +1300	[thread overview]
Message-ID: <1587820.dvQiXEhqcB@peggleto-mobl.ger.corp.intel.com> (raw)
In-Reply-To: <1474914338-26310-8-git-send-email-Liam.Howlett@WindRiver.com>

On Mon, 26 Sep 2016 14:25:35 Liam R. Howlett wrote:
> Read dependencies from layer.conf and try to create the LayerDependency
> entry by looking up the correct database object.  Dependencies are found
> by layer name only - no collection support.  layer.conf parsing is
> handled by the bitbake code.

I see you did some refactoring here to move some of the code needed to parse 
the layer conf to the utils module. Generally I do that kind of thing in a 
separate patch, although I won't insist upon it - however if you do do it as 
part of this patch then it needs to at least be mentioned as part of the 
commit message.


> diff --git a/layerindex/models.py b/layerindex/models.py
> index 6aec030..2db8818 100644
> --- a/layerindex/models.py
> +++ b/layerindex/models.py
> @@ -209,6 +209,9 @@ class LayerBranch(models.Model):
>          return "%s: %s" % (self.layer.name, self.branch.name)
> 
> 
> +    def get_required(self):
> +        return self.dependencies_set.filter(required=True)
> +
>  class LayerMaintainer(models.Model):
>      MAINTAINER_STATUS_CHOICES = (
>          ('A', 'Active'),
> @@ -230,6 +233,7 @@ class LayerMaintainer(models.Model):
>  class LayerDependency(models.Model):
>      layerbranch = models.ForeignKey(LayerBranch,
> related_name='dependencies_set') dependency = models.ForeignKey(LayerItem,
> related_name='dependents_set') 
> +    required = models.BooleanField(default=True)
> 
>      class Meta:
>          verbose_name_plural = "Layer dependencies"

This "required" field doesn't seem to be used in this commit - can you move 
these two changes to be part of the "recommends" support patch where they are 
used?


> --- a/layerindex/tools/import_layer.py
> +++ b/layerindex/tools/import_layer.py
> @@ -19,6 +19,7 @@ import glob
>  import utils
>  import logging
>  import subprocess
> +from layerconfparse import LayerConfParse
> 
>  class DryRunRollbackException(Exception):
>      pass
> @@ -375,11 +376,18 @@ def main():
>                  if layer.name != settings.CORE_LAYER_NAME:
>                      if not core_layer:
>                          core_layer =
> utils.get_layer(settings.CORE_LAYER_NAME) 
> +
>                      if core_layer:
> +                        logger.debug('Adding dep %s to %s' %
> (core_layer.name, layer.name)) layerdep = LayerDependency()
>                          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) 
> +

Use try..finally here to ensure shutdown() gets run.


>                  # Get some extra meta-information
>                  readme_files = glob.glob(os.path.join(layerdir, 'README*'))
> diff --git a/layerindex/update.py b/layerindex/update.py
> index 423eb53..ecd2380 100755
> --- a/layerindex/update.py
> +++ b/layerindex/update.py
> @@ -16,6 +16,8 @@ import subprocess
>  import signal
>  from distutils.version import LooseVersion
>  import utils
> +from layerconfparse import LayerConfParse
> +
> 
>  import warnings
>  warnings.filterwarnings("ignore", category=DeprecationWarning)
> @@ -92,7 +94,7 @@ def main():
> 
>      utils.setup_django()
>      import settings
> -    from layerindex.models import Branch, LayerItem
> +    from layerindex.models import Branch, LayerItem, LayerDependency
> 
>      logger.setLevel(options.loglevel)
> 
> @@ -201,6 +203,22 @@ def main():
>                      # Interrupted by user, break out of loop
>                      break
> 
> +        # Once indexed, then conf/layer.conf dependencies should be
> reevaluated. 

Shouldn't this be triggered solely when layer.conf changes rather than every 
time?


> +        layerconfparser = LayerConfParse(logger=logger,
> bitbakepath=bitbakepath) 
> +        for branch in branches:
> +            for layer in layerquery:
> +                urldir = layer.get_fetch_dir()
> +                repodir = os.path.join(fetchdir, urldir)
> +
> +                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)
> +
> +        layerconfparser.shutdown()

Use try..finally here as well.

> diff --git a/layerindex/utils.py b/layerindex/utils.py
> index 23b81f5..f82f8c7 100644
> --- a/layerindex/utils.py
> +++ b/layerindex/utils.py
> @@ -27,6 +27,114 @@ def get_layer(layername):
>          return res[0]
>      return None
> 
> +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))
> +
> +    # Nothing found, return.
> +    if len(res) == 0:
> +        return None

This is more simply written as:

    if res:
        return None


> +
> +    # If there is no version constraint, return the first one found.
> +    if not version_str:
> +        return res[0].layer
> +
> +    (operator, dep_version) = version_str.split()
> +    for layerbranch in res:
> +        layer_ver = layerbranch.version
> +
> +        # If there is no version in the found layer, then don't use this
> layer. 
> +        if not layer_ver:
> +            continue
> +
> +        try:
> +            success = bb.utils.vercmp_string_op(layer_ver, version_str,
> operator) 
> +        except bb.utils.VersionStringException as vse:
> +            raise vse
> +
> +        if success:
> +            return layerbranch.layer
> +
> +    return None
> +
> +def add_dependencies(layerbranch, config_data, logger=None):
> +    _add_dependency("LAYERDEPENDS", 'dependency', layerbranch, config_data,
> logger) 
> +
> +def _add_dependency(var, name, layerbranch, config_data, logger=None):
> +    from layerindex.models import LayerBranch, LayerDependency
> +
> +    layer_name = layerbranch.layer.name
> +    var_name = layer_name
> +
> +    dep_list = config_data.getVar("%s_%s" % (var, var_name), True)
> +
> +    if not dep_list:
> +         return

Indenting is out here.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre


  reply	other threads:[~2016-10-03 22:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 18:25 [layerindex-web][PATCH 00/10] Add Distribution, dependency and recommends detection, and import_project Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 01/10] import_layer: Add --actual-branch option Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 02/10] layerindex/tools/import_layer.py: Sanitize layer name Liam R. Howlett
2016-10-03 22:47   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 03/10] layerindex/tools/import_layer.py: Avoid failing if there is any layer to add Liam R. Howlett
2016-10-03 22:53   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 04/10] layerindex/utils: Update runcmd to decode binary strings to strings Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 05/10] layerindex: Add distribution to web interface and model Liam R. Howlett
2016-10-03 22:59   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 06/10] layerindex/tools/import_project: Add import_project Liam R. Howlett
2016-10-03 22:46   ` Paul Eggleton
2016-09-26 18:25 ` [layerindex-web][PATCH 07/10] layerindex: Detect dependencies from layer.conf files Liam R. Howlett
2016-10-03 22:54   ` Paul Eggleton [this message]
2016-09-26 18:25 ` [layerindex-web][PATCH 08/10] layerindex: Add collection and version to layerbranch Liam R. Howlett
2016-09-27 20:53   ` Mark Hatle
2016-10-03 22:54   ` Paul Eggleton
2016-10-04 13:51     ` Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 09/10] layerindexer: Add layer recommends support Liam R. Howlett
2016-09-26 18:25 ` [layerindex-web][PATCH 10/10] recipeparse: remove unnecessary else statement Liam R. Howlett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1587820.dvQiXEhqcB@peggleto-mobl.ger.corp.intel.com \
    --to=paul.eggleton@linux.intel.com \
    --cc=Liam.Howlett@windriver.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.