Skip to content

Commit

Permalink
fix(scancode): Ensure to find license texts in the Docker image
Browse files Browse the repository at this point in the history
Dump the ScanCode license texts to directory /opt/scancode-license-data
when creating the ORT docker container. Use this directory as
fallback option if the ScanCode license texts cannot be located by
the existing heuristic algorithm.

Fixes #8147.

Signed-off-by: Wolfgang Klenk <[email protected]>
  • Loading branch information
wkl3nk authored and sschuberth committed Dec 20, 2024
1 parent f0dd53a commit 958c08c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 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,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 }
}

/**
Expand Down

0 comments on commit 958c08c

Please sign in to comment.