Skip to content

Instantly share code, notes, and snippets.

@azriel91
Created December 4, 2018 00:37
Show Gist options
  • Select an option

  • Save azriel91/3bc29b4c131e5734652b51ac2f045865 to your computer and use it in GitHub Desktop.

Select an option

Save azriel91/3bc29b4c131e5734652b51ac2f045865 to your computer and use it in GitHub Desktop.
#! /bin/bash
# License compatibility
licenses_allowed=(
Apache-2.0
BSD-2-Clause
BSD-3-Clause
BSL-1.0
CC0-1.0
FTL
ISC
MIT
MPL-2.0
N/A
Unlicense
Zlib
)
IFS=$'\n'
blacklist=()
for license_group in $(cargo license); do
for allowed in "${licenses_allowed[@]}"; do
# If we detect a compatible license, continue
if printf "%s" "${license_group}" | grep -qF "${allowed}"; then
continue 2 # Continue outer loop
fi
done
blacklist=("${blacklist[@]}" "${license_group}")
done
if test -n "${blacklist}"; then
echo -e "Incompatible license detected in dependent crate(s). \n"\
"The following are not compatible with a closed-source commercial application: \n"\
"${blacklist}"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment