From b5b52b854e5340245a97d91e483e32cb46f48ca3 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Sat, 3 Aug 2024 16:02:43 -0400 Subject: [PATCH] LU-16707 scripts: make license-status more flexible Accept a path argument to restrict the search to a sub-tree. By default, use the current directory. Also, fix some shellcheck errors. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: Iaddf0c22f8fed80947b0b511f9a56f6a35e0347b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55928 Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- contrib/scripts/license-status | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/scripts/license-status b/contrib/scripts/license-status index 0001baa..7a60610 100755 --- a/contrib/scripts/license-status +++ b/contrib/scripts/license-status @@ -4,25 +4,28 @@ # # Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. # +# Copyright (c) 2023-2024, Amazon and/or its affiliates. All rights reserved. +# Use is subject to license terms. +# # # This file is part of Lustre, http://www.lustre.org/ # -# contrib/scripts/license-status -# # Display the license status of files in the current directory # # Author: Gordon Matzigkeit , 2001-09-27 # Author: Timothy Day , 2023-04-03 # -for file in $(git ls-tree -r HEAD --name-only); do - if head -20 "$file" | egrep -e 'SPDX' > /dev/null; then - license="$(grep SPDX $file | awk '{ print $3; exit; }')" +export files="${1:-$(pwd)}" + +for file in $(git ls-files "$files"); do + if head -20 "$file" | grep -Ee 'SPDX' > /dev/null; then + license="$(grep SPDX "$file" | awk '{ print $3; exit; }')" printf "%-10s %-15s %-s\n" "SPDX" "$license" "$file" - elif head -20 "$file" | egrep -e 'GNU General Public License' > /dev/null; then + elif head -20 "$file" | grep -Ee 'GNU General Public License' > /dev/null; then printf "%-10s %-15s %-s\n" "guess" "gpled" "$file" - elif head -20 "$file" | egrep -e '\([Cc]\)' > /dev/null; then + elif head -20 "$file" | grep -Ee '\([Cc]\)' > /dev/null; then printf "%-10s %-15s %-s\n" "guess" "copyright" "$file" else printf "%-10s %-15s %-s\n" "guess" "unknown" "$file" -- 1.8.3.1