From 786f8b45672ebdd432f6af5b7595d3d16013433b Mon Sep 17 00:00:00 2001 From: Sen Hastings Date: Wed, 27 Jul 2022 21:14:43 -0500 Subject: [PATCH] support/scripts/pkg-stats: fix duplicate package class names across rows Like all good problems, disparate pieces work together to create a "synergistically" hairy mess. The sortGrid() overhaul highlighted a flaw in pkg-stats allowing for duplicate package class names across rows. As an example, boot/barebox/barebox.mk and boot/barebox/barebox/barebox.mk both get the classname ._barebox and so sortGrid() sticks them on the same line giving a table with a vestigal row sticking out of the right side like some kind of appendage. Also I neglected to add a "_" to the current version column's cells pkgname class so instead of "._pkgname" we had ".pkgname" and so the cells were not collected properly as part of the row. These issues explain the formatting weirdness. package classnames are now ".path_to_package_makefile" without suffix (.mk) (so ._boot_barebox_barebox and ._boot_barebox_barebox_barebox instead of ._barebox) in order to guarantee uniqueness. and what was *accidentally* class="centered current_version data .barebox" is now class="centered current_version data ._boot_barebox_barebox" just like *all* the other cells in the row. :p Signed-off-by: Sen Hastings Signed-off-by: Thomas Petazzoni --- support/scripts/pkg-stats | 53 ++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index 9c37506cd4..d3ec65edbb 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -885,12 +885,13 @@ def boolean_str(b): def dump_html_pkg(f, pkg): - f.write(f'
{pkg.path}
\n') + pkg_css_class = pkg.path.replace("/", "_")[:-3] + f.write(f'
{pkg.path}
\n') # Patch count - data_field_id = f'patch_count__{pkg.name}' + data_field_id = f'patch_count__{pkg_css_class}' div_class = ["centered patch_count data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.patch_count == 0: div_class.append("nopatches") elif pkg.patch_count < 5: @@ -901,10 +902,10 @@ def dump_html_pkg(f, pkg): \">{str(pkg.patch_count)}\n') # Infrastructure - data_field_id = f'infrastructure__{pkg.name}' + data_field_id = f'infrastructure__{pkg_css_class}' infra = infra_str(pkg.infras) div_class = ["centered infrastructure data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if infra == "Unknown": div_class.append("wrong") else: @@ -913,9 +914,9 @@ def dump_html_pkg(f, pkg): \">{infra_str(pkg.infras)}\n') # License - data_field_id = f'license__{pkg.name}' + data_field_id = f'license__{pkg_css_class}' div_class = ["centered license data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.is_status_ok('license'): div_class.append("correct") else: @@ -924,9 +925,9 @@ def dump_html_pkg(f, pkg): \">{boolean_str(pkg.is_status_ok("license"))}\n') # License files - data_field_id = f'license_files__{pkg.name}' + data_field_id = f'license_files__{pkg_css_class}' div_class = ["centered license_files data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.is_status_ok('license-files'): div_class.append("correct") else: @@ -935,9 +936,9 @@ def dump_html_pkg(f, pkg): \">{boolean_str(pkg.is_status_ok("license-files"))}\n') # Hash - data_field_id = f'hash_file__{pkg.name}' + data_field_id = f'hash_file__{pkg_css_class}' div_class = ["centered hash_file data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.is_status_ok('hash'): div_class.append("correct") else: @@ -946,17 +947,17 @@ def dump_html_pkg(f, pkg): \">{boolean_str(pkg.is_status_ok("hash"))}\n') # Current version - data_field_id = f'current_version__{pkg.name}' + data_field_id = f'current_version__{pkg_css_class}' if len(pkg.current_version) > 20: current_version = pkg.current_version[:20] + "..." else: current_version = pkg.current_version f.write(f'
{current_version}
\n') + class=\"centered current_version data _{pkg_css_class}\">{current_version}\n') # Latest version - data_field_id = f'latest_version__{pkg.name}' - div_class.append(f'_{pkg.name}') + data_field_id = f'latest_version__{pkg_css_class}' + div_class.append(f'_{pkg_css_class}') div_class.append("latest_version data") if pkg.latest_version['status'] == RM_API_STATUS_ERROR: div_class.append("version-error") @@ -988,9 +989,9 @@ def dump_html_pkg(f, pkg): f.write(f'
{latest_version_text}
\n') # Warnings - data_field_id = f'warnings__{pkg.name}' + data_field_id = f'warnings__{pkg_css_class}' div_class = ["centered warnings data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.warnings == 0: div_class.append("correct") else: @@ -998,9 +999,9 @@ def dump_html_pkg(f, pkg): f.write(f'
{pkg.warnings}
\n') # URL status - data_field_id = f'upstream_url__{pkg.name}' + data_field_id = f'upstream_url__{pkg_css_class}' div_class = ["centered upstream_url data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') url_str = pkg.status['url'][1] if pkg.status['url'][0] in ("error", "warning"): div_class.append("missing_url") @@ -1013,9 +1014,9 @@ def dump_html_pkg(f, pkg): f.write(f'
{url_str}
\n') # CVEs - data_field_id = f'cves__{pkg.name}' + data_field_id = f'cves__{pkg_css_class}' div_class = ["centered cves data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.is_status_ok("cve"): div_class.append("cve-ok") elif pkg.is_status_error("cve"): @@ -1037,9 +1038,9 @@ def dump_html_pkg(f, pkg): f.write(" \n") # CVEs Ignored - data_field_id = f'ignored_cves__{pkg.name}' + data_field_id = f'ignored_cves__{pkg_css_class}' div_class = ["centered data ignored_cves"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.ignored_cves: div_class.append("cve_ignored") f.write(f'
\n') @@ -1048,9 +1049,9 @@ def dump_html_pkg(f, pkg): f.write("
\n") # CPE ID - data_field_id = f'cpe_id__{pkg.name}' + data_field_id = f'cpe_id__{pkg_css_class}' div_class = ["left cpe_id data"] - div_class.append(f'_{pkg.name}') + div_class.append(f'_{pkg_css_class}') if pkg.is_status_ok("cpe"): div_class.append("cpe-ok") elif pkg.is_status_error("cpe"):