Whamcloud - gitweb
LU-18217 build: Ensure LINUX_RELEASE is defined
[fs/lustre-release.git] / contrib / scripts / license-status
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-only
3
4 #
5 # Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
6 #
7 # Copyright (c) 2023-2024, Amazon and/or its affiliates. All rights reserved.
8 # Use is subject to license terms.
9 #
10
11 #
12 # This file is part of Lustre, http://www.lustre.org/
13 #
14 # Display the license status of files in the current directory
15 #
16 # Author: Gordon Matzigkeit <gord@fig.org>, 2001-09-27
17 # Author: Timothy Day <timday@amazon.com>, 2023-04-03
18 #
19
20 export files="${1:-$(pwd)}"
21
22 for file in $(git ls-files "$files"); do
23         if head -20 "$file" | grep -Ee 'SPDX' > /dev/null; then
24                 license="$(grep SPDX "$file" | awk '{ print $3; exit; }')"
25                 printf "%-10s %-15s %-s\n" "SPDX" "$license" "$file"
26         elif head -20 "$file" | grep -Ee 'GNU General Public License' > /dev/null; then
27                 printf "%-10s %-15s %-s\n" "guess" "gpled" "$file"
28         elif head -20 "$file" | grep -Ee '\([Cc]\)' > /dev/null; then
29                 printf "%-10s %-15s %-s\n" "guess" "copyright" "$file"
30         else
31                 printf "%-10s %-15s %-s\n" "guess" "unknown" "$file"
32         fi
33 done | sort