* [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository
@ 2026-10-21 13:46 raslene.ziadi
2026-10-21 14:59 ` Peter Seiderer via buildroot
0 siblings, 1 reply; 2+ messages in thread
From: raslene.ziadi @ 2026-10-21 13:46 UTC (permalink / raw)
To: buildroot; +Cc: Sen Hastings, Raslen Ziadi
From: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
pkg-stats can be run outside a Git repository. In this case,
retrieving the current commit fails and aborts the script.
Handle this failure and omit the commit information from the HTML
and JSON reports when the Git commit is unavailable.
Signed-off-by: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
---
support/scripts/pkg-stats | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index eb6d1836c3..52a4293948 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1260,7 +1260,10 @@ def dump_html_stats(f, stats):
def dump_html_gen_info(f, date, commit):
# Updated on Mon Feb 19 08:12:08 CET 2018, Git commit aa77030b8f5e41f1c53eb1c1ad664b8c814ba032
- f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
+ if commit:
+ f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
+ else:
+ f.write("<p><i>Updated on %s</i></p>\n" % str(date))
def dump_html(packages, stats, date, commit, output):
@@ -1300,9 +1303,10 @@ def dump_json(packages, defconfigs, stats, date, commit, output):
final = {'packages': pkgs,
'stats': statistics,
'defconfigs': defconfigs,
- 'package_status_checks': Package.status_checks,
- 'commit': commit,
- 'date': str(date)}
+ 'package_status_checks': Package.status_checks}
+ if commit:
+ final['commit'] = commit
+ final['date'] = str(date)
with open(output, 'w') as f:
json.dump(final, f, indent=2, separators=(',', ': '))
@@ -1371,9 +1375,13 @@ def main():
else:
package_list = None
date = datetime.datetime.now(datetime.timezone.utc)
- commit = subprocess.check_output(['git', '-C', brpath,
- 'rev-parse',
- 'HEAD']).splitlines()[0].decode()
+ try:
+ commit = subprocess.check_output(
+ ['git', '-C', brpath, 'rev-parse', 'HEAD'],
+ stderr=subprocess.DEVNULL
+ ).splitlines()[0].decode()
+ except subprocess.CalledProcessError:
+ commit = None
print("Build package list ...")
all_trees = get_trees()
packages = get_pkglist(all_trees, args.npackages, package_list)
--
2.43.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository
2026-10-21 13:46 [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository raslene.ziadi
@ 2026-10-21 14:59 ` Peter Seiderer via buildroot
0 siblings, 0 replies; 2+ messages in thread
From: Peter Seiderer via buildroot @ 2026-10-21 14:59 UTC (permalink / raw)
To: raslene.ziadi; +Cc: buildroot, Sen Hastings, Raslen Ziadi
Hello Raslen Ziadi,
On Wed, 21 Oct 2026 14:46:55 +0100, raslene.ziadi@gmail.com wrote:
> From: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
>
> pkg-stats can be run outside a Git repository. In this case,
> retrieving the current commit fails and aborts the script.
>
> Handle this failure and omit the commit information from the HTML
> and JSON reports when the Git commit is unavailable.
Stumbled some time ago over the same(?) failure and sent a slightly
different fix as patch (see [1]):
[PATCH] support/scripts/pkg-stats: use BR2_VERSION_FULL instead of raw commit hash
Regards,
Peter
[1] https://lore.kernel.org/buildroot/20251218200628.2615661-1-ps.report@gmx.net/T/#u
>
> Signed-off-by: Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
> ---
> support/scripts/pkg-stats | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
> index eb6d1836c3..52a4293948 100755
> --- a/support/scripts/pkg-stats
> +++ b/support/scripts/pkg-stats
> @@ -1260,7 +1260,10 @@ def dump_html_stats(f, stats):
>
> def dump_html_gen_info(f, date, commit):
> # Updated on Mon Feb 19 08:12:08 CET 2018, Git commit aa77030b8f5e41f1c53eb1c1ad664b8c814ba032
> - f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
> + if commit:
> + f.write("<p><i>Updated on %s, git commit %s</i></p>\n" % (str(date), commit))
> + else:
> + f.write("<p><i>Updated on %s</i></p>\n" % str(date))
>
>
> def dump_html(packages, stats, date, commit, output):
> @@ -1300,9 +1303,10 @@ def dump_json(packages, defconfigs, stats, date, commit, output):
> final = {'packages': pkgs,
> 'stats': statistics,
> 'defconfigs': defconfigs,
> - 'package_status_checks': Package.status_checks,
> - 'commit': commit,
> - 'date': str(date)}
> + 'package_status_checks': Package.status_checks}
> + if commit:
> + final['commit'] = commit
> + final['date'] = str(date)
>
> with open(output, 'w') as f:
> json.dump(final, f, indent=2, separators=(',', ': '))
> @@ -1371,9 +1375,13 @@ def main():
> else:
> package_list = None
> date = datetime.datetime.now(datetime.timezone.utc)
> - commit = subprocess.check_output(['git', '-C', brpath,
> - 'rev-parse',
> - 'HEAD']).splitlines()[0].decode()
> + try:
> + commit = subprocess.check_output(
> + ['git', '-C', brpath, 'rev-parse', 'HEAD'],
> + stderr=subprocess.DEVNULL
> + ).splitlines()[0].decode()
> + except subprocess.CalledProcessError:
> + commit = None
> print("Build package list ...")
> all_trees = get_trees()
> packages = get_pkglist(all_trees, args.npackages, package_list)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-21 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 13:46 [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository raslene.ziadi
2026-10-21 14:59 ` Peter Seiderer via buildroot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox