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
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 committed Dec 18, 2024
1 parent c259ffb commit dd37d32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 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 ! -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,9 @@ 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

# ScanCode license texts directory
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 dd37d32

Please sign in to comment.