diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-09-02 17:44:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-10-29 10:41:34 +0000 |
commit | 48755f1a4a663e7cc88be0d57ff2611771fe29cb (patch) | |
tree | 14cccbd9d28ef7b2c7670f575a90d902eaa26db4 /scripts/oe-pkgdata-util | |
parent | 4ec1f8c0181b7f50214e64c39f0f69e991b49194 (diff) | |
download | poky-48755f1a4a663e7cc88be0d57ff2611771fe29cb.tar.gz |
scripts/oe-pkgdata-util: add ability to search for a target path
Add ability to search for a target path in produced packages, in order
to find which package provides a specific file.
(From OE-Core rev: 0824f2f5cf4e05f82b6986ce6fb22fa1392b7776)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-pkgdata-util')
-rwxr-xr-x | scripts/oe-pkgdata-util | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index 01fccd2db0..2d896d03a9 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util | |||
@@ -186,6 +186,38 @@ def read_value(args, usage): | |||
186 | qvar = "%s_%s" % (var, mappedpkg) | 186 | qvar = "%s_%s" % (var, mappedpkg) |
187 | print(readvar(revlink, qvar)) | 187 | print(readvar(revlink, qvar)) |
188 | 188 | ||
189 | def find_path(args, usage): | ||
190 | if len(args) < 2: | ||
191 | usage() | ||
192 | sys.exit(1) | ||
193 | |||
194 | pkgdata_dir = args[0] | ||
195 | targetpath = args[1] | ||
196 | |||
197 | if not os.path.exists(pkgdata_dir): | ||
198 | print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir) | ||
199 | sys.exit(1) | ||
200 | |||
201 | import ast | ||
202 | import fnmatch | ||
203 | |||
204 | for root, dirs, files in os.walk(os.path.join(pkgdata_dir, 'runtime')): | ||
205 | for fn in files: | ||
206 | pkgsplitname = '/packages-split/%s' % fn | ||
207 | with open(os.path.join(root,fn)) as f: | ||
208 | for line in f: | ||
209 | if line.startswith('FILES_INFO:'): | ||
210 | val = line.split(':', 1)[1].strip().replace('\\\'', '\'') | ||
211 | dictval = ast.literal_eval(val) | ||
212 | for parent, dirlist in dictval.items(): | ||
213 | idx = parent.find(pkgsplitname) | ||
214 | if idx > -1: | ||
215 | parent = parent[idx+len(pkgsplitname):] | ||
216 | for basename in dirlist: | ||
217 | fullpth = os.path.join(parent, basename) | ||
218 | if fnmatch.fnmatchcase(fullpth, targetpath): | ||
219 | print("%s: %s" % (fn, fullpth)) | ||
220 | |||
189 | 221 | ||
190 | def main(): | 222 | def main(): |
191 | parser = optparse.OptionParser( | 223 | parser = optparse.OptionParser( |
@@ -195,6 +227,8 @@ Available commands: | |||
195 | glob <pkgdatadir> <pkglistfile> "<globs>" | 227 | glob <pkgdatadir> <pkglistfile> "<globs>" |
196 | expand one or more glob expressions over the packages listed in | 228 | expand one or more glob expressions over the packages listed in |
197 | pkglistfile (one package per line) | 229 | pkglistfile (one package per line) |
230 | find-path <pkgdatadir> <path> | ||
231 | find the package providing the specified path (wildcards * ? allowed) | ||
198 | read-value <pkgdatadir> <value-name> "<pkgs>" | 232 | read-value <pkgdatadir> <value-name> "<pkgs>" |
199 | read the named value from the pkgdata files for the specified | 233 | read the named value from the pkgdata files for the specified |
200 | packages''') | 234 | packages''') |
@@ -212,6 +246,8 @@ Available commands: | |||
212 | 246 | ||
213 | if args[0] == "glob": | 247 | if args[0] == "glob": |
214 | glob(args[1:], parser.print_help) | 248 | glob(args[1:], parser.print_help) |
249 | elif args[0] == "find-path": | ||
250 | find_path(args[1:], parser.print_help) | ||
215 | elif args[0] == "read-value": | 251 | elif args[0] == "read-value": |
216 | read_value(args[1:], parser.print_help) | 252 | read_value(args[1:], parser.print_help) |
217 | else: | 253 | else: |