From 492b94afb51ca64361c2ebd88abcd72d83eb5525 Mon Sep 17 00:00:00 2001 From: Trammell hudson Date: Fri, 4 May 2018 14:36:56 -0400 Subject: [PATCH] move git hash into /etc/config instead of Linux kernel version and track clean/dirty status (#398) --- Makefile | 29 ++++++++++++++++++++++------- modules/linux | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 14dee64b..2441f1ba 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,12 @@ CONFIG_HEADS ?= y # Some things want usernames, we use the current checkout # so that they are reproducible GIT_HASH := $(shell git rev-parse HEAD) +GIT_STATUS := $(shell \ + if git diff --exit-code >/dev/null ; then \ + echo clean ; \ + else \ + echo dirty ; \ + fi) # Timestamps should be in ISO format DATE=`date --rfc-3339=seconds` @@ -177,11 +183,11 @@ define do-cpio = endef define do-copy = - $(call do,INSTALL ,$1 => $2',\ - if ! cmp --quiet "$1" "$2" ; then \ + $(call do,INSTALL ,$1 => $2,\ + if cmp --quiet "$1" "$2" ; then \ echo "$(DATE) UNCHANGED $(1:$(pwd)/%=%)" ; \ fi ; \ - cp -a "$1" "$2"; \ + cp -a "$1" "$2" ; \ ) @sha256sum "$(2:$(pwd)/%=%)" endef @@ -476,17 +482,26 @@ $(build)/$(initrd_dir)/heads.cpio: FORCE $(build)/$(initrd_dir)/tools.cpio: \ $(initrd_bins) \ $(initrd_libs) \ + $(initrd_tmp_dir)/etc/config \ + $(call do-cpio,$@,$(initrd_tmp_dir)) + @$(RM) -rf "$(initrd_tmp_dir)" + +$(initrd_tmp_dir)/etc/config: FORCE + @mkdir -p $(dir $@) $(call do,INSTALL,$(CONFIG), \ - mkdir -p "$(initrd_tmp_dir)/etc" ; \ export \ | grep ' CONFIG_' \ | sed -e 's/^declare -x /export /' \ -e 's/\\\"//g' \ - > "$(initrd_tmp_dir)/etc/config" \ + > $@ \ + ) + $(call do,HASH,$(GIT_HASH) $(GIT_STATUS), \ + echo export GIT_HASH=\'$(GIT_HASH)\' \ + >> $@ ; \ + echo export GIT_STATUS=$(GIT_STATUS) \ + >> $@ ; \ ) - $(call do-cpio,$@,$(initrd_tmp_dir)) - @$(RM) -rf "$(initrd_tmp_dir)" # Ensure that the initrd depends on all of the modules that produce # binaries for it diff --git a/modules/linux b/modules/linux index 444e9e66..f0bfccf3 100644 --- a/modules/linux +++ b/modules/linux @@ -92,7 +92,7 @@ linux_target := \ AFLAGS_KERNEL="$(EXTRA_FLAGS)" \ CFLAGS_KERNEL="$(EXTRA_FLAGS)" \ CFLAGS_MODULE="$(EXTRA_FLAGS)" \ - KBUILD_BUILD_USER="$(GIT_HASH)" \ + KBUILD_BUILD_USER=$(notdir $(linux_kconfig)) \ KBUILD_BUILD_HOST=linuxboot \ KBUILD_BUILD_TIMESTAMP="1970-00-00" \ KBUILD_BUILD_VERSION=0 \