Skip to content

Commit

Permalink
Add a joinPathOS method that converts paths to OS specific ones and u…
Browse files Browse the repository at this point in the history
…se plan joinPath for files that are passed to cygwin programs.
  • Loading branch information
netomi committed Nov 23, 2023
1 parent a374308 commit ceecdfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ generateSBoM() {
sbomTargetName="${sbomTargetName//\.tar\.gz/}"
fi

local sbomJson="$(joinPath ${BUILD_CONFIG[WORKSPACE_DIR]} ${BUILD_CONFIG[TARGET_DIR]} ${sbomTargetName})"
local sbomJson="$(joinPathOS ${BUILD_CONFIG[WORKSPACE_DIR]} ${BUILD_CONFIG[TARGET_DIR]} ${sbomTargetName})"
echo "OpenJDK SBOM will be ${sbomJson}."

# Clean any old json
Expand Down Expand Up @@ -895,7 +895,7 @@ generateSBoM() {
# Add FreeType 3rd party
addFreeTypeVersionInfo
# Add FreeMarker 3rd party (openj9)
local freemarker_version="$(joinPath ${BUILD_CONFIG[WORKSPACE_DIR]} ${BUILD_CONFIG[TARGET_DIR]} 'metadata/dependency_version_freemarker.txt')"
local freemarker_version="$(joinPathOS ${BUILD_CONFIG[WORKSPACE_DIR]} ${BUILD_CONFIG[TARGET_DIR]} 'metadata/dependency_version_freemarker.txt')"
if [ -f "${freemarker_version}" ]; then
addSBOMMetadataTools "${javaHome}" "${classpath}" "${sbomJson}" "FreeMarker" "$(cat ${freemarker_version})"
fi
Expand Down
8 changes: 7 additions & 1 deletion sbin/common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,20 @@ function setDockerVolumeSuffix() {
}

# Joins multiple parts to a valid file path for the current OS
function joinPath() {
function joinPathOS() {
local path=$(printf '/%s' "${@}" | sed 's|/\+|/|g')
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
path=$(cygpath -w "${path}")
fi
echo "${path}"
}

# Joins multiple parts to a valid file path using slashes
function joinPath() {
local path=$(printf '/%s' "${@}" | sed 's|/\+|/|g')
echo "${path}"
}

# Create a Tar ball
getArchiveExtension()
{
Expand Down

0 comments on commit ceecdfe

Please sign in to comment.