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 <[email protected]>
  • Loading branch information
wkl3nk committed Dec 16, 2024
1 parent c259ffb commit 303e82f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 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,9 @@ 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") } ?:
// In cases where Python version management tools like Pyenv are used, the directory structure differs.
scanCodeBaseDir?.parentFile?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") }
}

/**
Expand Down

0 comments on commit 303e82f

Please sign in to comment.