Fix "devtool finish --force" command, by allowing to copy folders that
were not previously existing but also by preventing it from trying to
remove non-existent files. Devtool was particularly confused when using
the finish subcommand on a recipe that was just added.

Reproducer:

devtool add --version 2.10 https://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
...
devtool build hello
...
devtool finish hello -f ../openembedded-core/meta/
...
Traceback (most recent call last):
  File "/home/mathieu/projects/swat/gits/openembedded-core/scripts/devtool", 
line 352, in <module>
    ret = main()
  File "/home/mathieu/projects/swat/gits/openembedded-core/scripts/devtool", 
line 338, in main
    ret = args.func(args, config, basepath, workspace)
  File 
"/home/mathieu/projects/swat/gits/openembedded-core/scripts/lib/devtool/standard.py",
 line 2214, in finish
    updated, appendfile, removed = _update_recipe(args.recipename, workspace, 
rd, args.mode, appendlayerdir, wildcard_version=True, no_remove=False, 
no_report_remove=removing_original, initial_rev=args.initial_rev, 
dry_run_outdir=dry_run_outdir, no_overrides=args.no_overrides, 
force_patch_refresh=args.force_patch_refresh)
                                   
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/home/mathieu/projects/swat/gits/openembedded-core/scripts/lib/devtool/standard.py",
 line 1903, in _update_recipe
    updated, appendf, removed = _update_recipe_patch(recipename, workspace, 
srctree, crd, appendlayerdir, wildcard_version, no_remove, no_report_remove, 
initial_rev, dry_run_outdir, force_patch_refresh)
                                
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/home/mathieu/projects/swat/gits/openembedded-core/scripts/lib/devtool/standard.py",
 line 1675, in _update_recipe_patch
    upd_f, new_f, del_f = _export_local_files(srctree, rd, local_files_dir, 
srctreebase)
                          
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File 
"/home/mathieu/projects/swat/gits/openembedded-core/scripts/lib/devtool/standard.py",
 line 1469, in _export_local_files
    shutil.copy2(fullfile, os.path.join(destdir, f))
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 468, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/shutil.py", line 262, in copyfile
    with open(dst, 'wb') as fdst:
         ~~~~^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 
'/tmp/devtool77jejua2/tmpyuo3c_ay/build-aux/compile'

Using --force is arguably a bad idea here, but as we do provide this
possibility, we should make sure the code does not crash.

Signed-off-by: Mathieu Dubois-Briand <[email protected]>
---
Mathieu Dubois-Briand (4):
      scripts: scriptutils: Use LicenseRef-Proprietary LICENSE while fetching
      devtool: standard: Fix file copy on finish --force
      devtool: standard: Remove unused variable
      oe-selftest: devtool: Add test for add/finish workflow

 meta/lib/oeqa/selftest/cases/devtool.py | 58 +++++++++++++++++++++++++++++++++
 scripts/lib/devtool/standard.py         |  9 +++--
 scripts/lib/scriptutils.py              |  2 +-
 3 files changed, 65 insertions(+), 4 deletions(-)
---
base-commit: dd003e147db548d9c86821a08450d6461d061cea
change-id: 20260813-mathieu-devtool-9b0b2768098f

Best regards,
-- 
Mathieu Dubois-Briand <[email protected]>

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#243459): 
https://lists.openembedded.org/g/openembedded-core/message/243459
Mute This Topic: https://lists.openembedded.org/mt/120751632/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to