From e01d4082da2b938db3fe23ed2f7d1fe740f5a1b8 Mon Sep 17 00:00:00 2001 From: Wolfgang Klenk Date: Mon, 16 Dec 2024 16:50:12 +0100 Subject: [PATCH] fix(scancode): No ScanCode license texts in disclosure document 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 --- utils/spdx/src/main/kotlin/Utils.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/spdx/src/main/kotlin/Utils.kt b/utils/spdx/src/main/kotlin/Utils.kt index 876f8ecf257f9..6891411b6c34a 100644 --- a/utils/spdx/src/main/kotlin/Utils.kt +++ b/utils/spdx/src/main/kotlin/Utils.kt @@ -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") } } /**