[RFC PATCH 1/3] kbuild: Introduce build-salt generated header
From: Laura Abbott
Date: Tue Mar 20 2018 - 21:47:26 EST
The build id generated from --build-id can be generated in several different
ways, with the default being the sha1 on the output of the linked file. For
distributions, it can be useful to make sure this ID is unique, even if the
actual file contents don't change. The easiest way to do this is to insert
a comment section with some data.
Introduce a header which is generated from an environment varible, BUILD_TAG.
If this variable is set, an appropriate .comment section is generated. If
the environment variable isn't set, the define is simply empty and there
is no change to the build.
Suggested-by: Nick Clifton <nickc@xxxxxxxxxx>
Signed-off-by: Laura Abbott <labbott@xxxxxxxxxx>
---
Makefile | 9 ++++++++-
scripts/gencomment | 19 +++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
create mode 100755 scripts/gencomment
diff --git a/Makefile b/Makefile
index d65e2e229017..de360625aec5 100644
--- a/Makefile
+++ b/Makefile
@@ -1087,7 +1087,7 @@ endif
prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic
prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
- include/config/auto.conf
+ include/config/auto.conf include/generated/build-salt.h
$(cmd_crmodverdir)
archprepare: archheaders archscripts prepare1 scripts_basic
@@ -1175,6 +1175,13 @@ $(version_h): $(srctree)/Makefile FORCE
include/generated/utsrelease.h: include/config/kernel.release FORCE
$(call filechk,utsrelease.h)
+define filechk_build-salt.h
+ ($(CONFIG_SHELL) $(srctree)/scripts/gencomment)
+endef
+
+include/generated/build-salt.h: $(srctree)/Makefile FORCE
+ $(call filechk,build-salt.h)
+
PHONY += headerdep
headerdep:
$(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
diff --git a/scripts/gencomment b/scripts/gencomment
new file mode 100755
index 000000000000..13b6e7739ef7
--- /dev/null
+++ b/scripts/gencomment
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ -z $BUILD_TAG ]; then
+ echo "#define ID_TAG"
+ exit 0
+fi
+
+echo "#define ID_TAG \\"
+echo ".comment (INFO) : \\"
+echo " { \\"
+
+_TAG=`echo $BUILD_TAG | sed -e 's/\(.\)/\1 /g'`
+for c in $_TAG; do
+ _HEX=`echo -n $c | od -A n -t x1 | tr -d ' ' `
+ echo "BYTE(0x$_HEX); \\"
+done
+echo "BYTE(0x00); \\"
+
+echo " } "
--
2.16.2