Skip to content

Commit 36075ec

Browse files
inaky-intcAnas Nashif
authored andcommitted
scripts: look for files with no licensing info
Bash hack that will parse the list of files known to git, filter the ones for which we think we have licensing info, filter trivial ones and print the non-compliant ones to stdout: $ cd WHEREVER/zephyr.git $ scripts/scan-no-license.sh > no-license I: 6327 files total I: 3568 after filtering known issues I: 3568 files before, 1828 after filtering token 'SPDX-License-Identifier' I: 1828 files before, 1027 after filtering token 'Copyright' I: 1027 files before, 1023 after filtering token 'License' I: 1023 files before, 1017 after filtering token 'licenseText' I: 1017 files before, 78 after filtering token '([Cc])' I: 78 files without license $ head no-license arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da.qsys arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da.qws arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da.sof arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da.sopcinfo arch/nios2/soc/nios2f-zephyr/cpu/ghrd_10m50da_top.v ... Signed-off-by: Inaky Perez-Gonzalez <[email protected]>
1 parent c6e91f5 commit 36075ec

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

scripts/scan-no-license.sh

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#! /bin/sh
2+
#
3+
# Copyright (c) 2017 Intel Corporation.
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
#
8+
# Scan for files without some kind of a license header or
9+
# Copyright. Skip some files (as described in the first grep) due to:
10+
#
11+
# - them being trivial
12+
# - them being covered by the blanket Apache 2.0 license at the top
13+
# level
14+
#
15+
# The second grep scans for strings that mark a license
16+
# header/copyright and skip those. Print the rest to stdout.
17+
#
18+
# Run on top of the git tree
19+
#
20+
tmpdir=$(mktemp -d)
21+
trap "rm -rf $tmpdir" EXIT
22+
# Filter our things we don't need
23+
git ls-files | sort -u > $tmpdir/files-all
24+
echo "I: $(wc -l < $tmpdir/files-all) files total" 1>&2
25+
grep -v \
26+
`# Kbuild files, describing configuration, default` \
27+
`# configs and Makefiles` \
28+
-e Kbuild -e /Kconfig.\* -e Makefile \
29+
-e _defconfig$ -e /defconfig$ \
30+
-e prj\\.\*\\.conf -e \.conf$ \
31+
-e ^kernel/configs/kernel.config$ \
32+
`# Linker scripts` \
33+
-e linked\\.ld$ -e \\.ld$ \
34+
`# Device tree` \
35+
-e \\.dts$ -e \\.fixup$ -e \\.dtsi$ \
36+
-e dts/.*\\.yaml$ \
37+
`# Zephyr Sanity Check configs` \
38+
-e scripts/sanity_chk/arches/.*\\.ini \
39+
-e scripts/sanity_chk/.*\\.args \
40+
-e scripts/sanity_chk/.*\\.csv \
41+
`# Documentation files` \
42+
-e \\.rst$ -e README -e readme\\.txt -e TODO \
43+
-e ^samples/net/wpanusb/wpan-radio-spec.txt$ \
44+
`# Cross compiler support` \
45+
-e ^scripts/cross_compiler/.*\\.config$ \
46+
`# Testcase descriptor` \
47+
-e testcase.ini -e defaults\\.tc \
48+
`# Images we can't scan for text...` \
49+
-e jpg$ -e png$ \
50+
`# OpenOCD configuration files` \
51+
-e openocd.cfg \
52+
`# Zephyr misc configuration stuff` \
53+
-e ^\\.known-issues/ -e ^\\.git -e ^\\.checkpatch.conf \
54+
-e ^\\.mailmap/ -e ^\\.shippable.yml -e \\.gitignore \
55+
`# Nios data format XML` \
56+
-e \.dpf$ \
57+
`# List of maintainers` \
58+
-e MAINTAINERS -e ^\\.mailmap \
59+
`# scripts/kconfig: described doc/LICENSING.rst` \
60+
-e ^scripts/kconfig/ \
61+
`# ext/fs/fat: described in doc/LICENSING.rst` \
62+
-e ^ext/fs/fat \
63+
`# ext/hal/cmsis: a license agreement...` \
64+
-e ^ext/hal/cmsis/CMSIS_END_USER_LICENCE_AGREEMENT.pdf \
65+
`# ext/hal/nxp: trivial` \
66+
-e ^ext/hal/nxp/mcux/devices/MKW40Z4/fsl_clock.c$ \
67+
-e ^ext/hal/nxp/mcux/devices/MKW40Z4/fsl_clock.h$ \
68+
-e ^ext/hal/nxp/mcux/middleware/wireless/framework_5.3.3/OSAbstraction/Source/fsl_os_abstraction_zephyr.c$ \
69+
-e ^samples/bluetooth/hci_uart/.*.overlay$ \
70+
$tmpdir/files-all > $tmpdir/files-before
71+
echo "I: $(wc -l < $tmpdir/files-before) after filtering known issues" 1>&2
72+
73+
for token in \
74+
SPDX-License-Identifier \
75+
Copyright \
76+
License \
77+
licenseText \
78+
\([Cc]\);
79+
do
80+
grep -Lr "$token" $(<$tmpdir/files-before) > $tmpdir/files-after
81+
echo "I: $(wc -l < $tmpdir/files-before) files before,"\
82+
"$(wc -l < $tmpdir/files-after) after filtering token '$token'" 1>&2
83+
mv $tmpdir/files-after $tmpdir/files-before
84+
done
85+
echo "I: $(wc -l < $tmpdir/files-before) files without license information" 1>&2
86+
cat $tmpdir/files-before

0 commit comments

Comments
 (0)