Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git hash and tags for versioning #839

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ $(HEADS_GAWK): $(build)/$(gawk_dir)/.configured
$(VERBOSE_REDIRECT)
endif

# Some things want usernames, we use the current checkout
# so that they are reproducible
GIT_HASH := $(shell git rev-parse HEAD)
GIT_HASH_SHORT := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git branch --show-current)
GIT_TAG := $(shell git describe --abbrev=1 --tags --dirty)
GIT_STATUS := $(shell \
if git diff --exit-code >/dev/null ; then \
echo clean ; \
else \
echo dirty ; \
fi)

BOARD ?= qemu-coreboot
CONFIG := $(pwd)/boards/$(BOARD)/$(BOARD).config
Expand All @@ -100,16 +112,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

Expand Down Expand Up @@ -595,6 +597,8 @@ $(initrd_tmp_dir)/etc/config: FORCE
$(call do,HASH,$(GIT_HASH) $(GIT_STATUS) $(BOARD), \
echo export GIT_HASH=\'$(GIT_HASH)\' \
>> $@ ; \
echo export GIT_TAG=\'$(GIT_TAG)\' \
>> $@ ; \
echo export GIT_STATUS=$(GIT_STATUS) \
>> $@ ; \
echo export CONFIG_BOARD=$(BOARD) \
Expand Down
2 changes: 1 addition & 1 deletion initrd/bin/gui-init
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ while true; do
memtotal=$((${memtotal} / 1024 / 1024 + 1))
cpustr=$(cat /proc/cpuinfo | grep 'model name' | uniq | sed -r 's/\(R\)//;s/\(TM\)//;s/CPU //;s/model name.*: //')
whiptail --title 'System Info' \
--msgbox "VER: ${FW_VER}\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 16 60
--msgbox "VER: Heads $GIT_TAG ($GIT_HASH)\n\nCPU: ${cpustr}\nRAM: ${memtotal} GB\n\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')" 16 60
continue
fi

Expand Down
1 change: 1 addition & 0 deletions modules/coreboot
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ $(build)/$(coreboot_dir)/.build: \
$(build)/$(BOARD)/coreboot.rom: $(build)/$(coreboot_dir)/.build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something for a follow-on: coreboot.rom isn't the most useful output name, something like Heads-<board>-<tag>.rom would be far better. When building for a half dozen+ boards, having to rename manually to something useful after every build becomes very tiresome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until now I only added heads- to the copy of coreboot.rom. If I rename the coreboot.rom I need to change the CI files and maybe other things too, right?

Copy link
Collaborator

@tlaurion tlaurion Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alex-nitrokey : CircleCI backups the content of the build dir altogether, while gitlabci is currently foo bar, whiule the same logic used to CircleCI (backup build dir instead of individual files) should be taken anyway.

"$(build)/$(coreboot_dir)/cbfstool" "$(dir $<)coreboot.rom" print
$(call do-copy,$(dir $<)coreboot.rom,$@)
$(call do-copy,$(dir $<)coreboot.rom,$(build)/$(BOARD)/heads-$(GIT_BRANCH)-$(GIT_TAG).rom)
@touch $@ # update the time stamp

#
Expand Down