[OE-core] [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s)

Paul Eggleton paul.eggleton at linux.intel.com
Tue Jun 7 21:06:57 UTC 2016


Hi Sasha,

Functionality wise this looks good.

On Mon, 06 Jun 2016 00:44:29 Alexander D. Kanevskiy wrote:
> New option can be used for displaying full information about binary
> package(s), including name, full version, recipe name, recipe full version
> and package size.
> 
> This information can be useful to produce detailed image manifest
> for further analysis.

Possibly worth noting that since this looks up current information rather than 
what's in the image, this is only going to be accurate for that purpose if no 
packages have been rebuilt (strictly speaking no do_packagedata tasks have 
executed) since the manifest was generated.

> List of packages can be specified as command line or can be read
> from file (e.g. image manifest)
> 
> Output format:
> {PKG} [PKGE:]{PKGV}[-{PKGR}] {PN} [PE:]{PV}[-{PR}] {PKGSIZE}
> 
> Signed-off-by: Alexander D. Kanevskiy <kad at kad.name>
> ---
>  scripts/oe-pkgdata-util | 59
> +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59
> insertions(+)
> 
> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
> index b16ecc9..efc54c1 100755
> --- a/scripts/oe-pkgdata-util
> +++ b/scripts/oe-pkgdata-util
> @@ -274,6 +274,58 @@ def lookup_recipe(args):
>          items.extend(mappings.get(pkg, []))
>      print('\n'.join(items))
> 
> +def package_info(args):
> +    # Handle both multiple arguments and multiple values within an arg (old
> syntax) +    packages = []
> +    if args.file:
> +        with open(args.file, 'r') as f:
> +            for line in f:
> +                splitline = line.split()
> +                if splitline:
> +                    packages.append(splitline[0])
> +    else:
> +        for pkgitem in args.pkg:
> +            packages.extend(pkgitem.split())
> +        if not packages:
> +            logger.error("No packages specified")
> +            sys.exit(1)
> +
> +    mappings = defaultdict(lambda: defaultdict(str))
> +    for pkg in packages:
> +        pkgfile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
> +        if os.path.exists(pkgfile):
> +            with open(pkgfile, 'r') as f:
> +                for line in f:
> +                    fields = line.rstrip().split(': ')
> +                    if fields[0].endswith("_" + pkg):
> +                        k = fields[0][:len(fields[0]) - len(pkg) - 1]
> +                    else:
> +                        k = fields[0]
> +                    v = fields[1] if len(fields) == 2 else ""
> +                    mappings[pkg][k] = v
> +
> +    if len(mappings) < len(packages):
> +        missing = list(set(packages) - set(mappings.keys()))
> +        logger.error("The following packages could not be found: %s" %
> +                     ', '.join(missing))
> +        sys.exit(1)
> +
> +    items = []
> +    for pkg in packages:
> +        items.append(("%s %s%s%s %s %s%s%s %s" % (
> +            pkg,
> +            mappings[pkg]['PKGE'] + ":" if mappings[pkg]['PKGE'] else "",
> +            mappings[pkg]['PKGV'],
> +            "-" + mappings[pkg]['PKGR'] if mappings[pkg]['PKGR'] else "",
> +            mappings[pkg]['PN'],
> +            mappings[pkg]['PE'] + ":" if mappings[pkg]['PE'] else "",
> +            mappings[pkg]['PV'],
> +            "-" + mappings[pkg]['PR'] if mappings[pkg]['PR'] else "",
> +            mappings[pkg]['PKGSIZE']
> +        )).strip()
> +        )

This seems like a bit of an ugly construction. If it were me writing it I 
would probably break it down using variables rather than trying to do it all 
on one line. That said it's not bad enough to block it, if nobody else feels 
strongly about it then you're in the clear.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the Openembedded-core mailing list