|
| 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