[Buildroot] [PATCH 1/1] support/scripts/pkg-stats: add -N/--needs-update option
Kadambini Nema
kadambini.nema at gmail.com
Thu May 15 08:36:40 UTC 2025
This commit adds the -N/--needs-update option, disabled by default,
to list only packages with newer upstream versions. All other packages
will be excluded from the HTML or JSON output.
Signed-off-by: Kadambini Nema <kadambini.nema at gmail.com>
---
support/scripts/pkg-stats | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 46b12cd992..c22a8e724f 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1280,12 +1280,22 @@ def parse_args():
default=[])
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true',
help='Increase verbosity')
+ parser.add_argument('-N', '--needs-update', dest='needs_update', action='store_true',
+ help='Only include packages with newer versions available')
args = parser.parse_args()
if not args.html and not args.json:
parser.error('at least one of --html or --json (or both) is required')
return args
+def is_newer_version_available(pkg):
+ return not (
+ pkg.latest_version['status'] in (RM_API_STATUS_ERROR, RM_API_STATUS_NOT_FOUND) or
+ pkg.latest_version['version'] is None or
+ pkg.latest_version['version'] == pkg.current_version
+ )
+
+
def __main__():
global cvecheck
@@ -1341,6 +1351,8 @@ def __main__():
if "cve" not in args.disable and args.nvd_path:
print("Checking packages CVEs")
check_package_cves(args.nvd_path, packages)
+ if args.needs_update:
+ packages = [pkg for pkg in packages if is_newer_version_available(pkg)]
print("Calculate stats")
stats = calculate_stats(packages)
if args.html:
--
2.25.1
More information about the buildroot
mailing list