poky/meta/classes-global
Enrico Jörns 2d2d17e136 kernel-yocto: make kernel commits reproducible
The git commit hashes for the kernel checkout are not reproducible under
certain conditions:

- If the git repository is initialized on an archive (rather than a
  git), the initial git commit not only has the current user name set,
  it also uses the current system time as committer and author date.
  This will affect the initial git hash and thus all subsequent ones.

- The patches applied by the kern-tools have a valid author and date.
  However, their committer again depends on the user building the BSP.

This is an issue, for example, if one compiles a kernel with
CONFIG_LOCALVERSION_AUTO enabled where the commit hash lands into the
kernel and thus the package version. This not only makes the package
version non-reproducible, but also leads to version mismatches between
kernel modules built against a fresh kernel checkout and the kernel
retrieved from the sstate cache.

The class uses 'check_git_config' from utils.bbclass, but this only sets
the git user and only if none existed before. Thus it doesn't really
help here.

Since in Git the committer information can be set only from the
environment variables GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, and
GIT_COMMITTER_DATE, we introduce a helper function to set those and
apply the author settings in the same way.
As values simply use PATCH_GIT_USER_NAME, PATCH_GIT_USER_EMAIL (from
patch.bbclass) and SOURCE_DATE_EPOCH.
For convenience, put the new helper 'reproducible_git_committer_author'
into utils.bbclass next to 'check_git_config' so others can use it, too.

Using this helper in kernel-yocto.bbclass makes the committer and author
date/name/email for the initial commit reproducible, as well as the
committer name/email for the patches applied with kern-tools.

For debugging purpose, allow disabling the reproducibility features by
setting KERNEL_DEBUG_TIMESTAMPS to "1".

Suggested-by: Felix Klöckner <F.Kloeckner@weinmann-emt.de>
(From OE-Core rev: aab4517b4649917abd519ea85a20fd9d51bf3d99)

Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2025-01-21 13:26:07 +00:00
..
base.bbclass base/features_check: Make PARSE_ALL_RECIPES and SOURCE_MIRROR_FETCH boolean 2024-12-23 11:41:38 +00:00
buildstats.bbclass meta/lib: move buildstats.py and rootfspostcommands.py into oe 2024-12-05 17:07:10 +00:00
debian.bbclass package/package_write: Improve packagedata code location 2023-11-08 10:56:35 +00:00
devshell.bbclass devshell: Do not add scripts/git-intercept to PATH 2023-02-10 09:25:44 +00:00
insane.bbclass classes-global/insane: Handle case where RPROVIDER is also a provider 2024-12-12 12:55:56 +00:00
license.bbclass classes-global/license: Move functions to library code 2024-10-25 15:37:10 +01:00
logging.bbclass classes/logging: Added the bbverbnote command to the logging set 2025-01-20 13:38:59 +00:00
mirrors.bbclass binutils-cross-testsuite: Rename to binutils-testsuite 2024-06-27 13:03:34 +01:00
package_deb.bbclass package/package_write: Improve packagedata code location 2023-11-08 10:56:35 +00:00
package_ipk.bbclass ipk: Switch to using zstd compression 2023-12-23 08:46:00 +00:00
package_pkgdata.bbclass classes: Update classes to match new bitbake class scope functionality 2022-08-12 15:27:17 +01:00
package_rpm.bbclass package_rpm: set a timestamp handling policy with the new macro %build_mtime_policy 2025-01-04 12:34:04 +00:00
package.bbclass lib/package: Check incompatible licenses at packaging time 2024-10-25 15:37:10 +01:00
packagedata.bbclass classes: Update classes to match new bitbake class scope functionality 2022-08-12 15:27:17 +01:00
patch.bbclass patch.bbclass: Make use of oe.patch.GitApplyTree.commitIgnored() 2024-02-19 16:03:22 +00:00
retain.bbclass classes: add new retain class for retaining build results 2024-08-03 07:56:10 +01:00
sanity.bbclass sanity.bbclass: Lower the length of TMPDIR limit to 400 2025-01-03 11:05:03 +00:00
sstate.bbclass sstate: Ensure errors cause task failure 2025-01-08 12:37:20 +00:00
staging.bbclass classes-global/staging: Exclude do_create_spdx from automatic sysroot extension 2024-07-13 23:28:31 +01:00
uninative.bbclass uninative: Add pthread linking workaround 2024-03-19 15:25:12 +00:00
utility-tasks.bbclass classes/utility-tasks: port do_listtasks to use bb.build.listtasks 2024-12-12 13:31:27 +00:00
utils.bbclass kernel-yocto: make kernel commits reproducible 2025-01-21 13:26:07 +00:00
yocto-check-layer.bbclass yocto-check-layer: expand to cover all required QA checks 2024-12-03 11:42:35 +00:00