[oe-commits] [openembedded-core] 06/11: kernel.bbclass: fix SOURCE_DATE_EPOCH for non-git kernel builds

git at git.openembedded.org git at git.openembedded.org
Wed Mar 11 01:13:59 UTC 2020


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 270ae94fe345b9ce98d822034cbfad7e24c5f393
Author: Christopher Clark <christopher.w.clark at gmail.com>
AuthorDate: Sun Mar 8 21:48:13 2020 -0700

    kernel.bbclass: fix SOURCE_DATE_EPOCH for non-git kernel builds
    
    The source directory is not always a git repository, so when querying
    git for data to set SOURCE_DATE_EPOCH, specify ${S}/.git as the git
    directory to prevent retrieving incorrect data from any parent directory.
    
    Fixes the following errors with the prior logic when building a kernel
    that is not obtained from a git repository:
    
    1. With TMPDIR set to a directory outside any git repository on a
    mounted filesystem, reproducible builds fail in do_compile with this git
    error:
    
      fatal: not a git repository (or any parent up to mount point <abspath>)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
    
    aborting before the error handling logic.
    
    2. With TMPDIR located within a subdirectory of a git repository, the
    SOURCE_DATE_EPOCH timestamp would be that of said repository rather than
    that of the kernel.
    
    Signed-off-by: Christopher Clark <christopher.w.clark at gmail.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/kernel.bbclass | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 0eadd3e..a724645 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -294,14 +294,10 @@ kernel_do_compile() {
 		# 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
-			olddir=`pwd`
-			cd ${S}
-			SOURCE_DATE_EPOCH=`git log  -1 --pretty=%ct`
-			# git repo not guaranteed, so fall back to REPRODUCIBLE_TIMESTAMP_ROOTFS
-			if [ $? -ne 0 ]; then
-				SOURCE_DATE_EPOCH=${REPRODUCIBLE_TIMESTAMP_ROOTFS}
-			fi
-			cd $olddir
+			# 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`

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list