Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: Michal Marek <mmarek@suse.com>
Cc: linux-kbuild <linux-kbuild@vger.kernel.org>,
	reproducible-builds@lists.alioth.debian.org
Subject: [PATCH] kbuild: Add support for SOURCE_DATE_EPOCH environment variable
Date: Fri, 02 Oct 2015 00:15:32 +0100	[thread overview]
Message-ID: <1443741332.2730.75.camel@decadent.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]

As part of the reproducible builds project, the SOURCE_DATE_EPOCH
environment variable has been specified as a project- and
distribution-independent means to specify a timestamp at build
time: https://reproducible-builds.org/specs/source-date-epoch/

Add support for this by converting it to KBUILD_BUILD_TIMESTAMP
if they aren't both set.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 Documentation/kbuild/kbuild.txt | 15 +++++++++------
 Makefile                        | 10 ++++++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 0ff6a46..9f95228 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -211,12 +211,15 @@ KBUILD_ENABLE_EXTRA_GCC_CHECKS
 If enabled over the make command line with "W=1", it turns on additional
 gcc -W... options for more extensive build-time checking.
 
-KBUILD_BUILD_TIMESTAMP
---------------------------------------------------
-Setting this to a date string overrides the timestamp used in the
-UTS_VERSION definition (uname -v in the running kernel). The value has to
-be a string that can be passed to date -d. The default value
-is the output of the date command at one point during build.
+KBUILD_BUILD_TIMESTAMP, SOURCE_DATE_EPOCH
+--------------------------------------------------
+Setting KBUILD_BUILD_TIMESTAMP to a date string overrides the
+timestamp used in the UTS_VERSION definition (uname -v in the running
+kernel). The value has to be a string that can be passed to date -d.
+The default value is the output of the date command at one point
+during build. Alternately, the timestamp may be specified in
+SOURCE_DATE_EPOCH as the number of whole non-leap seconds since the
+epoch.
 
 KBUILD_BUILD_USER, KBUILD_BUILD_HOST
 --------------------------------------------------
diff --git a/Makefile b/Makefile
index 1d341eb..bfb0243 100644
--- a/Makefile
+++ b/Makefile
@@ -417,6 +417,16 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
 export KBUILD_ARFLAGS
 
+ifndef KBUILD_BUILD_TIMESTAMP
+  # If SOURCE_DATE_EPOCH is set in the environment (only), then
+  # generate a timestamp string based on that, independent of the
+  # current time zone and locale.
+  ifeq ("$(origin SOURCE_DATE_EPOCH)", "environment")
+    KBUILD_BUILD_TIMESTAMP := $(shell LC_TIME=C date -u -d@$(SOURCE_DATE_EPOCH))
+    export KBUILD_BUILD_TIMESTAMP
+  endif
+endif
+
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
 # even be read-only.
-- 
Ben Hutchings
When in doubt, use brute force. - Ken Thompson

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

             reply	other threads:[~2015-10-01 23:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-01 23:15 Ben Hutchings [this message]
2015-10-26 21:03 ` [PATCH] kbuild: Add support for SOURCE_DATE_EPOCH environment variable Michal Marek
2015-10-27  0:49   ` Ben Hutchings
2015-10-27  1:31     ` [Reproducible-builds] " Holger Levsen

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=1443741332.2730.75.camel@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=mmarek@suse.com \
    --cc=reproducible-builds@lists.alioth.debian.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