hack/validate/vendor: simplify looking for license

It was suggested that we use '.*\(COPYING\|LICENSE\|COPYRIGHT\).*'
as an argument to `find -iregex`, and this is how it all started.

Next thing, there is no COPYRIGHT in any of the vendored packages,
so it can be removed for good.

Next, we should not look too deep inside the package directory, as
the license should be in its root directory, so add `-maxdepth 1`
to `find`. This should also speed things up.

Finally, since we're not using the recursion feature of `find`,
it can be replaced with `echo | grep`.

While at it,
* avoid temporary $pkgs variable as it is only used once;
* replace `ls -d "vendor/$f"  > /dev/null 2>&1` with `test -d`.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2019-10-29 10:53:46 -07:00
parent 4be12ad3d0
commit 5791019028
1 changed files with 3 additions and 4 deletions

View File

@ -38,10 +38,9 @@ validate_vendor_diff(){
# 1. make sure all the vendored packages are used
# 2. make sure all the packages contain license information (just warning, because it can cause false-positive)
validate_vendor_used() {
pkgs=$(mawk '/^[a-zA-Z0-9]/ { print $1 }' < vendor.conf)
for f in $pkgs; do
if ls -d "vendor/$f" > /dev/null 2>&1; then
found=$(find "vendor/$f" -iregex '.*LICENSE.*' -or -iregex '.*COPYRIGHT.*' -or -iregex '.*COPYING.*' | wc -l)
for f in $(mawk '/^[a-zA-Z0-9]/ { print $1 }' vendor.conf); do
if [ -d "vendor/$f" ]; then
found=$(echo "vendor/$f/"* | grep -iEc '/(LICENSE|COPYING)')
if [ "$found" -eq 0 ]; then
echo "WARNING: could not find copyright information for $f"
fi