提交 6d49059a 编写于 作者: R Renaud Gaubert

Add license checker

Signed-off-by: NRenaud Gaubert <rgaubert@nvidia.com>
上级 03af0a80
services:
- docker:stable-dind
variables:
LICENSE_TAG: $CI_REGISTRY_IMAGE:license
stages:
- build
- unit
license-builder:
image: docker:stable
stage: build
only:
# changes:
# - license/Dockerfile
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $LICENSE_TAG ./license
- docker push $LICENSE_TAG
license:
stage: unit
image:
name: $LICENSE_TAG
script:
- ./license/check.sh
FROM debian:buster-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ruby \
ruby-dev \
bundler \
cmake \
pkg-config \
git \
build-essential \
libssl-dev
RUN gem install licensee
CMD ["/bin/bash"]
#! /bin/bash
set -ex
find . \( -path ./.git -o -path ./license \) -prune -o -print -type f | \
grep -i -E "license|copying" > /tmp/LICENSES.list
for path in `cat /tmp/LICENSES.list`; do
# Print the license for logging purposes
licensee detect ${path} | tee -a /tmp/LICENSE.full
# Ensure the format is of the form "${path} ${license}"
license=$(licensee detect ${path} | \
grep '^License:' | tr -s ' ' | awk '{print $2}')
confidence=$(licensee detect ${path} | \
tr -s ' ' | grep -E '^ Confidence:' | awk '{print $2}')
echo "Inspecting License ${license} (${confidence}) at ${path}" | tee -a /tmp/LICENSE.result
if ! grep -Fxq "${license}" ./license/whitelist.txt; then
echo "Found unexpected license at ${path}"
exit 1
fi
done
cat /tmp/LICENSE.result
Apache-2.0
BSD-3-Clause
MIT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册