summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2025-01-29 15:20:12 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-02-01 13:20:45 +0000
commit1923c62feeec014bd098b2080f37cf7b72dcb4c1 (patch)
tree8a9ae7ace12eb8b3fe29bc636d73e95dad1ec89a /scripts/lib/devtool/standard.py
parent49f9970c75e77689f3f7b0de11c4206c109f24c6 (diff)
downloadpoky-1923c62feeec014bd098b2080f37cf7b72dcb4c1.tar.gz
devtool: standard: cleanup imports; stop relying on transitive bb imports
(From OE-Core rev: 8457e24f60a9a84e0f1cfc4a28a39989534fa7de) Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-rw-r--r--scripts/lib/devtool/standard.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index fa846ce61a..305536f6f0 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -19,9 +19,12 @@ import scriptutils
19import errno 19import errno
20import glob 20import glob
21from collections import OrderedDict 21from collections import OrderedDict
22
22from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, setup_git_repo, recipe_to_append, get_bbclassextend_targets, update_unlockedsigs, check_prerelease_version, check_git_repo_dirty, check_git_repo_op, DevtoolError 23from devtool import exec_build_env_command, setup_tinfoil, check_workspace_recipe, use_external_build, setup_git_repo, recipe_to_append, get_bbclassextend_targets, update_unlockedsigs, check_prerelease_version, check_git_repo_dirty, check_git_repo_op, DevtoolError
23from devtool import parse_recipe 24from devtool import parse_recipe
24 25
26import bb.utils
27
25logger = logging.getLogger('devtool') 28logger = logging.getLogger('devtool')
26 29
27override_branch_prefix = 'devtool-override-' 30override_branch_prefix = 'devtool-override-'
@@ -29,7 +32,8 @@ override_branch_prefix = 'devtool-override-'
29 32
30def add(args, config, basepath, workspace): 33def add(args, config, basepath, workspace):
31 """Entry point for the devtool 'add' subcommand""" 34 """Entry point for the devtool 'add' subcommand"""
32 import bb 35 import bb.data
36 import bb.process
33 import oe.recipeutils 37 import oe.recipeutils
34 38
35 if not args.recipename and not args.srctree and not args.fetch and not args.fetchuri: 39 if not args.recipename and not args.srctree and not args.fetch and not args.fetchuri:
@@ -304,6 +308,7 @@ def add(args, config, basepath, workspace):
304 308
305def _check_compatible_recipe(pn, d): 309def _check_compatible_recipe(pn, d):
306 """Check if the recipe is supported by devtool""" 310 """Check if the recipe is supported by devtool"""
311 import bb.data
307 if pn == 'perf': 312 if pn == 'perf':
308 raise DevtoolError("The perf recipe does not actually check out " 313 raise DevtoolError("The perf recipe does not actually check out "
309 "source and thus cannot be supported by this tool", 314 "source and thus cannot be supported by this tool",
@@ -373,7 +378,7 @@ def _copy_file(src, dst, dry_run_outdir=None, base_outdir=None):
373 378
374def _git_ls_tree(repodir, treeish='HEAD', recursive=False): 379def _git_ls_tree(repodir, treeish='HEAD', recursive=False):
375 """List contents of a git treeish""" 380 """List contents of a git treeish"""
376 import bb 381 import bb.process
377 cmd = ['git', 'ls-tree', '-z', treeish] 382 cmd = ['git', 'ls-tree', '-z', treeish]
378 if recursive: 383 if recursive:
379 cmd.append('-r') 384 cmd.append('-r')
@@ -388,7 +393,7 @@ def _git_ls_tree(repodir, treeish='HEAD', recursive=False):
388 393
389def _git_modified(repodir): 394def _git_modified(repodir):
390 """List the difference between HEAD and the index""" 395 """List the difference between HEAD and the index"""
391 import bb 396 import bb.process
392 cmd = ['git', 'status', '--porcelain'] 397 cmd = ['git', 'status', '--porcelain']
393 out, _ = bb.process.run(cmd, cwd=repodir) 398 out, _ = bb.process.run(cmd, cwd=repodir)
394 ret = [] 399 ret = []
@@ -426,8 +431,6 @@ def _ls_tree(directory):
426 431
427def extract(args, config, basepath, workspace): 432def extract(args, config, basepath, workspace):
428 """Entry point for the devtool 'extract' subcommand""" 433 """Entry point for the devtool 'extract' subcommand"""
429 import bb
430
431 tinfoil = setup_tinfoil(basepath=basepath, tracking=True) 434 tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
432 if not tinfoil: 435 if not tinfoil:
433 # Error already shown 436 # Error already shown
@@ -450,8 +453,6 @@ def extract(args, config, basepath, workspace):
450 453
451def sync(args, config, basepath, workspace): 454def sync(args, config, basepath, workspace):
452 """Entry point for the devtool 'sync' subcommand""" 455 """Entry point for the devtool 'sync' subcommand"""
453 import bb
454
455 tinfoil = setup_tinfoil(basepath=basepath, tracking=True) 456 tinfoil = setup_tinfoil(basepath=basepath, tracking=True)
456 if not tinfoil: 457 if not tinfoil:
457 # Error already shown 458 # Error already shown
@@ -474,9 +475,9 @@ def sync(args, config, basepath, workspace):
474 475
475def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False): 476def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, workspace, fixed_setup, d, tinfoil, no_overrides=False):
476 """Extract sources of a recipe""" 477 """Extract sources of a recipe"""
477 import oe.recipeutils
478 import oe.patch
479 import oe.path 478 import oe.path
479 import bb.data
480 import bb.process
480 481
481 pn = d.getVar('PN') 482 pn = d.getVar('PN')
482 483
@@ -677,8 +678,6 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works
677 678
678def _add_md5(config, recipename, filename): 679def _add_md5(config, recipename, filename):
679 """Record checksum of a file (or recursively for a directory) to the md5-file of the workspace""" 680 """Record checksum of a file (or recursively for a directory) to the md5-file of the workspace"""
680 import bb.utils
681
682 def addfile(fn): 681 def addfile(fn):
683 md5 = bb.utils.md5_file(fn) 682 md5 = bb.utils.md5_file(fn)
684 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a+') as f: 683 with open(os.path.join(config.workspace_path, '.devtool_md5'), 'a+') as f:
@@ -697,7 +696,6 @@ def _add_md5(config, recipename, filename):
697def _check_preserve(config, recipename): 696def _check_preserve(config, recipename):
698 """Check if a file was manually changed and needs to be saved in 'attic' 697 """Check if a file was manually changed and needs to be saved in 'attic'
699 directory""" 698 directory"""
700 import bb.utils
701 origfile = os.path.join(config.workspace_path, '.devtool_md5') 699 origfile = os.path.join(config.workspace_path, '.devtool_md5')
702 newfile = os.path.join(config.workspace_path, '.devtool_md5_new') 700 newfile = os.path.join(config.workspace_path, '.devtool_md5_new')
703 preservepath = os.path.join(config.workspace_path, 'attic', recipename) 701 preservepath = os.path.join(config.workspace_path, 'attic', recipename)
@@ -739,6 +737,7 @@ def get_staging_kver(srcdir):
739 return staging_kerVer 737 return staging_kerVer
740 738
741def get_staging_kbranch(srcdir): 739def get_staging_kbranch(srcdir):
740 import bb.process
742 staging_kbranch = "" 741 staging_kbranch = ""
743 if os.path.exists(srcdir) and os.listdir(srcdir): 742 if os.path.exists(srcdir) and os.listdir(srcdir):
744 (branch, _) = bb.process.run('git branch | grep \\* | cut -d \' \' -f2', cwd=srcdir) 743 (branch, _) = bb.process.run('git branch | grep \\* | cut -d \' \' -f2', cwd=srcdir)
@@ -757,7 +756,8 @@ def get_real_srctree(srctree, s, workdir):
757 756
758def modify(args, config, basepath, workspace): 757def modify(args, config, basepath, workspace):
759 """Entry point for the devtool 'modify' subcommand""" 758 """Entry point for the devtool 'modify' subcommand"""
760 import bb 759 import bb.data
760 import bb.process
761 import oe.recipeutils 761 import oe.recipeutils
762 import oe.patch 762 import oe.patch
763 import oe.path 763 import oe.path
@@ -1183,7 +1183,7 @@ def _get_patchset_revs(srctree, recipe_path, initial_rev=None, force_patch_refre
1183 """Get initial and update rev of a recipe. These are the start point of the 1183 """Get initial and update rev of a recipe. These are the start point of the
1184 whole patchset and start point for the patches to be re-generated/updated. 1184 whole patchset and start point for the patches to be re-generated/updated.
1185 """ 1185 """
1186 import bb 1186 import bb.process
1187 1187
1188 # Get current branch 1188 # Get current branch
1189 stdout, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', 1189 stdout, _ = bb.process.run('git rev-parse --abbrev-ref HEAD',
@@ -1309,6 +1309,7 @@ def _export_patches(srctree, rd, start_revs, destdir, changed_revs=None):
1309 """ 1309 """
1310 import oe.recipeutils 1310 import oe.recipeutils
1311 from oe.patch import GitApplyTree 1311 from oe.patch import GitApplyTree
1312 import bb.process
1312 updated = OrderedDict() 1313 updated = OrderedDict()
1313 added = OrderedDict() 1314 added = OrderedDict()
1314 seqpatch_re = re.compile('^([0-9]{4}-)?(.+)') 1315 seqpatch_re = re.compile('^([0-9]{4}-)?(.+)')
@@ -1378,6 +1379,7 @@ def _export_patches(srctree, rd, start_revs, destdir, changed_revs=None):
1378 1379
1379def _create_kconfig_diff(srctree, rd, outfile): 1380def _create_kconfig_diff(srctree, rd, outfile):
1380 """Create a kconfig fragment""" 1381 """Create a kconfig fragment"""
1382 import bb.process
1381 # Only update config fragment if both config files exist 1383 # Only update config fragment if both config files exist
1382 orig_config = os.path.join(srctree, '.config.baseline') 1384 orig_config = os.path.join(srctree, '.config.baseline')
1383 new_config = os.path.join(srctree, '.config.new') 1385 new_config = os.path.join(srctree, '.config.new')
@@ -1415,6 +1417,8 @@ def _export_local_files(srctree, rd, destdir, srctreebase):
1415 - for removed dict, the absolute path to the existing file in recipe space 1417 - for removed dict, the absolute path to the existing file in recipe space
1416 """ 1418 """
1417 import oe.recipeutils 1419 import oe.recipeutils
1420 import bb.data
1421 import bb.process
1418 1422
1419 # Find out local files (SRC_URI files that exist in the "recipe space"). 1423 # Find out local files (SRC_URI files that exist in the "recipe space").
1420 # Local files that reside in srctree are not included in patch generation. 1424 # Local files that reside in srctree are not included in patch generation.
@@ -1506,7 +1510,7 @@ def _determine_files_dir(rd):
1506 1510
1507def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, dry_run_outdir=None): 1511def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, dry_run_outdir=None):
1508 """Implement the 'srcrev' mode of update-recipe""" 1512 """Implement the 'srcrev' mode of update-recipe"""
1509 import bb 1513 import bb.process
1510 import oe.recipeutils 1514 import oe.recipeutils
1511 1515
1512 dry_run_suffix = ' (dry-run)' if dry_run_outdir else '' 1516 dry_run_suffix = ' (dry-run)' if dry_run_outdir else ''
@@ -1607,7 +1611,6 @@ def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi
1607 1611
1608def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev, dry_run_outdir=None, force_patch_refresh=False): 1612def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev, dry_run_outdir=None, force_patch_refresh=False):
1609 """Implement the 'patch' mode of update-recipe""" 1613 """Implement the 'patch' mode of update-recipe"""
1610 import bb
1611 import oe.recipeutils 1614 import oe.recipeutils
1612 1615
1613 recipefile = rd.getVar('FILE') 1616 recipefile = rd.getVar('FILE')
@@ -1786,6 +1789,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
1786 1789
1787def _guess_recipe_update_mode(srctree, rdata): 1790def _guess_recipe_update_mode(srctree, rdata):
1788 """Guess the recipe update mode to use""" 1791 """Guess the recipe update mode to use"""
1792 import bb.process
1789 src_uri = (rdata.getVar('SRC_URI') or '').split() 1793 src_uri = (rdata.getVar('SRC_URI') or '').split()
1790 git_uris = [uri for uri in src_uri if uri.startswith('git://')] 1794 git_uris = [uri for uri in src_uri if uri.startswith('git://')]
1791 if not git_uris: 1795 if not git_uris:
@@ -1807,6 +1811,8 @@ def _guess_recipe_update_mode(srctree, rdata):
1807 return 'patch' 1811 return 'patch'
1808 1812
1809def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev, no_report_remove=False, dry_run_outdir=None, no_overrides=False, force_patch_refresh=False): 1813def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev, no_report_remove=False, dry_run_outdir=None, no_overrides=False, force_patch_refresh=False):
1814 import bb.data
1815 import bb.process
1810 srctree = workspace[recipename]['srctree'] 1816 srctree = workspace[recipename]['srctree']
1811 if mode == 'auto': 1817 if mode == 'auto':
1812 mode = _guess_recipe_update_mode(srctree, rd) 1818 mode = _guess_recipe_update_mode(srctree, rd)
@@ -1929,6 +1935,7 @@ def status(args, config, basepath, workspace):
1929 1935
1930def _reset(recipes, no_clean, remove_work, config, basepath, workspace): 1936def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
1931 """Reset one or more recipes""" 1937 """Reset one or more recipes"""
1938 import bb.process
1932 import oe.path 1939 import oe.path
1933 1940
1934 def clean_preferred_provider(pn, layerconf_path): 1941 def clean_preferred_provider(pn, layerconf_path):
@@ -2032,8 +2039,6 @@ def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
2032 2039
2033def reset(args, config, basepath, workspace): 2040def reset(args, config, basepath, workspace):
2034 """Entry point for the devtool 'reset' subcommand""" 2041 """Entry point for the devtool 'reset' subcommand"""
2035 import bb
2036 import shutil
2037 2042
2038 recipes = "" 2043 recipes = ""
2039 2044