[yocto] [[AUH][PATCH] 6/6] upgradehelper.py: Add _get_recipes_by_layer method

Aníbal Limón anibal.limon at linux.intel.com
Thu May 18 14:21:46 PDT 2017


When the layer mode is enabled and the upgradehelper is run
with all, there is a need to discover what recipes are provides
the layer to only try to upgrade those.

[YOCTO #8962]

Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 upgradehelper.py | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/upgradehelper.py b/upgradehelper.py
index be4282f..5ce2575 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -663,7 +663,13 @@ class UniverseUpdater(Updater):
         Updater.__init__(self, True, True)
 
         # to filter recipes in upgrade
-        self.recipes = recipes
+        if not recipes and self.opts['layer_mode'] == 'yes':
+            # when layer mode is enabled and no recipes are specified
+            # we need to figure out what recipes are provided by the
+            # layer to try upgrade
+            self.recipes = self._get_recipes_by_layer()
+        else:
+            self.recipes = recipes
 
         # read history file
         self.history_file = os.path.join(get_build_dir(), "upgrade-helper", "history.uh")
@@ -676,6 +682,30 @@ class UniverseUpdater(Updater):
                                                         line.split(',')[2],
                                                         line.split(',')[3],
                                                         line.split(',')[4]]
+    def _get_recipes_by_layer(self):
+        recipes = []
+
+        recipe_regex = re.compile('^(?P<name>.*):$')
+        layer_regex = re.compile('^  (?P<name>.*) +')
+
+        layers = False
+        name = ''
+
+        output = subprocess.check_output('bitbake-layers show-recipes',
+                shell=True)
+        for line in output.decode("utf-8") .split('\n'):
+            s = recipe_regex.search(line)
+            if s:
+                name = s.group('name')
+                continue
+
+            if not 'skipped' in line:
+                s = layer_regex.search(line)
+                if s:
+                    if s.group('name').strip() == self.opts['layer_name']:
+                        recipes.append(name)
+
+        return recipes
 
     def _update_master(self):
         if self.opts['layer_mode'] == 'yes':
-- 
2.1.4




More information about the yocto mailing list