diff --git a/Dockerfile b/Dockerfile index 4fa0b05d3131c..2c6bca2fe826c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -157,6 +157,11 @@ RUN ARCH=$(arch | sed s/aarch64/arm64/) \ rm requirements.txt; \ fi +# Extract ScanCode license texts to a directory. +RUN scancode-license-data --path /opt/scancode-license-data \ + && find /opt/scancode-license-data -type f -not -name "*.LICENSE" -exec rm -f {} + \ + && rm -rf /opt/scancode-license-data/static + RUN pip install --no-cache-dir -U \ pip=="$PIPTOOL_VERSION" \ wheel \ @@ -171,6 +176,9 @@ RUN pip install --no-cache-dir -U \ FROM scratch AS python COPY --from=pythonbuild /opt/python /opt/python +FROM scratch as scancode-license-data +COPY --from=pythonbuild /opt/scancode-license-data /opt/scancode-license-data + #------------------------------------------------------------------------ # NODEJS - Build NodeJS as a separate component with nvm FROM base AS nodejsbuild @@ -493,6 +501,8 @@ ENV GEM_HOME=/var/tmp/gem ENV PATH=$PATH:$RBENV_ROOT/bin:$RBENV_ROOT/shims:$RBENV_ROOT/plugins/ruby-install/bin COPY --from=ruby --chown=$USER:$USER $RBENV_ROOT $RBENV_ROOT +COPY --from=scancode-license-data --chown=$USER:$USER /opt/scancode-license-data /opt/scancode-license-data + #------------------------------------------------------------------------ # Container with all supported package managers. FROM minimal-tools as all-tools diff --git a/utils/spdx/src/main/kotlin/Utils.kt b/utils/spdx/src/main/kotlin/Utils.kt index 876f8ecf257f9..0d799de9f53c0 100644 --- a/utils/spdx/src/main/kotlin/Utils.kt +++ b/utils/spdx/src/main/kotlin/Utils.kt @@ -49,7 +49,8 @@ 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") } ?: + File("/opt/scancode-license-data").takeIf { it.isDirectory } } /**