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

Correctly obtain ALSA version for SBOM #3809

Merged
merged 1 commit into from
May 14, 2024
Merged
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
31 changes: 30 additions & 1 deletion sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ generateSBoM() {
addBootJDK

# Add ALSA 3rd party
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "ALSA" "$(cat ${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/dependency_version_alsa.txt)"
addALSAVersion
# Add FreeType 3rd party
addFreeTypeVersionInfo
# Add FreeMarker 3rd party (openj9)
Expand Down Expand Up @@ -1155,6 +1155,35 @@ addCycloneDXVersions() {

# Below add versions to sbom | Facilitate reproducible builds

addALSAVersion() {
# Get ALSA include location from configured build spec.gmk and locate version.h definition
local specFile
if [ -z "${BUILD_CONFIG[USER_OPENJDK_BUILD_ROOT_DIRECTORY]}" ] ; then
specFile="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/${BUILD_CONFIG[OPENJDK_SOURCE_DIR]}/build/*/spec.gmk"
else
specFile="${BUILD_CONFIG[USER_OPENJDK_BUILD_ROOT_DIRECTORY]}/spec.gmk"
fi

# Get ALSA include dir from the built build spec.gmk for ALSA_CFLAGS.
local ALSA_INCLUDE="$(grep "^ALSA_CFLAGS[ ]*:=" ${specFile} | sed "s/^ALSA_CFLAGS[ ]*:=[ ]*//" | sed "s/^-I//")"
if [ -z "${ALSA_INCLUDE}" ]; then
echo "No ALSA_CFLAGS, ALSA not used"
else
local ALSA_VERSION_H="${ALSA_INCLUDE}/version.h"

# Get SND_LIB_VERSION_STR from version.h
local ALSA_VERSION="$(grep "SND_LIB_VERSION_STR" ${ALSA_VERSION_H} | tr "\t" " " | tr -s " " | cut -d" " -f3 | sed "s/\"//g")"

if [ -z "${ALSA_VERSION}" ]; then
echo "Unable to find SND_LIB_VERSION_STR in ${ALSA_VERSION_H}"
ALSA_VERSION="Unknown"
fi

echo "Adding ALSA version to SBOM: ${ALSA_VERSION}"
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "ALSA" "${ALSA_VERSION}"
fi
}

addGLIBCforLinux() {
# Determine target build LIBC from configure log "target system type" which is consistent for jdk8+
local inputConfigFile="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[TARGET_DIR]}/metadata/configure.txt"
Expand Down
Loading