Skip to content

Commit bceb92c

Browse files
Populate sbom with minimal properties | reproducible builds (#3385)
* populate sbom with gcc and glibc versions Signed-off-by: Shriti Chandra <[email protected]> * Add gcc, glibc and bootjdk versions to build script Signed-off-by: Shriti Chandra <[email protected]> * shift to dpkg for sourcing glibc version Signed-off-by: Shriti Chandra <[email protected]> * add function calls Signed-off-by: Shriti Chandra <[email protected]> * Fix syntax error for grep commands Signed-off-by: Shriti Chandra <[email protected]> * Fix function call name Signed-off-by: Shriti Chandra <[email protected]> --------- Signed-off-by: Shriti Chandra <[email protected]>
1 parent fcbfd2a commit bceb92c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

sbin/build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,9 @@ generateSBoM() {
874874
addSBOMComponentPropertyFromFile "${javaHome}" "${classpath}" "${sbomJson}" "Eclipse Temurin" "make_command_args" "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/makeCommandArg.txt"
875875

876876
# Below add build tools into metadata tools
877+
addGLIBCforLinux
878+
addGCC
879+
addBootJDK
877880
# Add ALSA 3rd party
878881
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "ALSA" "$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/dependency_version_alsa.txt)"
879882
# Add FreeType 3rd party (windows + macOS)
@@ -906,6 +909,29 @@ checkingToolSummary() {
906909
sed -n '/^Tools summary:$/,$p' "${inputConfigFile}" > "${outputConfigFile}"
907910
}
908911

912+
# Below add versions to sbom | Facilitate reproducible builds
913+
914+
addGLIBCforLinux() {
915+
export CC=$(grep "^CC :=" ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/build/*/spec.gmk)
916+
export SYSROOT_CFLAGS=$(grep "^SYSROOT_CFLAGS :=" ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/build/*/spec.gmk)
917+
export GLIBC_MAJOR="$(echo "#include <features.h>" | $CC $SYSROOT_CFLAGS -dM -E - 2>&1 | tr -s " " | grep "#define __GLIBC__" | cut -d" " -f3)"
918+
export GLIBC_MINOR="$(echo "#include <features.h>" | $CC $SYSROOT_CFLAGS -dM -E - 2>&1 | tr -s " " | grep "#define __GLIBC_MINOR__" | cut -d" " -f3)"
919+
export GLIBC_VERSION="${GLIBC_MAJOR}.${GLIBC_MINOR}"
920+
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "GLIBC" "${GLIBC_VERSION}"
921+
}
922+
923+
addGCC() {
924+
echo "Checking and getting GCC Version:"
925+
inputConfigFile="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/configure.txt"
926+
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "GCC" "$(sed -n '/^Tools summary:$/,$p' "${inputConfigFile}" | grep "C Compiler:" | tr -s " " | cut -d " " -f5)"
927+
}
928+
929+
addBootJDK() {
930+
echo "Checking and getting BootJDK Version:"
931+
inputConfigFile="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/configure.txt"
932+
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "BOOTJDK" "$(sed -n '/^Tools summary:$/,$p' "${inputConfigFile}" | grep "Boot JDK:" | tr -s " " | cut -d " " -f 6)"
933+
}
934+
909935
getGradleJavaHome() {
910936
local gradleJavaHome=""
911937

0 commit comments

Comments
 (0)