From c32d04d8280a50cb9ef5b4cc3ba901a19a72ce0d Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Tue, 3 Dec 2024 15:27:48 +0100 Subject: [PATCH] build(core): use deterministic git rev-parse The output may differ in shallow vs. full repo. [no changelog] --- core/embed/projects/firmware/mpconfigport.h | 4 ++++ core/embed/projects/unix/mpconfigport.h | 4 ++++ core/site_scons/tools.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/embed/projects/firmware/mpconfigport.h b/core/embed/projects/firmware/mpconfigport.h index 0df34659e5..cac32fff9b 100644 --- a/core/embed/projects/firmware/mpconfigport.h +++ b/core/embed/projects/firmware/mpconfigport.h @@ -177,6 +177,10 @@ #define MP_STATE_PORT MP_STATE_VM +// by default contains nearest git tag, which may not be present in shallow +// repo, breaking reproducibility +#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython (trezor-core submodule)" + // ============= this ends common config section =================== diff --git a/core/embed/projects/unix/mpconfigport.h b/core/embed/projects/unix/mpconfigport.h index 2cc4b7d9e7..1bb74e8b79 100644 --- a/core/embed/projects/unix/mpconfigport.h +++ b/core/embed/projects/unix/mpconfigport.h @@ -217,6 +217,10 @@ extern const struct _mp_print_t mp_stderr_print; #define MP_STATE_PORT MP_STATE_VM +// by default contains nearest git tag, which may not be present in shallow +// repo, breaking reproducibility +#define MICROPY_BANNER_NAME_AND_VERSION "MicroPython (trezor-core submodule)" + // ============= this ends common config section =================== // For size_t and ssize_t diff --git a/core/site_scons/tools.py b/core/site_scons/tools.py index 728b0bccfb..ad4e25c7d2 100644 --- a/core/site_scons/tools.py +++ b/core/site_scons/tools.py @@ -33,9 +33,9 @@ def get_git_revision_hash() -> str: def get_git_revision_short_hash() -> str: return ( - subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]) + subprocess.check_output(["git", "rev-parse", "--verify", "HEAD"]) .decode("ascii") - .strip() + .strip()[:7] )