Bug 15417

Summary: "bitbake-layers remove-layer" does not work when there is a missing layer dependencies
Product: [Build System, Metadata & Runtime] BitBake Reporter: Yoann Congal <yoann.congal>
Component: bitbakeAssignee: Simone Weiß <simone.p.weiss>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: pavel, poky.bs.watcher, poky.watcher, randy.macleod, simone.p.weiss, tim.orling, yoann.congal
Version: unspecified   
Target Milestone: 5.0   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Yoann Congal 2024-03-03 23:00:54 UTC
For example, you added meta-networking before it depended on meta-python[0]: When you try to remove meta-networking, "bitbake-layers remove-layer" displays an error and does not remove the layer from bblayer.conf:

   $ bitbake-layers remove-layer ../meta-openembedded/meta-networking
  NOTE: Starting bitbake server...
  ERROR: Layer 'networking-layer' depends on layer 'meta-python', but this layer is not enabled in your configuration

Maybe an option -f/--force is missing to ignore such dependency error and forcibly remove the layer from bblayer.conf ?

NB: This was triggered on the AB[1] which add/remove layers for each layers of meta-openembedded.

[0]: https://git.openembedded.org/meta-openembedded/commit/?id=ab7c469bfeb7aba97402d8eab03d9bb18725c6af
[1]: https://autobuilder.yoctoproject.org/typhoon/#/builders/155/builds/14/steps/30/logs/stdio
Comment 1 Tim Orling 2024-03-07 00:15:11 UTC
I'm willing to wager that "bitbake-layers layerindex-fetch meta-networking" would work however ;)
Comment 2 Simone Weiß 2024-03-11 18:53:23 UTC
There is already a --force option for bitbake-layers. It ignores the recipe parse verification when adding layers. I will how to add it for remove as well
Comment 3 Simone Weiß 2024-03-11 19:43:02 UTC
(In reply to Tim Orling from comment #1)
> I'm willing to wager that "bitbake-layers layerindex-fetch meta-networking"
> would work however ;)

Actually not :)
Comment 4 Tim Orling 2024-03-11 21:55:52 UTC
(In reply to Simone Weiß from comment #3)
> (In reply to Tim Orling from comment #1)
> > I'm willing to wager that "bitbake-layers layerindex-fetch meta-networking"
> > would work however ;)
> 
> Actually not :)

Only because meta-openembedded hasn't branched for scarthgap yet.

bibake-layers layerindex-fetch --branch master meta-networking is just fine.
Comment 5 Simone Weiß 2024-03-16 09:22:16 UTC
This would maybe do, but feels too messy for me
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index d4b1d1aaf2..78c316fff7 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -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('-T', '--notinfoil', help='Force run without tinfoil, this might fail.', 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.notinfoil:
+        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.notinfoil:
                 plugin.tinfoil_init(tinfoil)
             if hasattr(plugin, 'register_commands'):
                 registered = True
Comment 6 Simone Weiß 2024-03-16 09:24:49 UTC
(In reply to Simone Weiß from comment #5)
> This would maybe do, but feels too messy for me
> diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
> index d4b1d1aaf2..78c316fff7 100755
> --- a/bitbake/bin/bitbake-layers
> +++ b/bitbake/bin/bitbake-layers
> @@ -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('-T', '--notinfoil', help='Force run without
> tinfoil, this might fail.', 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.notinfoil:
> +        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.notinfoil:
>                  plugin.tinfoil_init(tinfoil)
>              if hasattr(plugin, 'register_commands'):
>                  registered = True

And then also using this in bitbake/lib/bblayers/action.py
 for adding and removing...
Comment 7 Pavel Zhukov 2024-03-22 15:57:44 UTC
This is even worse. 


$ bitbake-layers add-layer  ../../sources/meta-openembedded/meta-python/
NOTE: Starting bitbake server...
ERROR: Layer 'networking-layer' depends on layer 'meta-python', but this layer is not enabled in your configuration