Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Seiderer via buildroot <buildroot@buildroot.org>
To: raslene.ziadi@gmail.com
Cc: buildroot@buildroot.org, Sen Hastings <sen@hastings.org>,
	Raslen Ziadi <raslen.ziadi@enim.u-monastir.tn>
Subject: Re: [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: handle missing git repository
Date: Wed, 21 Oct 2026 16:59:33 +0200	[thread overview]
Message-ID: <20261021165933.36c5c64f@pc-1> (raw)
In-Reply-To: <20261021134656.30706-1-raslene.ziadi@gmail.com>

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

      reply	other threads:[~2026-10-21 14:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20261021165933.36c5c64f@pc-1 \
    --to=buildroot@buildroot.org \
    --cc=ps.report@gmx.net \
    --cc=raslen.ziadi@enim.u-monastir.tn \
    --cc=raslene.ziadi@gmail.com \
    --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