Abort if we can't find a license

This commit is contained in:
Tim Hockin 2016-05-27 14:13:37 -07:00
parent 392c5dc618
commit aae0c90d64

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Update the Godeps/LICENSES.md document. # Update the Godeps/LICENSES document.
# Generates a table of Godep dependencies and their license. # Generates a table of Godep dependencies and their license.
# #
# Usage: # Usage:
@ -117,6 +117,7 @@ LICENSE_ROOT="${LICENSE_ROOT:-${KUBE_ROOT}}"
cd "${LICENSE_ROOT}" cd "${LICENSE_ROOT}"
GODEPS_LICENSE_FILE="Godeps/LICENSES" GODEPS_LICENSE_FILE="Godeps/LICENSES"
TMP_LICENSE_FILE="/tmp/Godeps.LICENSES.$$"
DEPS_DIR="vendor" DEPS_DIR="vendor"
declare -Ag CONTENT declare -Ag CONTENT
@ -129,7 +130,7 @@ cat ${LICENSE_ROOT}/LICENSE
echo echo
echo "= LICENSE $(cat ${LICENSE_ROOT}/LICENSE | md5sum)" echo "= LICENSE $(cat ${LICENSE_ROOT}/LICENSE | md5sum)"
echo "================================================================================" echo "================================================================================"
) > ${GODEPS_LICENSE_FILE} ) > ${TMP_LICENSE_FILE}
# Loop through every package in Godeps.json # Loop through every package in Godeps.json
for PACKAGE in $(cat Godeps/Godeps.json | \ for PACKAGE in $(cat Godeps/Godeps.json | \
@ -144,21 +145,22 @@ for PACKAGE in $(cat Godeps/Godeps.json | \
echo "= ${DEPS_DIR}/${PACKAGE} licensed under: =" echo "= ${DEPS_DIR}/${PACKAGE} licensed under: ="
echo echo
content="" file=""
if [[ -n "${CONTENT[${PACKAGE}-LICENSE]-}" ]]; then if [[ -n "${CONTENT[${PACKAGE}-LICENSE]-}" ]]; then
content="${CONTENT[${PACKAGE}-LICENSE]-}" file="${CONTENT[${PACKAGE}-LICENSE]-}"
elif [[ -n "${CONTENT[${PACKAGE}-COPYRIGHT]-}" ]]; then elif [[ -n "${CONTENT[${PACKAGE}-COPYRIGHT]-}" ]]; then
content="${CONTENT[${PACKAGE}-COPYRIGHT]-}" file="${CONTENT[${PACKAGE}-COPYRIGHT]-}"
fi fi
if [[ -z "${content}" ]]; then if [[ -z "${file}" ]]; then
echo "UNKNOWN" echo "Could not find a license for ${PACKAGE} - aborting" > /dev/stderr
content="/dev/null" exit 9
else
cat "${content}"
fi fi
cat "${file}"
echo echo
echo "= ${content} $(cat ${content} | md5sum)" echo "= ${file} $(cat ${file} | md5sum)"
echo "================================================================================" echo "================================================================================"
echo echo
done >> ${GODEPS_LICENSE_FILE} done >> ${TMP_LICENSE_FILE}
cat ${TMP_LICENSE_FILE} > ${GODEPS_LICENSE_FILE}