From: Franciszek Stachura <fbstachura@gmail.com>
To: buildroot@buildroot.org
Cc: Sen Hastings <sen@hastings.org>,
Franciszek Stachura <fbstachura@gmail.com>
Subject: [Buildroot] [PATCH] support/scripts/pkg-stats: sort latest version by state
Date: Sun, 20 Sep 2026 12:55:54 +0200 [thread overview]
Message-ID: <20260920105553.859978-2-fbstachura@gmail.com> (raw)
pkg-stats columns are sorted either alphabetically or numerically. This
does not make much sense for the "Latest version" column.
This commit orders the column by whether the package is up-to-date or
not.
Signed-off-by: Franciszek Stachura <fbstachura@gmail.com>
---
support/scripts/pkg-stats | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 2b2194b9a5..842e78f8c0 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -44,6 +44,11 @@ RM_API_STATUS_NOT_FOUND = 4
HTTP_HEADERS = {'User-Agent': 'buildroot.org pkg-stats'}
+LATEST_SORT_GOOD = 3
+LATEST_SORT_ERROR = 2
+LATEST_SORT_UNKNOWN = 1
+LATEST_SORT_NEEDS_UPDATE = 0
+
class Defconfig:
def __init__(self, name, path):
@@ -766,7 +771,15 @@ addedCSSRules = [
addedCSSRules.forEach(rule => styleSheet.insertRule(rule));
-function sortGrid(sortLabel){
+function byInnerText(el) {
+ return el.innerText;
+}
+
+function byIsLatest(el) {
+ return el.getAttribute('data-latest-sort');
+}
+
+function sortGrid(sortLabel, sortBy=byInnerText){
let i = 0;
let pkgSortArray = [], sortedPkgArray = [], pkgStringSortArray = [], pkgNumSortArray = [];
const git_hash_regex = /[a-f,0-9]/gi;
@@ -786,10 +799,10 @@ function sortGrid(sortLabel){
columnValues.forEach((listing) => {
let sortArr = [];
sortArr[0] = listing.id.replace(sortLabel+"_", "");
- if (!listing.innerText){
+ if (!sortBy(listing)) {
sortArr[1] = -1;
} else {
- sortArr[1] = listing.innerText;
+ sortArr[1] = sortBy(listing);
};
pkgSortArray.push(sortArr);
});
@@ -1011,14 +1024,20 @@ def dump_html_pkg(f, pkg):
div_class = ["centered"]
div_class.append(f'_{pkg_css_class}')
div_class.append("latest_version data")
+ data_latest_sort = None
if pkg.latest_version['status'] == RM_API_STATUS_ERROR:
div_class.append("version-error")
+ data_latest_sort = LATEST_SORT_ERROR
if pkg.latest_version['version'] is None:
div_class.append("version-unknown")
+ if data_latest_sort != LATEST_SORT_ERROR:
+ data_latest_sort = LATEST_SORT_UNKNOWN
elif pkg.latest_version['version'] != pkg.current_version:
div_class.append("version-needs-update")
+ data_latest_sort = LATEST_SORT_NEEDS_UPDATE
else:
div_class.append("version-good")
+ data_latest_sort = LATEST_SORT_GOOD
if pkg.latest_version['status'] == RM_API_STATUS_ERROR:
latest_version_text = "<b>Error</b>"
@@ -1038,7 +1057,7 @@ def dump_html_pkg(f, pkg):
else:
latest_version_text += "found by guess"
- f.write(f' <div id="{data_field_id}" class="{" ".join(div_class)}">{latest_version_text}</div>\n')
+ f.write(f' <div id="{data_field_id}" data-latest-sort="{data_latest_sort}" class="{" ".join(div_class)}">{latest_version_text}</div>\n')
# Warnings
data_field_id = f'warnings__{pkg_css_class}'
@@ -1170,7 +1189,7 @@ def dump_html_all_pkgs(f, packages):
class="centered hash_file data label"><span>Hash file</span><span></span></div>
<div style="grid-column: 8;" onclick="sortGrid(this.id)" id="current_version"
class="centered current_version data label"><span>Current version</span><span></span></div>
-<div style="grid-column: 9;" onclick="sortGrid(this.id)" id="latest_version"
+<div style="grid-column: 9;" onclick="sortGrid(this.id, byIsLatest)" id="latest_version"
class="centered latest_version data label"><span>Latest version</span><span></span></div>
<div style="grid-column: 10;" onclick="sortGrid(this.id)" id="warnings"
class="centered warnings data label"><span>Warnings</span><span></span></div>
--
2.55.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next reply other threads:[~2026-09-20 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 10:55 Franciszek Stachura [this message]
2026-09-20 13:17 ` [Buildroot] [PATCH] support/scripts/pkg-stats: sort latest version by state Thomas Petazzoni via buildroot
2026-09-25 14:47 ` Raphaël Mélotte via buildroot
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=20260920105553.859978-2-fbstachura@gmail.com \
--to=fbstachura@gmail.com \
--cc=buildroot@buildroot.org \
--cc=sen@hastings.org \
/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