Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH next 2/5] support/scripts/pkg-stats-new: add -n and -p options
Date: Thu, 15 Feb 2018 23:03:42 +0100	[thread overview]
Message-ID: <20180215220345.8532-3-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20180215220345.8532-1-thomas.petazzoni@bootlin.com>

This commit adds the following options to the pkg-stats-new script:

 -n, to specify a number of packages to parse instead of all packages

 -p, to specify a list of packages (comma-separated) to parse instead
     of all packages

These options are basically only useful when debugging/developping
this script, but they are very useful, because the script is rather
slow to run completely with all 2000+ packages, especially once
upstream versions will be fetched from release-monitoring.org.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/scripts/pkg-stats-new | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/support/scripts/pkg-stats-new b/support/scripts/pkg-stats-new
index a5e056a948..d018e1fed4 100755
--- a/support/scripts/pkg-stats-new
+++ b/support/scripts/pkg-stats-new
@@ -31,7 +31,7 @@ class Package:
 # npackages: limit to N packages
 # package_list: limit to those packages in this list
 #
-def get_pkglist():
+def get_pkglist(npackages, package_list):
     WALK_USEFUL_SUBDIRS = ["boot", "linux", "package", "toolchain"]
     WALK_EXCLUDES = [ "boot/common.mk",
                       "linux/linux-ext-.*.mk",
@@ -53,6 +53,7 @@ def get_pkglist():
                       "toolchain/helpers.mk",
                       "toolchain/toolchain-wrapper.mk" ]
     packages = dict()
+    count = 0
     for root, dirs, files in os.walk("."):
         rootdir = root.split("/")
         if len(rootdir) < 2:
@@ -64,6 +65,8 @@ def get_pkglist():
                 continue
             # Strip ending ".mk"
             pkgname = f[:-3]
+            if package_list and pkgname not in package_list:
+                continue
             pkgpath = os.path.join(root, f)
             skip = False
             for exclude in WALK_EXCLUDES:
@@ -76,6 +79,9 @@ def get_pkglist():
             p = Package(pkgname)
             p.path = pkgpath
             packages[pkgname] = p
+            count += 1
+            if npackages and count == npackages:
+                return packages
     return packages
 
 INFRA_RE = re.compile("\$\(eval \$\(([a-z-]*)-package\)\)")
@@ -400,12 +406,23 @@ def parse_args():
     parser = argparse.ArgumentParser()
     parser.add_argument('-o', dest='output', action='store', required=True,
                         help='HTML output file')
+    parser.add_argument('-n', dest='npackages', type=int, action='store',
+                        help='Number of packages')
+    parser.add_argument('-p', dest='packages', action='store',
+                        help='List of packages')
     return parser.parse_args()
 
 def __main__():
     args = parse_args()
+    if args.npackages and args.packages:
+        print "ERROR: -n and -p are mutually exclusive"
+        sys.exit(1)
+    if args.packages:
+        package_list = args.packages.split(",")
+    else:
+        package_list = None
     print "Build package list ..."
-    packages = get_pkglist()
+    packages = get_pkglist(args.npackages, package_list)
     print "Get package infra ..."
     add_infra_info(packages)
     print "Get make info ..."
-- 
2.14.3

  parent reply	other threads:[~2018-02-15 22:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 22:03 [Buildroot] [PATCH next 0/5] New pkg-stats, with upstream version comparison Thomas Petazzoni
2018-02-15 22:03 ` [Buildroot] [PATCH next 1/5] support/scripts/pkg-stats-new: rewrite in Python Thomas Petazzoni
2018-02-19  2:48   ` Ricardo Martincoski
2018-02-19 20:57     ` Thomas Petazzoni
2018-02-22  1:55       ` Ricardo Martincoski
2018-02-15 22:03 ` Thomas Petazzoni [this message]
2018-02-15 22:03 ` [Buildroot] [PATCH next 3/5] support/scripts/pkg-stats-new: add current version information Thomas Petazzoni
2018-02-15 22:03 ` [Buildroot] [PATCH next 4/5] support/scripts/pkg-stats-new: add latest upstream " Thomas Petazzoni
2018-02-15 22:03 ` [Buildroot] [PATCH next 5/5] support/scripts/pkg-stats: replace with new Python version Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180215220345.8532-3-thomas.petazzoni@bootlin.com \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox