All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s)
@ 2016-06-05 21:44 Alexander D. Kanevskiy
  2016-06-07 21:06 ` Paul Eggleton
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander D. Kanevskiy @ 2016-06-05 21:44 UTC (permalink / raw)
  To: openembedded-core

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.

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@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()
+        )
+    print('\n'.join(items))
+
 def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged):
     recipedatafile = os.path.join(pkgdata_dir, recipe)
     if not os.path.exists(recipedatafile):
@@ -469,6 +521,13 @@ def main():
     parser_lookup_recipe.add_argument('pkg', nargs='+', help='Runtime package name to look up')
     parser_lookup_recipe.set_defaults(func=lookup_recipe)
 
+    parser_package_info = subparsers.add_parser('package-info',
+                                          help='Shows version, recipe and size information for one or more packages',
+                                          description='Looks up the specified runtime package(s) and display information')
+    parser_package_info.add_argument('pkg', nargs='*', help='Runtime package name to look up')
+    parser_package_info.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)')
+    parser_package_info.set_defaults(func=package_info)
+
     parser_find_path = subparsers.add_parser('find-path',
                                           help='Find package providing a target path',
                                           description='Finds the recipe-space package providing the specified target path')
-- 
2.8.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s)
  2016-06-05 21:44 [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s) Alexander D. Kanevskiy
@ 2016-06-07 21:06 ` Paul Eggleton
  2016-06-08  2:24   ` Christopher Larson
  2016-06-08  9:47   ` Alexander Kanevskiy
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Eggleton @ 2016-06-07 21:06 UTC (permalink / raw)
  To: Alexander D. Kanevskiy; +Cc: openembedded-core

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@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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s)
  2016-06-07 21:06 ` Paul Eggleton
@ 2016-06-08  2:24   ` Christopher Larson
  2016-06-08  9:47   ` Alexander Kanevskiy
  1 sibling, 0 replies; 4+ messages in thread
From: Christopher Larson @ 2016-06-08  2:24 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

On Tue, Jun 7, 2016 at 2:06 PM, Paul Eggleton <paul.eggleton@linux.intel.com
> wrote:

> > +    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.


I'd agree, that's not particularly readable, both due to the long single
line and overuse of the inline if.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 2026 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s)
  2016-06-07 21:06 ` Paul Eggleton
  2016-06-08  2:24   ` Christopher Larson
@ 2016-06-08  9:47   ` Alexander Kanevskiy
  1 sibling, 0 replies; 4+ messages in thread
From: Alexander Kanevskiy @ 2016-06-08  9:47 UTC (permalink / raw)
  To: Paul Eggleton; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]

On Wed, Jun 8, 2016 at 12:06 AM, Paul Eggleton <
paul.eggleton@linux.intel.com> wrote:

> 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.
>

Assumption that it would be used in extra buildhistory class, so pkgdata
still should be valid.
But good point that it can be executed manually.


> > +    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.
>

ok. I'll send new version of patch a bit later today.

-- 
br, Alexander Kanevskiy

[-- Attachment #2: Type: text/html, Size: 2950 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-08  9:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-05 21:44 [PATCH] oe-pkgdata-util: new option to provide full info for binary package(s) Alexander D. Kanevskiy
2016-06-07 21:06 ` Paul Eggleton
2016-06-08  2:24   ` Christopher Larson
2016-06-08  9:47   ` Alexander Kanevskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.