Skip to contentSkip to conversation

bitbake-layers: add/remove option to not use tinfoil

PATCH Superseded [email protected] 2 participants 2 messages Mar 27, 2024 – Mar 28, 2024

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bitbake-layers: add/remove option to not use tinfoil

From: Simone Weiß <[email protected]>

Fixes [YOCTO #15417]

When a layer adds a new dependency after it was added to a conf, it can not be removed w/o this dependency in the setup. Even the dependent layer can not be added, as the tinfoil setup will fail.
Add an option to not perform the tinfoil at all, the use will be at own risk, i.e. the added layers might not parse properly afterwards.

---
v2: Rename option to be more meaningful.

 bin/bitbake-layers     | 14 ++++++++++----
 lib/bblayers/action.py |  6 ++++--
 2 files changed, 14 insertions(+), 6 deletions(-)
bin/bitbake-layers +10 -4
index d4b1d1aa..f7ed5ce0 100755
@@ -34,6 +34,7 @@ def main():
     parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true')
     parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true')
     parser.add_argument('-F', '--force', help='Force add without recipe parse verification', action='store_true')
+    parser.add_argument('-S', '--skip_parse_tests', help='Force run without parsing the layers, this might cause later failures.', action='store_true')
     parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR')
 
     global_args, unparsed_args = parser.parse_known_args()
@@ -59,16 +60,21 @@ def main():
     plugins = []
     tinfoil = bb.tinfoil.Tinfoil(tracking=True)
     tinfoil.logger.setLevel(logger.getEffectiveLevel())
-    try:
+    if global_args.skip_parse_tests:
+        bbpath_string = []
+    else:
         tinfoil.prepare(True)
-        for path in ([topdir] +
-                    tinfoil.config_data.getVar('BBPATH').split(':')):
+        bbpath_string = tinfoil.config_data.getVar('BBPATH').split(':')
+        print(bbpath_string)
+    
+    try: 
+        for path in ([topdir] + bbpath_string):
             pluginpath = os.path.join(path, 'lib', 'bblayers')
             bb.utils.load_plugins(logger, plugins, pluginpath)
 
         registered = False
         for plugin in plugins:
-            if hasattr(plugin, 'tinfoil_init'):
+            if hasattr(plugin, 'tinfoil_init') and not global_args.skip_parse_tests:
                 plugin.tinfoil_init(tinfoil)
             if hasattr(plugin, 'register_commands'):
                 registered = True
lib/bblayers/action.py +4 -2
index a8f26993..5aecc452 100644
@@ -50,8 +50,8 @@ class ActionPlugin(LayerPlugin):
 
         try:
             notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdirs, None)
-            self.tinfoil.modified_files()
-            if not (args.force or notadded):
+            if not (args.force or notadded or args.skip_parse_tests):
+                self.tinfoil.modified_files()
                 try:
                     self.tinfoil.run_command('parseConfiguration')
                 except (bb.tinfoil.TinfoilUIException, bb.BBHandledException):
@@ -83,6 +83,8 @@ class ActionPlugin(LayerPlugin):
                 layerdir = os.path.abspath(item)
             layerdirs.append(layerdir)
         (_, notremoved) = bb.utils.edit_bblayers_conf(bblayers_conf, None, layerdirs)
+        if args.skip_parse_tests:
+            return 0
         self.tinfoil.modified_files()
         if notremoved:
             for item in notremoved:
Signature · 1 line
2.39.2
#1 lore raw
Quoted 29 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Simone Weiß
Sent: den 27 mars 2024 20:54
To: [email protected]
Cc: Simone Weiß <[email protected]>
Subject: [bitbake-devel] [PATCH v2] bitbake-layers: add/remove option to not use tinfoil

From: Simone Weiß <[email protected]>

Fixes [YOCTO #15417]

When a layer adds a new dependency after it was added to a conf, it can not be removed w/o this dependency in the setup. Even the dependent layer can not be added, as the tinfoil setup will fail.
Add an option to not perform the tinfoil at all, the use will be at own risk, i.e. the added layers might not parse properly afterwards.

---
v2: Rename option to be more meaningful.

 bin/bitbake-layers     | 14 ++++++++++----
 lib/bblayers/action.py |  6 ++++--
 2 files changed, 14 insertions(+), 6 deletions(-)
bin/bitbake-layers +0 -0
index d4b1d1aa..f7ed5ce0 100755

bin/bitbake-layers def main(): · line 37

Quoted 4 lines
bin/bitbake-layers +1 -0
@@ -34,6 +34,7 @@ def main():
     parser.add_argument('-d', '--debug', help='Enable debug output', action='store_true')
     parser.add_argument('-q', '--quiet', help='Print only errors', action='store_true')
     parser.add_argument('-F', '--force', help='Force add without recipe parse verification', action='store_true')
+    parser.add_argument('-S', '--skip_parse_tests', help='Force run without parsing the layers, this might cause later failures.', action='store_true')

Does this really need a separate option? Can't the functionality be folded into the already existing -F option? Typically, as a user, if I want to make sure a layer is added no matter what, I would look for an option to force it. And when I find -F, I would look no further.

Quoted 5 lines
bin/bitbake-layers +0 -0
     parser.add_argument('--color', choices=['auto', 'always', 'never'], default='auto', help='Colorize output (where %(metavar)s is %(choices)s)', metavar='COLOR')
 
     global_args, unparsed_args = parser.parse_known_args()
@@ -59,16 +60,21 @@ def main():
     plugins = []

bin/bitbake-layers def main(): · line 67

Quoted 10 lines
bin/bitbake-layers +4 -3
     tinfoil = bb.tinfoil.Tinfoil(tracking=True)
     tinfoil.logger.setLevel(logger.getEffectiveLevel())
-    try:
+    if global_args.skip_parse_tests:
+        bbpath_string = []
+    else:
         tinfoil.prepare(True)
-        for path in ([topdir] +
-                    tinfoil.config_data.getVar('BBPATH').split(':')):
+        bbpath_string = tinfoil.config_data.getVar('BBPATH').split(':')

Odd variable name, given that it is not a string but a list. I would call it "bbpaths" instead.

bin/bitbake-layers def main(): · line 68

Quoted 1 line
bin/bitbake-layers +1 -0
+        print(bbpath_string)

This looks like a debug leftover...

Quoted 38 lines
bin/bitbake-layers +4 -1
+
+    try:
+        for path in ([topdir] + bbpath_string):
             pluginpath = os.path.join(path, 'lib', 'bblayers')
             bb.utils.load_plugins(logger, plugins, pluginpath)
 
         registered = False
         for plugin in plugins:
-            if hasattr(plugin, 'tinfoil_init'):
+            if hasattr(plugin, 'tinfoil_init') and not global_args.skip_parse_tests:
                 plugin.tinfoil_init(tinfoil)
             if hasattr(plugin, 'register_commands'):
                 registered = True
lib/bblayers/action.py +4 -3
index a8f26993..5aecc452 100644
@@ -50,8 +50,8 @@ class ActionPlugin(LayerPlugin):
 
         try:
             notadded, _ = bb.utils.edit_bblayers_conf(bblayers_conf, layerdirs, None)
-            self.tinfoil.modified_files()
-            if not (args.force or notadded):
+            if not (args.force or notadded or args.skip_parse_tests):
+                self.tinfoil.modified_files()
                 try:
                     self.tinfoil.run_command('parseConfiguration')
                 except (bb.tinfoil.TinfoilUIException, bb.BBHandledException):
@@ -83,6 +83,8 @@ class ActionPlugin(LayerPlugin):
                 layerdir = os.path.abspath(item)
             layerdirs.append(layerdir)
         (_, notremoved) = bb.utils.edit_bblayers_conf(bblayers_conf, None, layerdirs)
+        if args.skip_parse_tests:
+            return 0
         self.tinfoil.modified_files()
         if notremoved:
             for item in notremoved:
--
Quoted 1 line

2.39.2

//Peter