On 5/13/20 9:24 AM, Bruce Ashfield wrote:
From: Bruce Ashfield <[email protected]>
Rather than duplicating the code to generate the kbuild environment
variable: KBUILD_BUILD_TIMESTAMP, we can factor the checks into a
python function and call it from the main image and kernel module
do_compile routines.
All paths have been checked and the timestamp is identical to the
previous shell variant.
Signed-off-by: Bruce Ashfield <[email protected]>
---
meta/classes/kernel.bbclass | 43 ++++++++++++++++---------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index a3990aaf59..de63e1c0f6 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -153,6 +153,21 @@ python do_symlink_kernsrc () {
}
addtask symlink_kernsrc before do_configure after do_unpack
+def get_kernel_source_date_epoch(d):
+ import subprocess
+
+ s_d_e = d.getVar("SOURCE_DATE_EPOCH")
+ if not s_d_e:
+ s_d_e = subprocess.check_output(['git', '--git-dir=%s/.git' %
d.getVar('S'), 'log', '-1', '--pretty=%ct']).decode('utf-8')
+ if not s_d_e:
+ s_d_e = d.getVar("REPRODUCIBLE_TIMESTAMP_ROOTFS")
+
+ env = os.environ.copy()
+ env['LC_ALL'] = 'C'
+ ts = subprocess.check_output(['date', '-d @%s' % s_d_e]).decode('utf-8')
+
+ return ts
+
Is there something special about the kernel that it can't use the
SOURCE_DATE_EPOCH guessing code from classes/reproducible_build.bbclass?
If so, is it possible there is some minor change we could make to the
code to make it work? It seems a little unfortunate to replicate the
logic to calculate the SDE when that class does it already.
inherit kernel-arch deploy
PACKAGES_DYNAMIC += "^${KERNEL_PACKAGE_NAME}-module-.*"
@@ -291,19 +306,9 @@ get_cc_option () {
kernel_do_compile() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
- # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may
not
- # be set....
- if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" =
"0" ]; then
- # The source directory is not necessarily a git
repository, so we
- # specify the git-dir to ensure that git does not query
a
- # repository in any parent directory.
- SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct
2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"`
- fi
-
- ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
- export KBUILD_BUILD_TIMESTAMP="$ts"
+ export KBUILD_BUILD_TIMESTAMP="${@
get_kernel_source_date_epoch(d)}"
export KCONFIG_NOTIMESTAMP=1
- bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
+ bbnote "KBUILD_BUILD_TIMESTAMP: $KBUILD_BUILD_TIMESTAMP"
fi
# The $use_alternate_initrd is only set from
# do_bundle_initramfs() This variable is specifically for the
@@ -332,19 +337,9 @@ kernel_do_compile() {
do_compile_kernelmodules() {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
- # kernel sources do not use do_unpack, so SOURCE_DATE_EPOCH may
not
- # be set....
- if [ "${SOURCE_DATE_EPOCH}" = "" -o "${SOURCE_DATE_EPOCH}" =
"0" ]; then
- # The source directory is not necessarily a git
repository, so we
- # specify the git-dir to ensure that git does not query
a
- # repository in any parent directory.
- SOURCE_DATE_EPOCH=`git --git-dir="${S}/.git" log -1 --pretty=%ct
2>/dev/null || echo "${REPRODUCIBLE_TIMESTAMP_ROOTFS}"`
- fi
-
- ts=`LC_ALL=C date -d @$SOURCE_DATE_EPOCH`
- export KBUILD_BUILD_TIMESTAMP="$ts"
+ export KBUILD_BUILD_TIMESTAMP="${@
get_kernel_source_date_epoch(d)}"
export KCONFIG_NOTIMESTAMP=1
- bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
+ bbnote "KBUILD_BUILD_TIMESTAMP: $KBUILD_BUILD_TIMESTAMP"
fi
if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
cc_extra=$(get_cc_option)
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#138277):
https://lists.openembedded.org/g/openembedded-core/message/138277
Mute This Topic: https://lists.openembedded.org/mt/74182751/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-