diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-12-02 18:50:44 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-12-03 17:45:49 +0000 |
commit | 4a75e83b29d6736a17d3a461774adb18b8ff5abf (patch) | |
tree | 4f676dbd0a8ca75e13c31287439a6b498bb72712 | |
parent | a6450a951fd52d1330c577139dd492f0c8abb1f8 (diff) | |
download | poky-4a75e83b29d6736a17d3a461774adb18b8ff5abf.tar.gz |
classes/package: fix FILES_INFO serialisation in pkgdata
The FILES_INFO entry in each pkgdata file stores the list of files for
each package. Make the following improvements to how this is stored:
* Store paths as they would be seen on the target rather than
erroneously including the full path to PKGDEST (which is specific to
the build host the package was built on)
* For simplicity when loading the data, store complete paths for each
entry instead of trying to break off the first part and use it as the
dict key
* Record sizes for each file (as needed by Toaster)
* Serialise the value explicitly using json rather than just passing it
through str().
Fixes [YOCTO #5443].
(From OE-Core rev: ca86603607a69a17cc5540d69de0e242b33382d3)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/package.bbclass | 19 | ||||
-rw-r--r-- | meta/classes/toaster.bbclass | 28 | ||||
-rwxr-xr-x | scripts/oe-pkgdata-util | 19 |
3 files changed, 21 insertions, 45 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 48bb9828f5..cce2499122 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -1110,6 +1110,7 @@ PKGDESTWORK = "${WORKDIR}/pkgdata" | |||
1110 | 1110 | ||
1111 | python emit_pkgdata() { | 1111 | python emit_pkgdata() { |
1112 | from glob import glob | 1112 | from glob import glob |
1113 | import json | ||
1113 | 1114 | ||
1114 | def write_if_exists(f, pkg, var): | 1115 | def write_if_exists(f, pkg, var): |
1115 | def encode(str): | 1116 | def encode(str): |
@@ -1173,22 +1174,20 @@ python emit_pkgdata() { | |||
1173 | workdir = d.getVar('WORKDIR', True) | 1174 | workdir = d.getVar('WORKDIR', True) |
1174 | 1175 | ||
1175 | for pkg in packages.split(): | 1176 | for pkg in packages.split(): |
1176 | items = {} | ||
1177 | for files_list in pkgfiles[pkg]: | ||
1178 | item_name = os.path.basename(files_list) | ||
1179 | item_path = os.path.dirname(files_list) | ||
1180 | if item_path not in items: | ||
1181 | items[item_path] = [] | ||
1182 | items[item_path].append(item_name) | ||
1183 | subdata_file = pkgdatadir + "/runtime/%s" % pkg | ||
1184 | |||
1185 | pkgval = d.getVar('PKG_%s' % pkg, True) | 1177 | pkgval = d.getVar('PKG_%s' % pkg, True) |
1186 | if pkgval is None: | 1178 | if pkgval is None: |
1187 | pkgval = pkg | 1179 | pkgval = pkg |
1188 | d.setVar('PKG_%s' % pkg, pkg) | 1180 | d.setVar('PKG_%s' % pkg, pkg) |
1189 | 1181 | ||
1190 | d.setVar('FILES_INFO', str(items)) | 1182 | pkgdestpkg = os.path.join(pkgdest, pkg) |
1183 | files = {} | ||
1184 | for f in pkgfiles[pkg]: | ||
1185 | relpth = os.path.relpath(f, pkgdestpkg) | ||
1186 | fstat = os.lstat(f) | ||
1187 | files[os.sep + relpth] = fstat.st_size | ||
1188 | d.setVar('FILES_INFO', json.dumps(files)) | ||
1191 | 1189 | ||
1190 | subdata_file = pkgdatadir + "/runtime/%s" % pkg | ||
1192 | sf = open(subdata_file, 'w') | 1191 | sf = open(subdata_file, 'w') |
1193 | write_if_exists(sf, pkg, 'PN') | 1192 | write_if_exists(sf, pkg, 'PN') |
1194 | write_if_exists(sf, pkg, 'PV') | 1193 | write_if_exists(sf, pkg, 'PV') |
diff --git a/meta/classes/toaster.bbclass b/meta/classes/toaster.bbclass index 7dbb3844d7..8dc1663165 100644 --- a/meta/classes/toaster.bbclass +++ b/meta/classes/toaster.bbclass | |||
@@ -39,8 +39,7 @@ python toaster_package_dumpdata() { | |||
39 | 39 | ||
40 | 40 | ||
41 | # scan and send data for each package | 41 | # scan and send data for each package |
42 | import ast | 42 | import json |
43 | import fnmatch | ||
44 | 43 | ||
45 | lpkgdata = {} | 44 | lpkgdata = {} |
46 | for pkg in packages.split(): | 45 | for pkg in packages.split(): |
@@ -54,28 +53,11 @@ python toaster_package_dumpdata() { | |||
54 | (n, v) = line.rstrip().split(":", 1) | 53 | (n, v) = line.rstrip().split(":", 1) |
55 | if pkg in n: | 54 | if pkg in n: |
56 | n = n.replace("_" + pkg, "") | 55 | n = n.replace("_" + pkg, "") |
57 | lpkgdata[n] = v.strip() | ||
58 | line = sf.readline() | ||
59 | pkgsplitname = os.path.join(pkgdest, pkg) | ||
60 | # replace FILES_INFO data with a dictionary of file name - file size | ||
61 | if n == 'FILES_INFO': | 56 | if n == 'FILES_INFO': |
62 | filesizedata = {} | 57 | lpkgdata[n] = json.loads(v) |
63 | val = v.strip().replace('\\\'', '\'') | 58 | else: |
64 | dictval = ast.literal_eval(val) | 59 | lpkgdata[n] = v.strip() |
65 | for parent, dirlist in dictval.items(): | 60 | line = sf.readline() |
66 | idx = parent.find(pkgsplitname) | ||
67 | if idx > -1: | ||
68 | parent = parent[idx+len(pkgsplitname):] | ||
69 | else: | ||
70 | bb.error("Invalid path while looking for file ", parent) | ||
71 | for basename in dirlist: | ||
72 | fullpath = os.path.join(parent, basename) | ||
73 | try: | ||
74 | filesizedata[fullpath] = os.stat(pkgsplitname + fullpath).st_size | ||
75 | except OSError: | ||
76 | # we may hit a symlink that is not pointing correctly over package-split | ||
77 | filesizedata[fullpath] = 0 | ||
78 | lpkgdata[n] = filesizedata | ||
79 | 61 | ||
80 | # Fire an event containing the pkg data | 62 | # Fire an event containing the pkg data |
81 | bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d) | 63 | bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d) |
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index 17e946e1e4..03c8f95305 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util | |||
@@ -262,25 +262,20 @@ def find_path(args, usage, debug=False): | |||
262 | print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir) | 262 | print('ERROR: Unable to find pkgdata directory %s' % pkgdata_dir) |
263 | sys.exit(1) | 263 | sys.exit(1) |
264 | 264 | ||
265 | import ast | 265 | import json |
266 | import fnmatch | 266 | import fnmatch |
267 | 267 | ||
268 | for root, dirs, files in os.walk(os.path.join(pkgdata_dir, 'runtime')): | 268 | for root, dirs, files in os.walk(os.path.join(pkgdata_dir, 'runtime')): |
269 | for fn in files: | 269 | for fn in files: |
270 | pkgsplitname = '/packages-split/%s' % fn | ||
271 | with open(os.path.join(root,fn)) as f: | 270 | with open(os.path.join(root,fn)) as f: |
272 | for line in f: | 271 | for line in f: |
273 | if line.startswith('FILES_INFO:'): | 272 | if line.startswith('FILES_INFO:'): |
274 | val = line.split(':', 1)[1].strip().replace('\\\'', '\'') | 273 | val = line.split(':', 1)[1].strip() |
275 | dictval = ast.literal_eval(val) | 274 | dictval = json.loads(val) |
276 | for parent, dirlist in dictval.items(): | 275 | for fullpth in dictval.keys(): |
277 | idx = parent.find(pkgsplitname) | 276 | if fnmatch.fnmatchcase(fullpth, targetpath): |
278 | if idx > -1: | 277 | print("%s: %s" % (fn, fullpth)) |
279 | parent = parent[idx+len(pkgsplitname):] | 278 | break |
280 | for basename in dirlist: | ||
281 | fullpth = os.path.join(parent, basename) | ||
282 | if fnmatch.fnmatchcase(fullpth, targetpath): | ||
283 | print("%s: %s" % (fn, fullpth)) | ||
284 | 279 | ||
285 | 280 | ||
286 | def main(): | 281 | def main(): |