From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v3 3/5] support/scripts/pkg-stats-new: add current version information
Date: Fri, 23 Mar 2018 21:54:53 +0100 [thread overview]
Message-ID: <20180323205455.24789-4-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20180323205455.24789-1-thomas.petazzoni@bootlin.com>
This commit adds a new column in the HTML output containing the
current version of a package in Buildroot. As such, it isn't terribly
useful, but combined with the latest upstream version added in a
follow-up commit, it will become very useful.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
Changes since v2:
- Address Ricardo's concern about printvars variable sorting affecting
the version reported: we now parse all HOST_*_VERSION variables
first, and then all *_VERSION variables, ensuring that the target
version of a package wins.
- Limit length of version string to 20 characters, as suggested by
Ricardo.
- Move a lot of the logic as methods of the Package() class.
Changes since v1:
- Fix flake8 warnings
- Pass BR2_HAVE_DOT_CONFIG=y when calling make, in order to fake
having a .config. This allows "printvars" to dump all variables even
without a .config.
- Add missing newline in HTML code
---
support/scripts/pkg-stats-new | 46 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/support/scripts/pkg-stats-new b/support/scripts/pkg-stats-new
index 5dc70f1671..43f7e8d543 100755
--- a/support/scripts/pkg-stats-new
+++ b/support/scripts/pkg-stats-new
@@ -31,6 +31,7 @@ INFRA_RE = re.compile("\$\(eval \$\(([a-z-]*)-package\)\)")
class Package:
all_licenses = list()
all_license_files = list()
+ all_versions = dict()
def __init__(self, name, path):
self.name = name
@@ -41,6 +42,7 @@ class Package:
self.has_hash = False
self.patch_count = 0
self.warnings = 0
+ self.current_version = None
def pkgvar(self):
return self.name.upper().replace("-", "_")
@@ -88,6 +90,14 @@ class Package:
for subdir, _, _ in os.walk(pkgdir):
self.patch_count += len(fnmatch.filter(os.listdir(subdir), '*.patch'))
+ def set_current_version(self):
+ """
+ Fills in the .current_version field
+ """
+ var = self.pkgvar()
+ if var in self.all_versions:
+ self.current_version = self.all_versions[var]
+
def set_check_package_warnings(self):
"""
Fills in the .warnings field
@@ -217,6 +227,33 @@ def package_init_make_info():
Package.all_license_files.append(pkgvar)
+ # Version
+ o = subprocess.check_output(["make", "BR2_HAVE_DOT_CONFIG=y",
+ "-s", "printvars", "VARS=%_VERSION"])
+
+ # We process first the host package VERSION, and then the target
+ # package VERSION. This means that if a package exists in both
+ # target and host variants, with different version numbers
+ # (unlikely), we'll report the target version number.
+ version_list = o.splitlines()
+ version_list = [x for x in version_list if x.startswith("HOST_")] + \
+ [x for x in version_list if not x.startswith("HOST_")]
+ for l in version_list:
+ # Get variable name and value
+ pkgvar, value = l.split("=")
+
+ # If present, strip HOST_ from variable name
+ if pkgvar.startswith("HOST_"):
+ pkgvar = pkgvar[5:]
+
+ if pkgvar.endswith("_DL_VERSION"):
+ continue
+
+ # Strip _VERSION
+ pkgvar = pkgvar[:-8]
+
+ Package.all_versions[pkgvar] = value
+
def calculate_stats(packages):
stats = defaultdict(int)
@@ -369,6 +406,13 @@ def dump_html_pkg(f, pkg):
f.write(" <td class=\"%s\">%s</td>\n" %
(" ".join(td_class), boolean_str(pkg.has_hash)))
+ # Current version
+ if len(pkg.current_version) > 20:
+ current_version = pkg.current_version[:20] + "..."
+ else:
+ current_version = pkg.current_version
+ f.write(" <td class=\"centered\">%s</td>\n" % current_version)
+
# Warnings
td_class = ["centered"]
if pkg.warnings == 0:
@@ -391,6 +435,7 @@ def dump_html_all_pkgs(f, packages):
<td class=\"centered\">License</td>
<td class=\"centered\">License files</td>
<td class=\"centered\">Hash file</td>
+<td class=\"centered\">Current version</td>
<td class=\"centered\">Warnings</td>
</tr>
""")
@@ -471,6 +516,7 @@ def __main__():
pkg.set_hash_info()
pkg.set_patch_count()
pkg.set_check_package_warnings()
+ pkg.set_current_version()
print "Calculate stats"
stats = calculate_stats(packages)
print "Write HTML"
--
2.14.3
next prev parent reply other threads:[~2018-03-23 20:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-23 20:54 [Buildroot] [PATCH v3 0/5] New pkg-stats script, with version information Thomas Petazzoni
2018-03-23 20:54 ` [Buildroot] [PATCH v3 1/5] support/scripts/pkg-stats-new: rewrite in Python Thomas Petazzoni
2018-03-30 3:23 ` Ricardo Martincoski
2018-03-23 20:54 ` [Buildroot] [PATCH v3 2/5] support/scripts/pkg-stats-new: add -n and -p options Thomas Petazzoni
2018-03-23 20:54 ` Thomas Petazzoni [this message]
2018-03-30 3:25 ` [Buildroot] [PATCH v3 3/5] support/scripts/pkg-stats-new: add current version information Ricardo Martincoski
2018-03-23 20:54 ` [Buildroot] [PATCH v3 4/5] support/scripts/pkg-stats-new: add latest upstream " Thomas Petazzoni
2018-03-30 3:32 ` Ricardo Martincoski
2018-04-05 8:56 ` Peter Korsgaard
2018-03-23 20:54 ` [Buildroot] [PATCH v3 5/5] support/scripts/pkg-stats: replace with new Python version Thomas Petazzoni
2018-04-04 20:10 ` [Buildroot] [PATCH v3 0/5] New pkg-stats script, with version information 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=20180323205455.24789-4-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