2006-01-04 22:42:03 +03:00
|
|
|
#!/bin/sh
|
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
2009-05-16 16:00:56 +04:00
|
|
|
#
|
|
|
|
# This scripts adds local version information from the version
|
|
|
|
# control systems git, mercurial (hg) and subversion (svn).
|
|
|
|
#
|
|
|
|
# If something goes wrong, send a mail the kernel build mailinglist
|
|
|
|
# (see MAINTAINERS) and CC Nico Schottelius
|
|
|
|
# <nico-linuxsetlocalversion -at- schottelius.org>.
|
|
|
|
#
|
|
|
|
#
|
2005-07-31 12:57:49 +04:00
|
|
|
|
2006-01-04 22:42:03 +03:00
|
|
|
usage() {
|
2023-03-15 18:50:18 +03:00
|
|
|
echo "Usage: $0 [--no-local] [srctree]" >&2
|
2006-01-04 22:42:03 +03:00
|
|
|
exit 1
|
2005-07-31 12:57:49 +04:00
|
|
|
}
|
|
|
|
|
2023-03-15 18:50:18 +03:00
|
|
|
no_local=false
|
|
|
|
if test "$1" = "--no-local"; then
|
|
|
|
no_local=true
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2010-06-17 17:14:58 +04:00
|
|
|
srctree=.
|
|
|
|
if test $# -gt 0; then
|
|
|
|
srctree=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
if test $# -gt 0 -o ! -d "$srctree"; then
|
|
|
|
usage
|
|
|
|
fi
|
2005-07-31 12:57:49 +04:00
|
|
|
|
2010-06-17 17:14:58 +04:00
|
|
|
scm_version()
|
|
|
|
{
|
2023-03-15 18:50:18 +03:00
|
|
|
local short=false
|
|
|
|
local no_dirty=false
|
2023-02-05 15:09:57 +03:00
|
|
|
local tag
|
2023-03-15 18:50:18 +03:00
|
|
|
|
|
|
|
while [ $# -gt 0 ];
|
|
|
|
do
|
|
|
|
case "$1" in
|
|
|
|
--short)
|
|
|
|
short=true;;
|
|
|
|
--no-dirty)
|
|
|
|
no_dirty=true;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2009-05-16 16:00:56 +04:00
|
|
|
|
2010-06-17 17:14:58 +04:00
|
|
|
cd "$srctree"
|
2009-05-16 16:00:56 +04:00
|
|
|
|
2023-01-22 17:14:23 +03:00
|
|
|
if test -n "$(git rev-parse --show-cdup 2>/dev/null)"; then
|
|
|
|
return
|
|
|
|
fi
|
2010-06-17 17:14:58 +04:00
|
|
|
|
2023-01-22 17:14:23 +03:00
|
|
|
if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then
|
|
|
|
return
|
|
|
|
fi
|
2010-06-17 17:14:58 +04:00
|
|
|
|
2023-02-05 15:09:57 +03:00
|
|
|
# If a localversion*' file and the corresponding annotated tag exist,
|
|
|
|
# use it. This is the case in linux-next.
|
|
|
|
tag=${file_localversion#-}
|
|
|
|
tag=$(git describe --exact-match --match=$tag $tag 2>/dev/null)
|
|
|
|
|
|
|
|
# Otherwise, default to the annotated tag derived from KERNELVERSION.
|
|
|
|
# mainline kernel: 6.2.0-rc5 -> v6.2-rc5
|
|
|
|
# stable kernel: 6.1.7 -> v6.1.7
|
|
|
|
if [ -z "${tag}" ]; then
|
|
|
|
tag=v$(echo "${KERNELVERSION}" | sed -E 's/^([0-9]+\.[0-9]+)\.0(.*)$/\1\2/')
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If we are at the tagged commit, we ignore it because the version is
|
|
|
|
# well-defined.
|
|
|
|
if [ -z "$(git describe --exact-match --match=$tag 2>/dev/null)" ]; then
|
2021-05-23 06:14:27 +03:00
|
|
|
|
2023-01-22 17:14:23 +03:00
|
|
|
# If only the short version is requested, don't bother
|
|
|
|
# running further git commands
|
|
|
|
if $short; then
|
|
|
|
echo "+"
|
|
|
|
return
|
2010-06-17 17:14:58 +04:00
|
|
|
fi
|
2023-02-05 15:09:57 +03:00
|
|
|
# If we are past the tagged commit, we pretty print it.
|
|
|
|
# (like 6.1.0-14595-g292a089d78d3)
|
|
|
|
if atag="$(git describe --match=$tag 2>/dev/null)"; then
|
2023-01-22 17:14:23 +03:00
|
|
|
echo "$atag" | awk -F- '{printf("-%05d", $(NF-1))}'
|
2010-06-17 17:14:58 +04:00
|
|
|
fi
|
2023-01-22 17:14:23 +03:00
|
|
|
|
|
|
|
# Add -g and exactly 12 hex chars.
|
|
|
|
printf '%s%s' -g "$(echo $head | cut -c1-12)"
|
|
|
|
fi
|
|
|
|
|
2023-03-15 18:50:18 +03:00
|
|
|
if ${no_dirty}; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2023-01-22 17:14:23 +03:00
|
|
|
# Check for uncommitted changes.
|
|
|
|
# This script must avoid any write attempt to the source tree, which
|
|
|
|
# might be read-only.
|
|
|
|
# You cannot use 'git describe --dirty' because it tries to create
|
|
|
|
# .git/index.lock .
|
|
|
|
# First, with git-status, but --no-optional-locks is only supported in
|
|
|
|
# git >= 2.14, so fall back to git-diff-index if it fails. Note that
|
|
|
|
# git-diff-index does not refresh the index, so it may give misleading
|
|
|
|
# results.
|
|
|
|
# See git-update-index(1), git-diff-index(1), and git-status(1).
|
|
|
|
if {
|
|
|
|
git --no-optional-locks status -uno --porcelain 2>/dev/null ||
|
|
|
|
git diff-index --name-only HEAD
|
|
|
|
} | read dummy; then
|
|
|
|
printf '%s' -dirty
|
2010-06-17 17:14:58 +04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
collect_files()
|
|
|
|
{
|
2019-10-01 15:17:24 +03:00
|
|
|
local file res=
|
2010-06-17 17:14:58 +04:00
|
|
|
|
|
|
|
for file; do
|
|
|
|
case "$file" in
|
|
|
|
*\~*)
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if test -e "$file"; then
|
|
|
|
res="$res$(cat "$file")"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "$res"
|
|
|
|
}
|
|
|
|
|
2023-01-22 17:14:25 +03:00
|
|
|
if [ -z "${KERNELVERSION}" ]; then
|
|
|
|
echo "KERNELVERSION is not set" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-06-17 17:14:58 +04:00
|
|
|
# localversion* files in the build and source directory
|
2023-02-05 15:09:56 +03:00
|
|
|
file_localversion="$(collect_files localversion*)"
|
2010-06-17 17:14:58 +04:00
|
|
|
if test ! "$srctree" -ef .; then
|
2023-02-05 15:09:56 +03:00
|
|
|
file_localversion="${file_localversion}$(collect_files "$srctree"/localversion*)"
|
2010-06-17 17:14:58 +04:00
|
|
|
fi
|
|
|
|
|
2023-03-15 18:50:18 +03:00
|
|
|
if ${no_local}; then
|
|
|
|
echo "${KERNELVERSION}$(scm_version --no-dirty)"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! test -e include/config/auto.conf; then
|
|
|
|
echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-02-05 15:09:56 +03:00
|
|
|
# version string from CONFIG_LOCALVERSION
|
kbuild: do not quote string values in include/config/auto.conf
The previous commit fixed up all shell scripts to not include
include/config/auto.conf.
Now that include/config/auto.conf is only included by Makefiles,
we can change it into a more Make-friendly form.
Previously, Kconfig output string values enclosed with double-quotes
(both in the .config and include/config/auto.conf):
CONFIG_X="foo bar"
Unlike shell, Make handles double-quotes (and single-quotes as well)
verbatim. We must rip them off when used.
There are some patterns:
[1] $(patsubst "%",%,$(CONFIG_X))
[2] $(CONFIG_X:"%"=%)
[3] $(subst ",,$(CONFIG_X))
[4] $(shell echo $(CONFIG_X))
These are not only ugly, but also fragile.
[1] and [2] do not work if the value contains spaces, like
CONFIG_X=" foo bar "
[3] does not work correctly if the value contains double-quotes like
CONFIG_X="foo\"bar"
[4] seems to work better, but has a cost of forking a process.
Anyway, quoted strings were always PITA for our Makefiles.
This commit changes Kconfig to stop quoting in include/config/auto.conf.
These are the string type symbols referenced in Makefiles or scripts:
ACPI_CUSTOM_DSDT_FILE
ARC_BUILTIN_DTB_NAME
ARC_TUNE_MCPU
BUILTIN_DTB_SOURCE
CC_IMPLICIT_FALLTHROUGH
CC_VERSION_TEXT
CFG80211_EXTRA_REGDB_KEYDIR
EXTRA_FIRMWARE
EXTRA_FIRMWARE_DIR
EXTRA_TARGETS
H8300_BUILTIN_DTB
INITRAMFS_SOURCE
LOCALVERSION
MODULE_SIG_HASH
MODULE_SIG_KEY
NDS32_BUILTIN_DTB
NIOS2_DTB_SOURCE
OPENRISC_BUILTIN_DTB
SOC_CANAAN_K210_DTB_SOURCE
SYSTEM_BLACKLIST_HASH_LIST
SYSTEM_REVOCATION_KEYS
SYSTEM_TRUSTED_KEYS
TARGET_CPU
UNUSED_KSYMS_WHITELIST
XILINX_MICROBLAZE0_FAMILY
XILINX_MICROBLAZE0_HW_VER
XTENSA_VARIANT_NAME
I checked them one by one, and fixed up the code where necessary.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2021-12-14 05:53:53 +03:00
|
|
|
config_localversion=$(sed -n 's/^CONFIG_LOCALVERSION=\(.*\)$/\1/p' include/config/auto.conf)
|
2010-06-17 17:14:58 +04:00
|
|
|
|
2023-02-05 15:09:57 +03:00
|
|
|
# scm version string if not at the kernel version tag or at the file_localversion
|
2021-12-14 05:53:52 +03:00
|
|
|
if grep -q "^CONFIG_LOCALVERSION_AUTO=y$" include/config/auto.conf; then
|
2010-06-17 17:14:58 +04:00
|
|
|
# full scm version string
|
2023-02-05 15:09:56 +03:00
|
|
|
scm_version="$(scm_version)"
|
2021-07-12 22:35:46 +03:00
|
|
|
elif [ "${LOCALVERSION+set}" != "set" ]; then
|
|
|
|
# If the variable LOCALVERSION is not set, append a plus
|
|
|
|
# sign if the repository is not in a clean annotated or
|
|
|
|
# signed tagged state (as git describe only looks at signed
|
|
|
|
# or annotated tags - git tag -a/-s).
|
|
|
|
#
|
|
|
|
# If the variable LOCALVERSION is set (including being set
|
|
|
|
# to an empty string), we don't want to append a plus sign.
|
2023-02-05 15:09:56 +03:00
|
|
|
scm_version="$(scm_version --short)"
|
2008-02-03 09:13:26 +03:00
|
|
|
fi
|
2010-06-17 17:14:58 +04:00
|
|
|
|
2023-02-05 15:09:56 +03:00
|
|
|
echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"
|