Skip to content

Commit 958c08c

Browse files
wkl3nksschuberth
authored andcommitted
fix(scancode): Ensure to find license texts in the Docker image
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]>
1 parent f0dd53a commit 958c08c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ RUN ARCH=$(arch | sed s/aarch64/arm64/) \
157157
rm requirements.txt; \
158158
fi
159159

160+
# Extract ScanCode license texts to a directory.
161+
RUN scancode-license-data --path /opt/scancode-license-data \
162+
&& find /opt/scancode-license-data -type f -not -name "*.LICENSE" -exec rm -f {} + \
163+
&& rm -rf /opt/scancode-license-data/static
164+
160165
RUN pip install --no-cache-dir -U \
161166
pip=="$PIPTOOL_VERSION" \
162167
wheel \
@@ -171,6 +176,9 @@ RUN pip install --no-cache-dir -U \
171176
FROM scratch AS python
172177
COPY --from=pythonbuild /opt/python /opt/python
173178

179+
FROM scratch as scancode-license-data
180+
COPY --from=pythonbuild /opt/scancode-license-data /opt/scancode-license-data
181+
174182
#------------------------------------------------------------------------
175183
# NODEJS - Build NodeJS as a separate component with nvm
176184
FROM base AS nodejsbuild
@@ -493,6 +501,8 @@ ENV GEM_HOME=/var/tmp/gem
493501
ENV PATH=$PATH:$RBENV_ROOT/bin:$RBENV_ROOT/shims:$RBENV_ROOT/plugins/ruby-install/bin
494502
COPY --from=ruby --chown=$USER:$USER $RBENV_ROOT $RBENV_ROOT
495503

504+
COPY --from=scancode-license-data --chown=$USER:$USER /opt/scancode-license-data /opt/scancode-license-data
505+
496506
#------------------------------------------------------------------------
497507
# Container with all supported package managers.
498508
FROM minimal-tools as all-tools

utils/spdx/src/main/kotlin/Utils.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ val scanCodeLicenseTextDir by lazy {
4949
val pythonBinDir = listOf("bin", "Scripts")
5050
val scanCodeBaseDir = scanCodeExeDir?.takeUnless { it.name in pythonBinDir } ?: scanCodeExeDir?.parentFile
5151

52-
scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") }
52+
scanCodeBaseDir?.walkTopDown()?.find { it.isDirectory && it.endsWith("licensedcode/data/licenses") } ?:
53+
File("/opt/scancode-license-data").takeIf { it.isDirectory }
5354
}
5455

5556
/**

0 commit comments

Comments
 (0)