Skip to content

Commit

Permalink
fix(scancode): No ScanCode license texts in disclosure document
Browse files Browse the repository at this point in the history
If ORT is executed within a Docker container, the report generator for
the OSS disclosure document may not be able to look up the license texts
collected by ScanCode, leading to empty sections in the disclosure
document.

In environments where Python version management tools like Pyenv are
used, directory structures differ, leading to different paths for data
directories, causing the reporter to fail looking up the ScanCode license
texts.

Update the heuristic algorithm to locate the ScanCode license texts
directory based on the path of the ScanCode binary: Ensure compatibility
with directory layouts managed by Python version management tools.

Fixes #8147.

Signed-off-by: Wolfgang Klenk <wolfgang.klenk2@bosch.com>
  • Loading branch information
wkl3nk committed Dec 17, 2024
1 parent c259ffb commit de1b915
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion utils/spdx/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ val scanCodeLicenseTextDir by lazy {
val pythonBinDir = listOf("bin", "Scripts")
val scanCodeBaseDir = scanCodeExeDir?.takeUnless { it.name in pythonBinDir } ?: scanCodeExeDir?.parentFile

scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") }
scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") } ?:
// Fallback: In case a Python Version Management tool like Pyenv is used, the directory structure differs.
scanCodeBaseDir?.parentFile?.walkTopDown()
?.onEnter { it != scanCodeBaseDir }
?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") }
}

/**
Expand Down

0 comments on commit de1b915

Please sign in to comment.