|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Copyright 2018 Istio Authors. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +################################################################################ |
| 18 | + |
| 19 | +set -eu |
| 20 | + |
| 21 | +# Check whether any git repositories are defined. |
| 22 | +# Git repository definition contains `commit` and `remote` fields. |
| 23 | +if git --no-pager grep -E "commit =|remote =" -- 'WORKSPACE' '*.bzl'; then |
| 24 | + echo "Using git repositories is not allowed." |
| 25 | + echo "To ensure that all dependencies can be stored offline in distdir, only HTTP repositories are allowed." |
| 26 | + exit 1 |
| 27 | +fi |
| 28 | + |
| 29 | +# Check whether number of defined `url =` and `sha256 =` kwargs in repository |
| 30 | +# definitions is equal. |
| 31 | +urls_count=$(git --no-pager grep -E "url =" -- 'WORKSPACE' '*.bzl' | wc -l) |
| 32 | +sha256sums_count=$(git --no-pager grep -E "sha256 =" -- 'WORKSPACE' '*.bzl' | wc -l) |
| 33 | + |
| 34 | +if [[ $urls_count != $sha256sums_count ]]; then |
| 35 | + echo "Found more defined repository URLs than SHA256 sums, which means that there are some repositories without sums." |
| 36 | + echo "Dependencies without SHA256 sums cannot be stored in distdir." |
| 37 | + echo "Please ensure that every repository has a SHA256 sum." |
| 38 | + echo "Repositories are defined in the WORKSPACE file." |
| 39 | + exit 1 |
| 40 | +fi |
0 commit comments