diff options
| author | Andres Beltran <abeltran@linux.microsoft.com> | 2021-08-12 16:58:56 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-27 11:54:34 +0100 |
| commit | 37e0565c11240a3e1e1acec338d9695666757fa3 (patch) | |
| tree | 9954345537c369b54397537062c64b652b15fb17 /scripts/oe-pkgdata-util | |
| parent | 51a174f501e00c0fb1ccbcea04bf58e361b99bbb (diff) | |
| download | poky-37e0565c11240a3e1e1acec338d9695666757fa3.tar.gz | |
buildhistory: Add output file listing package information
Currently, buildhistory does not produce a single file combining relevant
information of installed packages. Produce an output file
"installed-package-info.txt" listing a package's runtime name, buildtime name,
its recipe, version, and size to avoid having to look up each package externally.
Leave the existing package list files as-is for backwards compatibility.
In order to support this efficiently, extend oe-pkgdata-util to accept multiple keys
for its read-value argument.
(From OE-Core rev: 1e18b514bf1f960d324a21db608c8e8e5af007ef)
Signed-off-by: Andres Beltran <abeltran@linux.microsoft.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/oe-pkgdata-util')
| -rwxr-xr-x | scripts/oe-pkgdata-util | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util index ffa3850b8b..71656dadce 100755 --- a/scripts/oe-pkgdata-util +++ b/scripts/oe-pkgdata-util | |||
| @@ -171,7 +171,7 @@ def read_value(args): | |||
| 171 | val = line.split(': ', 1)[1].rstrip() | 171 | val = line.split(': ', 1)[1].rstrip() |
| 172 | return val | 172 | return val |
| 173 | 173 | ||
| 174 | logger.debug("read-value('%s', '%s' '%s')" % (args.pkgdata_dir, args.valuename, packages)) | 174 | logger.debug("read-value('%s', '%s' '%s')" % (args.pkgdata_dir, args.valuenames, packages)) |
| 175 | for package in packages: | 175 | for package in packages: |
| 176 | pkg_split = package.split('_') | 176 | pkg_split = package.split('_') |
| 177 | pkg_name = pkg_split[0] | 177 | pkg_name = pkg_split[0] |
| @@ -180,20 +180,29 @@ def read_value(args): | |||
| 180 | logger.debug(revlink) | 180 | logger.debug(revlink) |
| 181 | if os.path.exists(revlink): | 181 | if os.path.exists(revlink): |
| 182 | mappedpkg = os.path.basename(os.readlink(revlink)) | 182 | mappedpkg = os.path.basename(os.readlink(revlink)) |
| 183 | qvar = args.valuename | 183 | qvars = args.valuenames |
| 184 | value = readvar(revlink, qvar, mappedpkg) | 184 | val_names = qvars.split(',') |
| 185 | if qvar == "PKGSIZE": | 185 | values = [] |
| 186 | # PKGSIZE is now in bytes, but we we want it in KB | 186 | for qvar in val_names: |
| 187 | pkgsize = (int(value) + 1024 // 2) // 1024 | 187 | if qvar == "PACKAGE": |
| 188 | value = "%d" % pkgsize | 188 | value = mappedpkg |
| 189 | if args.unescape: | 189 | else: |
| 190 | import codecs | 190 | value = readvar(revlink, qvar, mappedpkg) |
| 191 | # escape_decode() unescapes backslash encodings in byte streams | 191 | if qvar == "PKGSIZE": |
| 192 | value = codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8") | 192 | # PKGSIZE is now in bytes, but we we want it in KB |
| 193 | pkgsize = (int(value) + 1024 // 2) // 1024 | ||
| 194 | value = "%d" % pkgsize | ||
| 195 | if args.unescape: | ||
| 196 | import codecs | ||
| 197 | # escape_decode() unescapes backslash encodings in byte streams | ||
| 198 | value = codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8") | ||
| 199 | values.append(value) | ||
| 200 | |||
| 201 | values_str = ' '.join(values) | ||
| 193 | if args.prefix_name: | 202 | if args.prefix_name: |
| 194 | print('%s %s' % (pkg_name, value)) | 203 | print('%s %s' % (pkg_name, values_str)) |
| 195 | else: | 204 | else: |
| 196 | print(value) | 205 | print(values_str) |
| 197 | else: | 206 | else: |
| 198 | logger.debug("revlink %s does not exist", revlink) | 207 | logger.debug("revlink %s does not exist", revlink) |
| 199 | 208 | ||
| @@ -570,7 +579,7 @@ def main(): | |||
| 570 | parser_read_value = subparsers.add_parser('read-value', | 579 | parser_read_value = subparsers.add_parser('read-value', |
| 571 | help='Read any pkgdata value for one or more packages', | 580 | help='Read any pkgdata value for one or more packages', |
| 572 | description='Reads the named value from the pkgdata files for the specified packages') | 581 | description='Reads the named value from the pkgdata files for the specified packages') |
| 573 | parser_read_value.add_argument('valuename', help='Name of the value to look up') | 582 | parser_read_value.add_argument('valuenames', help='Name of the value/s to look up (separated by commas, no spaces)') |
| 574 | parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up') | 583 | parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up') |
| 575 | parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') | 584 | parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') |
| 576 | parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true') | 585 | parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true') |
