Skip to contentSkip to conversation

bitbake-layers: adapt force option to not use tinfoil

PATCH In review [email protected] 3 participants 3 messages Apr 19, 2024 – May 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 bitbake-layers: adapt force 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.
Adapt --force to not perform the tinfoil at all, the use will be at own risk, i.e. the added layers might not parse properly afterwards.
This is not merged into the force option with -F as it even changes the loading of plugins from other layers and is hence even more invasive as force. Instead force can now be speciefied multiple times and is counted.

---
v4: Do not add a new option to skip the tinfoil setup and allow mutiple force levels instead.

 bin/bitbake-layers     | 14 +++++++++-----
 lib/bblayers/action.py |  4 +++-
 2 files changed, 12 insertions(+), 6 deletions(-)
bin/bitbake-layers +9 -5
index d4b1d1aa..aebb5100 100755
@@ -33,7 +33,7 @@ def main():
         add_help=False)
     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('-F', '--force', help='Forced execution: can be specified multiple times. -F will force add without recipe parse verification and -FF will additionally force the run withput layer parsing.', action='count', default=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 +59,20 @@ def main():
     plugins = []
     tinfoil = bb.tinfoil.Tinfoil(tracking=True)
     tinfoil.logger.setLevel(logger.getEffectiveLevel())
-    try:
+    if global_args.force > 1:
+        bbpaths = []
+    else:
         tinfoil.prepare(True)
-        for path in ([topdir] +
-                    tinfoil.config_data.getVar('BBPATH').split(':')):
+        bbpaths = tinfoil.config_data.getVar('BBPATH').split(':')
+    
+    try: 
+        for path in ([topdir] + bbpaths):
             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 global_args.force <= 1:
                 plugin.tinfoil_init(tinfoil)
             if hasattr(plugin, 'register_commands'):
                 registered = True
lib/bblayers/action.py +3 -1
index a8f26993..a14f1994 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):
+                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.force > 1:
+            return 0
         self.tinfoil.modified_files()
         if notremoved:
             for item in notremoved:
Signature · 1 line
2.39.2
#1 lore raw
Quoted 34 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Simone Weiß
Sent: den 19 april 2024 22:09
To: [email protected]
Cc: Simone Weiß <[email protected]>
Subject: [bitbake-devel] [PATCH v4] bitbake-layers: adapt force 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.
Adapt --force to not perform the tinfoil at all, the use will be at own risk, i.e. the added layers might not parse properly afterwards.
This is not merged into the force option with -F as it even changes the loading of plugins from other layers and is hence even more invasive as force. Instead force can now be speciefied multiple times and is counted.

---
v4: Do not add a new option to skip the tinfoil setup and allow mutiple force levels instead.

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

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

Quoted 5 lines
bin/bitbake-layers +1 -1
@@ -33,7 +33,7 @@ def main():
         add_help=False)
     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('-F', '--force', help='Forced execution: can be specified multiple times. -F will force add without recipe parse verification and -FF will additionally force the run withput layer parsing.', action='count', default=0)

Typo: withput -> without

Quoted 52 lines
bin/bitbake-layers +8 -4
     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 +59,20 @@ def main():
     plugins = []
     tinfoil = bb.tinfoil.Tinfoil(tracking=True)
     tinfoil.logger.setLevel(logger.getEffectiveLevel())
-    try:
+    if global_args.force > 1:
+        bbpaths = []
+    else:
         tinfoil.prepare(True)
-        for path in ([topdir] +
-                    tinfoil.config_data.getVar('BBPATH').split(':')):
+        bbpaths = tinfoil.config_data.getVar('BBPATH').split(':')
+
+    try:
+        for path in ([topdir] + bbpaths):
             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 global_args.force <= 1:
                 plugin.tinfoil_init(tinfoil)
             if hasattr(plugin, 'register_commands'):
                 registered = True
lib/bblayers/action.py +3 -2
index a8f26993..a14f1994 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):
+                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.force > 1:
+            return 0
         self.tinfoil.modified_files()
         if notremoved:
             for item in notremoved:
--
Quoted 1 line

2.39.2

//Peter

#2 lore raw
In reply to [email protected]
Quoted 13 lines · Simone Weiß via lists.openembedded.org

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.
Adapt --force to not perform the tinfoil at all, the use will be at own risk, i.e. the added layers might not parse properly afterwards.
This is not merged into the force option with -F as it even changes the loading of plugins from other layers and is hence even more invasive as force. Instead force can now be speciefied multiple times and is counted.

Quoted 1 line

Sorry about the delay on review. I wanted to say this is quite a neat solution so thanks for persevering with it!

Cheers,

Richard