diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2018-02-26 14:50:00 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-03-01 22:13:56 +0000 |
commit | e8c7c36c60da20df4e261f27b1606f8e2aa2e441 (patch) | |
tree | 2c670d38d48e70bae20d711b315f625b74ed0bc5 /scripts/lib | |
parent | 2f48cb606b0250b5589db78e0d90917c1878fae7 (diff) | |
download | poky-e8c7c36c60da20df4e261f27b1606f8e2aa2e441.tar.gz |
devtool: search: also look in recipe cache
If pkgdata isn't present or is incomplete, then you get either a
traceback or you don't see the results you were hoping for. The recipe
cache that bitbake collects during startup contains some useful
information for each recipe that we could search through as well, and
we can access it easily using tinfoil's all_recipes() API function,
so add some code that does that. (We still show a warning if pkgdata
isn't present, as there are certain dynamic packages that are generated
at packaging time that won't show up in the cache).
One side-effect of this is that we will start showing non-target
recipes - that's actually a good thing, since seeing those is useful,
however we exclude nativesdk recipes when in the eSDK to avoid confusion
since nativesdk isn't directly applicable there.
Fixes [YOCTO #12356].
(From OE-Core rev: b8406383886d09a80a9a002150dcf364fa9902d7)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/devtool/search.py | 96 |
1 files changed, 63 insertions, 33 deletions
diff --git a/scripts/lib/devtool/search.py b/scripts/lib/devtool/search.py index 054985b85d..b51a7b8020 100644 --- a/scripts/lib/devtool/search.py +++ b/scripts/lib/devtool/search.py | |||
@@ -36,44 +36,74 @@ def search(args, config, basepath, workspace): | |||
36 | 36 | ||
37 | keyword_rc = re.compile(args.keyword) | 37 | keyword_rc = re.compile(args.keyword) |
38 | 38 | ||
39 | for fn in os.listdir(pkgdata_dir): | 39 | def print_match(pn): |
40 | pfn = os.path.join(pkgdata_dir, fn) | 40 | rd = parse_recipe(config, tinfoil, pn, True) |
41 | if not os.path.isfile(pfn): | 41 | if not rd: |
42 | return | ||
43 | summary = rd.getVar('SUMMARY') | ||
44 | if summary == rd.expand(defsummary): | ||
45 | summary = '' | ||
46 | print("%s %s" % (pn.ljust(20), summary)) | ||
47 | |||
48 | |||
49 | matches = [] | ||
50 | if os.path.exists(pkgdata_dir): | ||
51 | for fn in os.listdir(pkgdata_dir): | ||
52 | pfn = os.path.join(pkgdata_dir, fn) | ||
53 | if not os.path.isfile(pfn): | ||
54 | continue | ||
55 | |||
56 | packages = [] | ||
57 | match = False | ||
58 | if keyword_rc.search(fn): | ||
59 | match = True | ||
60 | |||
61 | if not match: | ||
62 | with open(pfn, 'r') as f: | ||
63 | for line in f: | ||
64 | if line.startswith('PACKAGES:'): | ||
65 | packages = line.split(':', 1)[1].strip().split() | ||
66 | |||
67 | for pkg in packages: | ||
68 | if keyword_rc.search(pkg): | ||
69 | match = True | ||
70 | break | ||
71 | if os.path.exists(os.path.join(pkgdata_dir, 'runtime', pkg + '.packaged')): | ||
72 | with open(os.path.join(pkgdata_dir, 'runtime', pkg), 'r') as f: | ||
73 | for line in f: | ||
74 | if ': ' in line: | ||
75 | splitline = line.split(':', 1) | ||
76 | key = splitline[0] | ||
77 | value = splitline[1].strip() | ||
78 | if key in ['PKG_%s' % pkg, 'DESCRIPTION', 'FILES_INFO'] or key.startswith('FILERPROVIDES_'): | ||
79 | if keyword_rc.search(value): | ||
80 | match = True | ||
81 | break | ||
82 | if match: | ||
83 | print_match(fn) | ||
84 | matches.append(fn) | ||
85 | else: | ||
86 | logger.warning('Package data is not available, results may be limited') | ||
87 | |||
88 | for recipe in tinfoil.all_recipes(): | ||
89 | if args.fixed_setup and 'nativesdk' in recipe.inherits(): | ||
42 | continue | 90 | continue |
43 | 91 | ||
44 | packages = [] | ||
45 | match = False | 92 | match = False |
46 | if keyword_rc.search(fn): | 93 | if keyword_rc.search(recipe.pn): |
47 | match = True | 94 | match = True |
48 | 95 | else: | |
49 | if not match: | 96 | for prov in recipe.provides: |
50 | with open(pfn, 'r') as f: | 97 | if keyword_rc.search(prov): |
51 | for line in f: | ||
52 | if line.startswith('PACKAGES:'): | ||
53 | packages = line.split(':', 1)[1].strip().split() | ||
54 | |||
55 | for pkg in packages: | ||
56 | if keyword_rc.search(pkg): | ||
57 | match = True | 98 | match = True |
58 | break | 99 | break |
59 | if os.path.exists(os.path.join(pkgdata_dir, 'runtime', pkg + '.packaged')): | 100 | if not match: |
60 | with open(os.path.join(pkgdata_dir, 'runtime', pkg), 'r') as f: | 101 | for rprov in recipe.rprovides: |
61 | for line in f: | 102 | if keyword_rc.search(rprov): |
62 | if ': ' in line: | 103 | match = True |
63 | splitline = line.split(':', 1) | 104 | break |
64 | key = splitline[0] | 105 | if match and not recipe.pn in matches: |
65 | value = splitline[1].strip() | 106 | print_match(recipe.pn) |
66 | if key in ['PKG_%s' % pkg, 'DESCRIPTION', 'FILES_INFO'] or key.startswith('FILERPROVIDES_'): | ||
67 | if keyword_rc.search(value): | ||
68 | match = True | ||
69 | break | ||
70 | |||
71 | if match: | ||
72 | rd = parse_recipe(config, tinfoil, fn, True) | ||
73 | summary = rd.getVar('SUMMARY') | ||
74 | if summary == rd.expand(defsummary): | ||
75 | summary = '' | ||
76 | print("%s %s" % (fn.ljust(20), summary)) | ||
77 | finally: | 107 | finally: |
78 | tinfoil.shutdown() | 108 | tinfoil.shutdown() |
79 | 109 | ||
@@ -85,4 +115,4 @@ def register_commands(subparsers, context): | |||
85 | description='Searches for available target recipes. Matches on recipe name, package name, description and installed files, and prints the recipe name on match.', | 115 | description='Searches for available target recipes. Matches on recipe name, package name, description and installed files, and prints the recipe name on match.', |
86 | group='info') | 116 | group='info') |
87 | parser_search.add_argument('keyword', help='Keyword to search for (regular expression syntax allowed)') | 117 | parser_search.add_argument('keyword', help='Keyword to search for (regular expression syntax allowed)') |
88 | parser_search.set_defaults(func=search, no_workspace=True) | 118 | parser_search.set_defaults(func=search, no_workspace=True, fixed_setup=context.fixed_setup) |