Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix presubmit failure by avoiding license downloading when building image #3406

Merged
merged 6 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/Dockerfile.visualization
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# visualization. More details about this process can be found in the server.py
# and exporter.py files in the directory specified above.

# Copyright 2019 Google LLC
# Copyright 2019-2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -37,6 +37,7 @@ RUN pip3 install -r requirements.txt

COPY backend/src/apiserver/visualization/license.sh /src
COPY backend/src/apiserver/visualization/third_party_licenses.csv /src
COPY backend/src/apiserver/visualization/third_party_licenses /usr/licenses

RUN ./license.sh third_party_licenses.csv /usr/licenses

Expand Down
33 changes: 33 additions & 0 deletions backend/src/apiserver/visualization/license-download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# A script to download licenses based on
# a specified license table (3 columns: name,license_link,license_type) csv file.
#
# Usage:
# ./license-download.sh ./third_party_licenses.csv ./third_party_licenses

mkdir -p $2

IFS=$'\n'
while IFS=, read -r col1 col2 col3
do
DEST="$2/$col1.LICENSE"
if [[ -f "$DEST" ]]; then
echo "Skip downloaded license file $DEST."
else
wget -O $2/$col1.LICENSE $col2
rmgogogo marked this conversation as resolved.
Show resolved Hide resolved
fi
done < $1
15 changes: 14 additions & 1 deletion backend/src/apiserver/visualization/license.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,22 @@ mkdir -p $2/source
while IFS=, read -r col1 col2 col3
do
if [[ " ${INSTALLED_PACKAGES[@]} " =~ " ${col1} " ]]; then
wget -O $2/$col1.LICENSE $col2
# Download license is moved to part of `./license-download.sh`.
# wget -O $2/$col1.LICENSE $col2
# We check existence of the license file instead.
if [[ -f "$2/${col1}.LICENSE" ]]; then
echo "OK: ${col1}'s license exists."
else
echo "Error: ${col1} package's license is missing."
echo "Please rerun ./license-download.sh locally and commit into licenses folder."
exit 1
fi
if [[ "${col3}" == *GPL* ]] || [[ "${col3}" =~ ^MPL ]]; then
pip install -t "$2/source/${col1}" ${col1}
fi
else
echo "${col1} is part of third_party_licenses.csv, but not installed"
echo "Please remove ${col1} from third_party_licenses.csv"
exit 1
fi
done < $1
Loading