SBOM: Change makefile to get versions from build.h
Builds using SBOM were failing in the release because we don't have a git tree to get information from. We can't assume that the coreboot source will always be in a git tree, so it needs to be updated. This updates build.h to contain all the data that the SBOM wants and changes the SBOM makefile to get its information from build.h which can generate the required data in a number of different ways. Change-Id: I59fba349d95cb0dcff7a31d335f4acb4f11c89c7 Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/88236 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alicja Michalska <ahplka19@gmail.com>
This commit is contained in:
parent
a4156f99ff
commit
2739c4b773
3 changed files with 8 additions and 4 deletions
|
|
@ -110,10 +110,10 @@ $(build-dir)/compiler-%.json: $(src-dir)/compiler-%.json | $(build-dir)/goswid
|
|||
$(build-dir)/goswid add-payload-file -o $@ -i $@ --name $$(basename $$tool) --version $$version; \
|
||||
done
|
||||
|
||||
$(build-dir)/coreboot.json: $(src-dir)/coreboot.json .git/HEAD | $(build-dir)/goswid
|
||||
$(build-dir)/coreboot.json: $(src-dir)/coreboot.json $(obj)/build.h | $(build-dir)/goswid
|
||||
cp $< $@
|
||||
git_tree_hash=$$(git log -n 1 --format=%T);\
|
||||
git_comm_hash=$$(git log -n 1 --format=%H);\
|
||||
git_tree_hash=$$(grep 'COREBOOT_ORIGIN_TREE_REVISION' $(obj)/build.h | sed 's/.*"\(.*\)".*/\1/');\
|
||||
git_comm_hash=$$(grep 'COREBOOT_ORIGIN_GIT_REVISION' $(obj)/build.h | sed 's/.*"\(.*\)".*/\1/');\
|
||||
sed -i -e "s/<colloquial_version>/$$git_tree_hash/" -e "s/<software_version>/$$git_comm_hash/" $@;\
|
||||
$(build-dir)/goswid add-license -o $@ -i $@ $(coreboot-licenses)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ if [ "${BUILD_TIMELESS}" = "1" ]; then
|
|||
DATE=0
|
||||
elif [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
|
||||
GITREV="$(get_git_head_data %h)"
|
||||
TREE_REV="$(get_git_head_data %t)"
|
||||
TIMESOURCE=git
|
||||
DATE="$(get_git_head_data %ct)"
|
||||
VERSION="$(git describe)"
|
||||
|
|
@ -45,6 +46,8 @@ else
|
|||
if [ -f "${COREBOOT_VERSION_FILE}" ]; then
|
||||
MAJOR_VER="$(sed -n 's/^0*\([0-9]*\)\.0*\([0-9]*\).*/\1/p' "${COREBOOT_VERSION_FILE}")"
|
||||
MINOR_VER="$(sed -n 's/^0*\([0-9]*\)\.0*\([0-9]*\).*/\2/p' "${COREBOOT_VERSION_FILE}")"
|
||||
GITREV="Based_on_$(sed -n 's/^[^-]*-\([^-]*\)-.*/\1/p' "${COREBOOT_VERSION_FILE}")"
|
||||
TREE_REV="Based_on_$(sed -n 's/^[^-]*-[^-]*-\(.*\)/\1/p' "${COREBOOT_VERSION_FILE}")"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -78,6 +81,7 @@ printf "#define COREBOOT_VERSION %s\n" "\"${KERNELVERSION}\""
|
|||
printf "/* timesource: %s */\n" "${TIMESOURCE}"
|
||||
printf "#define COREBOOT_VERSION_TIMESTAMP %s\n" "${DATE}"
|
||||
printf "#define COREBOOT_ORIGIN_GIT_REVISION \"%s\"\n" "${GITREV}"
|
||||
printf "#define COREBOOT_ORIGIN_TREE_REVISION \"%s\"\n" "${TREE_REV:-0}"
|
||||
|
||||
printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "${COREBOOT_EXTRA_VERSION}"
|
||||
printf "#define COREBOOT_MAJOR_VERSION %s\n" "${MAJOR_VER:-0}"
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ fi
|
|||
|
||||
git submodule update --init --checkout
|
||||
|
||||
printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h -1)" > .coreboot-version
|
||||
printf "%s-%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h -1)" "$(git log --pretty=%t -1)" > .coreboot-version
|
||||
printf "%s\n" "$(git log --pretty=format:%ci -1)" > "${TIME_FILE}"
|
||||
)
|
||||
tstamp=$(cat "${TIME_FILE}" | sed 's/ +0000//')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue