From bd7a945bbbf586ceb7c83785ef36d95f0adf7a15 Mon Sep 17 00:00:00 2001 From: MrChromebox Date: Wed, 21 Oct 2020 10:04:27 -0500 Subject: [PATCH] Inject Heads version string into coreboot LOCALVERSION... (#859) * config/coreboot-*: drop CONFIG_LOCALVERSION Will be injected as part of the build using $(HEADS_GIT_VERSION) Signed-off-by: Matt DeVillier * modules/coreboot: inject $(HEADS_GIT_VERSION) as CONFIG_LOCALVERSION Needed for fwupd to handle board updates Signed-off-by: Matt DeVillier * modules/coreboot: override SMBIOS ProductName with $(BOARD) Signed-off-by: Matt DeVillier * Use $(BOARD)-$(HEADS_GIT_VERSION) as basis for output filename makes builds uniquely identifiable based on board and version. Signed-off-by: Matt DeVillier --- Makefile | 32 +++++++++++-------- .../qemu-coreboot-fbwhiptail.config | 2 +- boards/qemu-coreboot/qemu-coreboot.config | 2 +- boards/t430-flash/t430-flash.config | 2 +- boards/x230-flash/x230-flash.config | 2 +- config/coreboot-kgpe-d16.config | 1 - config/coreboot-librem_13v2.config | 1 - config/coreboot-librem_13v4.config | 1 - config/coreboot-librem_15v3.config | 1 - config/coreboot-librem_15v4.config | 1 - config/coreboot-librem_mini.config | 1 - config/coreboot-qemu-fbwhiptail.config | 1 - config/coreboot-qemu.config | 1 - config/coreboot-t420.config | 1 - config/coreboot-t430-flash.config | 1 - config/coreboot-t430.config | 1 - config/coreboot-x220.config | 1 - config/coreboot-x230-flash.config | 1 - config/coreboot-x230-hotp-verification.config | 1 - config/coreboot-x230.config | 1 - modules/coreboot | 6 +++- modules/linuxboot | 6 ++-- 22 files changed, 31 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index 7817f5f6..44023aed 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,17 @@ +# Need to set CB_OUTPUT_FILE before board .config included so +# that target overrides in x230/x430-flash (eg) are properly handled +GIT_HASH := $(shell git rev-parse HEAD) +GIT_STATUS := $(shell \ + if git diff --exit-code >/dev/null ; then \ + echo clean ; \ + else \ + echo dirty ; \ + fi) +HEADS_GIT_VERSION := $(shell git describe --tags --dirty) + +CB_OUTPUT_FILE := heads-$(BOARD)-$(HEADS_GIT_VERSION).rom +LB_OUTPUT_FILE := linuxboot-$(BOARD)-$(HEADS_GIT_VERSION).rom + all: -include .config @@ -100,16 +114,6 @@ include $(CONFIG) # Unless otherwise specified, we are building for heads 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) - # record the build date / git hashes and other files here HASHES := $(build)/$(BOARD)/hashes.txt @@ -186,10 +190,10 @@ CROSS_TOOLS := \ -ifeq "$(CONFIG_COREBOOT)" "y" -all: $(build)/$(BOARD)/coreboot.rom -else ifeq "$(CONFIG_LINUXBOOT)" "y" -all: $(build)/$(BOARD)/linuxboot.rom +ifeq ($(CONFIG_COREBOOT), y) +all: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) +else ifeq ($(CONFIG_LINUXBOOT), y) +all: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) else $(error "$(BOARD): neither CONFIG_COREBOOT nor CONFIG_LINUXBOOT is set?") endif diff --git a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config index b6210ca7..83ba5cd9 100644 --- a/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config +++ b/boards/qemu-coreboot-fbwhiptail/qemu-coreboot-fbwhiptail.config @@ -48,7 +48,7 @@ export CONFIG_BOOT_DEV="/dev/sda1" run: qemu-system-x86_64 \ --machine q35 \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/qemu-coreboot/qemu-coreboot.config b/boards/qemu-coreboot/qemu-coreboot.config index dce3583e..79643a5e 100644 --- a/boards/qemu-coreboot/qemu-coreboot.config +++ b/boards/qemu-coreboot/qemu-coreboot.config @@ -58,7 +58,7 @@ run: qemu-system-x86_64 \ --machine q35 \ --serial /dev/tty \ - --bios $(build)/$(BOARD)/coreboot.rom \ + --bios $(build)/$(BOARD)/$(CB_OUTPUT_FILE) \ -object rng-random,filename=/dev/urandom,id=rng0 \ -device virtio-rng-pci,rng=rng0 \ -netdev user,id=u1 -device e1000,netdev=u1 \ diff --git a/boards/t430-flash/t430-flash.config b/boards/t430-flash/t430-flash.config index 43be7cb2..897eb641 100644 --- a/boards/t430-flash/t430-flash.config +++ b/boards/t430-flash/t430-flash.config @@ -21,6 +21,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/boards/x230-flash/x230-flash.config b/boards/x230-flash/x230-flash.config index edb417ea..283c8fbf 100644 --- a/boards/x230-flash/x230-flash.config +++ b/boards/x230-flash/x230-flash.config @@ -26,6 +26,6 @@ export CONFIG_FLASHROM_OPTIONS="--force --noverify-all -p internal --ifd --image # allow the board to boot into a minimal Heads and read the full # ROM from an external USB media. all: $(build)/$(BOARD)/$(BOARD).rom -$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/coreboot.rom +$(build)/$(BOARD)/$(BOARD).rom: $(build)/$(BOARD)/$(CB_OUTPUT_FILE) dd of=$@ if=$< bs=65536 count=64 skip=128 sha256sum $@ diff --git a/config/coreboot-kgpe-d16.config b/config/coreboot-kgpe-d16.config index 01cf91ee..3c341acd 100644 --- a/config/coreboot-kgpe-d16.config +++ b/config/coreboot-kgpe-d16.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_OPTION_TABLE=y # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-librem_13v2.config b/config/coreboot-librem_13v2.config index d7c89987..5c30393d 100644 --- a/config/coreboot-librem_13v2.config +++ b/config/coreboot-librem_13v2.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_13v4.config b/config/coreboot-librem_13v4.config index 66fd6aa0..d3c01989 100644 --- a/config/coreboot-librem_13v4.config +++ b/config/coreboot-librem_13v4.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_15v3.config b/config/coreboot-librem_15v3.config index 7be32773..a813b5ea 100644 --- a/config/coreboot-librem_15v3.config +++ b/config/coreboot-librem_15v3.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_15v4.config b/config/coreboot-librem_15v4.config index a2afb1ce..46298eda 100644 --- a/config/coreboot-librem_15v4.config +++ b/config/coreboot-librem_15v4.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="4.8.1-Purism-1-heads-beta" CONFIG_ANY_TOOLCHAIN=y CONFIG_USE_BLOBS=y CONFIG_MEASURED_BOOT=y diff --git a/config/coreboot-librem_mini.config b/config/coreboot-librem_mini.config index ddf4ed5e..0a574bdf 100644 --- a/config/coreboot-librem_mini.config +++ b/config/coreboot-librem_mini.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_CBFS_SIZE=0xC00000 CONFIG_VENDOR_PURISM=y diff --git a/config/coreboot-qemu-fbwhiptail.config b/config/coreboot-qemu-fbwhiptail.config index a1a6f432..bd1a924f 100644 --- a/config/coreboot-qemu-fbwhiptail.config +++ b/config/coreboot-qemu-fbwhiptail.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="-heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set CONFIG_CBFS_SIZE=0x700000 diff --git a/config/coreboot-qemu.config b/config/coreboot-qemu.config index 87d0f64a..8a3fd6d2 100644 --- a/config/coreboot-qemu.config +++ b/config/coreboot-qemu.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="-heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set CONFIG_CBFS_SIZE=0x700000 diff --git a/config/coreboot-t420.config b/config/coreboot-t420.config index 793ff17d..59a91b8b 100644 --- a/config/coreboot-t420.config +++ b/config/coreboot-t420.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-t430-flash.config b/config/coreboot-t430-flash.config index c44c7537..092bd8bc 100644 --- a/config/coreboot-t430-flash.config +++ b/config/coreboot-t430-flash.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-t430.config b/config/coreboot-t430.config index 405e0bba..1607172c 100644 --- a/config/coreboot-t430.config +++ b/config/coreboot-t430.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y diff --git a/config/coreboot-x220.config b/config/coreboot-x220.config index 01a66302..88167453 100644 --- a/config/coreboot-x220.config +++ b/config/coreboot-x220.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-x230-flash.config b/config/coreboot-x230-flash.config index 6461d02b..9ad545e0 100644 --- a/config/coreboot-x230-flash.config +++ b/config/coreboot-x230-flash.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y # CONFIG_INCLUDE_CONFIG_FILE is not set # CONFIG_COLLECT_TIMESTAMPS is not set diff --git a/config/coreboot-x230-hotp-verification.config b/config/coreboot-x230-hotp-verification.config index 092064af..865a04fe 100644 --- a/config/coreboot-x230-hotp-verification.config +++ b/config/coreboot-x230-hotp-verification.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y diff --git a/config/coreboot-x230.config b/config/coreboot-x230.config index ac344588..4d3c569b 100644 --- a/config/coreboot-x230.config +++ b/config/coreboot-x230.config @@ -1,4 +1,3 @@ -CONFIG_LOCALVERSION="heads" CONFIG_ANY_TOOLCHAIN=y CONFIG_MEASURED_BOOT=y CONFIG_VENDOR_LENOVO=y diff --git a/modules/coreboot b/modules/coreboot index 7e3b7f1e..a4664e94 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -37,6 +37,8 @@ EXTRA_FLAGS := -fdebug-prefix-map=$(pwd)=heads -gno-record-gcc-switches -Wno-err coreboot_configure := \ mkdir -p "$(build)/$(coreboot_dir)" \ && cp "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" "$(build)/$(coreboot_dir)/.config" \ + && echo 'CONFIG_LOCALVERSION="Heads-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \ + && echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(BOARD)"' >> $(build)/$(coreboot_dir)/.config \ && $(MAKE) olddefconfig \ -C "$(build)/$(coreboot_base_dir)" \ obj="$(build)/$(coreboot_dir)" \ @@ -76,10 +78,12 @@ $(build)/$(coreboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ # This produces a ROM image that is written with the flashrom program -$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/.build +ifneq ($(CONFIG_COREBOOT),) +$(build)/$(BOARD)/$(CB_OUTPUT_FILE): $(build)/$(coreboot_dir)/.build "$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print $(call do-copy,$(dir $<)coreboot.rom,$@) @touch $@ # update the time stamp +endif # # Helpful target for reconfiguring the coreboot target diff --git a/modules/linuxboot b/modules/linuxboot index 57ea31a2..19edcc4e 100644 --- a/modules/linuxboot +++ b/modules/linuxboot @@ -59,9 +59,11 @@ endif linuxboot_output := build/$(linuxboot_board)/linuxboot.rom linuxboot_rom := $(build)/$(linuxboot_dir)/$(linuxboot_output) -$(build)/$(BOARD)/linuxboot.rom: $(build)/$(linuxboot_dir)/.build +ifneq ($(CONFIG_LINUXBOOT),) +$(build)/$(BOARD)/$(LB_OUTPUT_FILE): $(build)/$(linuxboot_dir)/.build $(call do-copy,$(dir $<)linuxboot.rom,$@) @touch $@ +endif # Also force a rebuild if any of the input files are updated $(build)/$(linuxboot_dir)/.build: \ @@ -70,7 +72,7 @@ $(build)/$(linuxboot_dir)/.build: \ $(build)/$(BOARD)/initrd.cpio.xz \ -linuxboot.run: $(build)/$(BOARD)/linuxboot.rom +linuxboot.run: $(build)/$(BOARD)/$(LB_OUTPUT_FILE) $(MAKE) -C $(build)/$(linuxboot_base_dir) \ BOARD:=$(linuxboot_board) \ KERNEL=$(build)/$(BOARD)/bzImage \