Permalink
Switch branches/tags
v2.2.0-alpha.00000000 v2.1.0-beta.20181015 v2.1.0-beta.20181008 v2.1.0-beta.20181001 v2.1.0-beta.20180924 v2.1.0-beta.20180917 v2.1.0-beta.20180910 v2.1.0-beta.20180904 v2.1.0-beta.20180827 v2.1.0-alpha.20180730 v2.1.0-alpha.20180702 v2.1.0-alpha.20180604 v2.1.0-alpha.20180507 v2.1.0-alpha.20180416 v2.1.0-alpha.00000000 v2.0.6 v2.0.6-rc.1 v2.0.5 v2.0.4 v2.0.3 v2.0.2 v2.0.1 v2.0.0 v2.0-rc.1 v2.0-beta.20180326 v2.0-beta.20180319 v2.0-beta.20180312 v2.0-beta.20180305 v2.0-alpha.20180212 v2.0-alpha.20180129 v2.0-alpha.20180122 v2.0-alpha.20180116 v2.0-alpha.20171218 v2.0-alpha.20171218-plus-left-join-fix v1.2-alpha.20171211 v1.2-alpha.20171204 v1.2-alpha.20171113 v1.2-alpha.20171026 v1.2-alpha.20170901 v1.1.9 v1.1.9-rc.1 v1.1.8 v1.1.7 v1.1.6 v1.1.5 v1.1.4 v1.1.3 v1.1.2 v1.1.1 v1.1.0 v1.1.0-rc.1 v1.1-beta.20170928 v1.1-beta.20170921 v1.1-beta.20170907 v1.1-alpha.20170817 v1.1-alpha.20170810 v1.1-alpha.20170803 v1.1-alpha.20170720 v1.1-alpha.20170713 v1.1-alpha.20170629 v1.1-alpha.20170622 v1.1-alpha.20170608 v1.1-alpha.20170601 v1.0.7 v1.0.6 v1.0.5 v1.0.4 v1.0.3 v1.0.2 v1.0.1 v1.0 v1.0-rc.3 v1.0-rc.2 v1.0-rc.1 v0.1-alpha beta-20170420 beta-20170413 beta-20170406 beta-20170330 beta-20170323 beta-20170309 beta-20170223 beta-20170216 beta-20170209 beta-20170126 beta-20170112 beta-20170105 beta-20161215 beta-20161208 beta-20161201 beta-20161110 beta-20161103 beta-20161027 beta-20161013 beta-20161006 beta-20160929 beta-20160915 beta-20160908 beta-20160829 beta-20160728
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 104 lines (86 sloc) 2.81 KB
#!/usr/bin/env bash
set -euo pipefail
# Output the license info for the current directory's dependencies.
#
# The output is sorted by package name:
# <package-repo-root> <license info>
function isApache2() {
# The first pair of patterns matches the apache license itself; the
# last is the header that some projects use in place of the full
# license.
(grep -q '[[:space:]]*Apache License' "$1" && \
grep -q '[[:space:]]*Version 2\.0,' "$1") || \
grep -q '^Licensed under the Apache License, Version 2.0 (the "License")' "$1"
}
function isBSD2Clause() {
grep -q 'Redistributions of source code must retain the above copyright' "$1" && \
grep -q 'this list of conditions and the following disclaimer' "$1" &&
grep -q 'Redistributions in binary form must reproduce the above' "$1"
}
function isBSD3Clause() {
egrep -q 'Neither the name of .* nor the names of its' "$1"
}
function isBSD4Clause() {
grep -q 'All advertising materials mentioning features' "$1"
}
function isLGPLV3() {
grep -q '[[:space:]]*GNU LESSER GENERAL PUBLIC LICENSE' "$1" && \
grep -q '[[:space:]]Version 3' "$1"
}
function isMIT() {
if grep -q 'MIT License' "$1"; then
return 0
fi
grep -q 'Permission is hereby granted, free of charge, to any person' "$1" && \
grep -q 'The above copyright notice and this permission notice' "$1"
}
function isCC0() {
grep -q 'This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication' "$1"
}
function isMPL2() {
grep -q '^Mozilla Public License Version 2.0' "$1"
}
function inspect() {
local dir="$1"
local files="$(ls ${dir}/{LICENSE,COPYING} 2>/dev/null)"
files="${files} $(ls ${dir}/LICEN[CS]E.{md,txt,code} 2>/dev/null)"
files="${files} $(ls ${dir}/*/{LICENSE,COPYING} 2>/dev/null)"
for file in $files; do
if [ -e "${file}" ]; then
if isApache2 "${file}"; then
echo "Apache License 2.0"
return
elif isBSD2Clause "${file}"; then
if isBSD4Clause "${file}"; then
echo "BSD 4-Clause License"
elif isBSD3Clause "${file}"; then
echo "BSD 3-Clause License"
else
echo "BSD 2-Clause License"
fi
return
elif isLGPLV3 "${file}"; then
echo "GNU Lesser General Public License 3.0"
return
elif isMIT "${file}"; then
echo "MIT License"
return
elif isCC0 "${file}"; then
echo "Creative Commons CC0"
return
elif isMPL2 "${file}"; then
echo "Mozilla Public License 2.0"
return
fi
# TODO(pmattis): This is incomplete. Add other license
# detectors as necessary.
break
fi
done
echo "unable to determine license"
}
pkgs=$(grep '^- name: ' Gopkg.lock | cut -d' ' -f3)
for pkg in ${pkgs}; do
info=$(inspect "vendor/${pkg}")
printf "%-50s %s\n" "${pkg}" "${info}"
done