[Buildroot] [PATCH] support/scripts/pkg-stats: use BR2_VERSION_FULL instead of raw commit hash

Peter Seiderer ps.report at gmx.net
Thu Dec 18 20:06:28 UTC 2025


- use BR2_VERSION_FULL instead of raw commit hash

Fixes:

  $ wget https://buildroot.org/downloads/buildroot-2025.11.tar.xz
  $ tar -xvJf buildroot-2025.11.tar.xz
  $ make raspberrypi4_64_defconfig
  $ make pkg-stats
  fatal: not a git repository (or any parent up to mount point /)
  Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
  Traceback (most recent call last):
    File ".../buildroot-2025.11/support/scripts/pkg-stats", line 1387, in <module>
      __main__()
      ~~~~~~~~^^
    File ".../buildroot-2025.11/support/scripts/pkg-stats", line 1339, in __main__
      commit = subprocess.check_output(['git', '-C', brpath,
               ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
                                        'rev-parse',
                                        ^^^^^^^^^^^^
                                        'HEAD']).splitlines()[0].decode()
                                        ^^^^^^^^
    File "/usr/lib64/python3.13/subprocess.py", line 472, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
             ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 **kwargs).stdout
                 ^^^^^^^^^
    File "/usr/lib64/python3.13/subprocess.py", line 577, in run
      raise CalledProcessError(retcode, process.args,
                               output=stdout, stderr=stderr)
  subprocess.CalledProcessError: Command '['git', '-C', '.../buildroot-2025.11', 'rev-parse', 'HEAD']' returned non-zero exit status 128.
  make: *** [Makefile:935: pkg-stats] Error 1

Signed-off-by: Peter Seiderer <ps.report at gmx.net>
---
 support/scripts/pkg-stats | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 7d9170e30f..27a44cde57 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1233,21 +1233,21 @@ def dump_html_stats(f, stats):
     f.write('</div>\n')
 
 
-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))
+def dump_html_gen_info(f, date, br_version_full):
+    # Updated on Mon Feb 19 08:12:08 CET 2018, 2025.11-322-g1bb2eecc3e
+    f.write("<p><i>Updated on %s, %s</i></p>\n" % (str(date), br_version_full))
 
 
-def dump_html(packages, stats, date, commit, output):
+def dump_html(packages, stats, date, br_version_full, output):
     with open(output, 'w') as f:
         f.write(html_header)
         dump_html_all_pkgs(f, packages)
         dump_html_stats(f, stats)
-        dump_html_gen_info(f, date, commit)
+        dump_html_gen_info(f, date, br_version_full)
         f.write(html_footer)
 
 
-def dump_json(packages, defconfigs, stats, date, commit, output):
+def dump_json(packages, defconfigs, stats, date, br_version_full, output):
     # Format packages as a dictionary instead of a list
     # Exclude local field that does not contains real date
     excluded_fields = ['url_worker', 'name', 'tree_path']
@@ -1271,12 +1271,12 @@ def dump_json(packages, defconfigs, stats, date, commit, output):
         if not k.startswith('infra-')
     }
     statistics['infra'] = {k[6:]: v for k, v in stats.items() if k.startswith('infra-')}
-    # The actual structure to dump, add commit and date to it
+    # The actual structure to dump, add br_version_full and date to it
     final = {'packages': pkgs,
              'stats': statistics,
              'defconfigs': defconfigs,
              'package_status_checks': Package.status_checks,
-             'commit': commit,
+             'br_version_full': br_version_full,
              'date': str(date)}
 
     with open(output, 'w') as f:
@@ -1336,9 +1336,7 @@ 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()
+    br_version_full = os.getenv('BR2_VERSION_FULL', 'unknown')
     print("Build package list ...")
     all_trees = get_trees()
     packages = get_pkglist(all_trees, args.npackages, package_list)
@@ -1378,10 +1376,10 @@ def __main__():
     stats = calculate_stats(packages)
     if args.html:
         print("Write HTML")
-        dump_html(packages, stats, date, commit, args.html)
+        dump_html(packages, stats, date, br_version_full, args.html)
     if args.json:
         print("Write JSON")
-        dump_json(packages, defconfigs, stats, date, commit, args.json)
+        dump_json(packages, defconfigs, stats, date, br_version_full, args.json)
 
 
 __main__()
-- 
2.52.0



More information about the buildroot mailing list