diff options
-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) |